12:Web及MySQL服务异常监测案例

[root@db01 scripts]# cat db_check.sh 
#!/bin/bash

db_num=$(mysql -h172.16.1.51   -P3306 -uroot -poldboy123 -e "show databases;"|wc -l)

if [ $(db_num) -gt 3  ]
then
    echo "数据库运行正常"
else
    echo "没启动"

fi

 

[root@jenkins scripts]# cat web_db.sh 
#!/bin/bash
##############################################################
# File Name: web_db.sh
# Version: V1.0
# Author: gaobo
# Organization: 641627690@qq.com
# Created Time : 2017-12-06 18:58:47
# Description:
##############################################################
ret_code=$(curl  -s  -I www.baidu.com|awk 'NR==1{print $2}')

np_dk=$(nmap 10.0.0.64 8080 2>/dev/null|grep "8080/tcp open"|wc -l)

sjk_dk=$(nmap 10.0.0.51|grep "3306/tcp open"|wc -l)

[ ${sjk_dk} -gt 0 ] && echo "数据库3306端口开启"
if [ ${ret_code} -eq 200  -a ${sjk_dk} -gt 0 ]
then
    echo "web服务开启"
    
fi

 

posted @ 2017-12-07 16:53  滴滴滴  阅读(275)  评论(0编辑  收藏  举报