mysql监控脚本

Mysql监控脚本,如果状态出现问题,会自动重启,并且发邮件通知

#######################

#!/bin/bash

####mysql status

time="$(date +"%Y%m%d-%H:%M")"

service="/sbin/service"

/usr/local/mysql/bin/mysqladmin -u root -pxxx ping &> /dev/null

if [ $? = 0 ]

then

echo "......hello" &> /dev/null

else

$service mysqld restart

echo "$time mysqld service is down .... restart..." >> /var/log/www/mysql.log

echo "$time mysqld service restart ...." > /root/mail-mysql.txt

mail -s "$time mysqld down" [email protected] < /root/mail-mysql.txt

fi

##################end##########



你可能感兴趣的:(mysql,service,local,监控,hello)