#!/bin/bash
path=/
logfile=/var/log/moniter.log
date=`(date +%D--%T)`
hostname=qubaoquan.test.com
ip=192.168.10.195
sleeptime=30
mydnsmessege="the mydns server have reboot"
mysqlmessege="the mysql server have reboot"
$path/check_dns -H $hostname -s $ip>$path/respone.txt
valuese=`(awk '{print $2}' $path/respone.txt | sed 's/://g')`
mydns=`(awk '{print $1}' $path/respone.txt)`
mysql=`(awk '{print $4}' $path/respone.txt)`
mydnsdown=CRITICAL
ok=OK
sqldown=not
if [[ $valuse != $ok ]]
then
if [[ $mydns == $mydnsdown ]]
then
ifconfig eth1 down;killall -9 mydns;service mydns start;echo "$mydnsmessege on $date">>$logfile;sleep $sleeptime;ifconfig eth1 up
elif [[ $mysql == $sqldown ]]
then
ifconfig eth1 down;killall -9 mysqld;service mysqld start;echo "$mysqlmessege on $date">>$logfile;sleep $sleeptime;ifconfig eth1 up
fi
fi
阅读(596) | 评论(0) | 转发(0) |