注:只能定时任务执行,不可后台执行
#!/bin/bash #by LC USER=root PASSWD=123456 CRONNECTEB=`mysql -u$USER -p$PASSWD -e "show status;"|grep Threads_connected|awk ‘{print $2}‘` LOGS=/home/lichuang/mysql_alert.log MAIL1=lichuang@lichuaung.com MAIL2=jingli@jingli.com MAIL3=zongjian@zongjian.com if [ $CRONNECTEB -ge 300 ] then clear echo -e "\033[31m##################################\033[0m" echo -e "\033[31m\033[0m""\033[1;5;31m MySQL Threads_connected alert \033[0m""\033[31m \033[0m" echo -e "\033[31m##################################\033[0m" echo "`date +%F_%H-%M-%S`MySQL Threads_connected alert"|mail -s MySQL $MAIL1 echo "`date +%F_%H-%M-%S`MySQL Threads_connected alert"|mail -s MySQL $MAIL2 echo "`date +%F_%H-%M-%S`MySQL Threads_connected alert"|mail -s MySQL $MAIL3 echo "===`date +%F_%H-%M-%S`===" >>$LOGS mysql -u$USER -p$PASSWD -e "show status;" >>$LOGS fi
本文出自 “10886311” 博客,请务必保留此出处http://10896311.blog.51cto.com/10886311/1725191
原文:http://10896311.blog.51cto.com/10886311/1725191