mysql 监控读写脚本_mysql 监控脚本一

mysql  监控

# monitor master-slave  监控主从同步

####  192.168.57.108/192.168.101.93

hostip="192.168.11.93"

user="root"

pass="Uasdf*dn"

STATUS=$(mysql -h$hostip -u$user -p$pass  mysql  -e "show slave status\G" | grep -i  "running" )

IO_env=`echo $STATUS  | awk  ' {print $2}'`

SQL_env=`echo $STATUS | awk  '{print $4}'`

if [ "$IO_env"  != "Yes"  -o   "$SQL_env" != "Yes" ]

then

echo " $hostip :  Slave is not running!"  | mail -s "warn! $hostip MySQL Slave is not running"  dwchaoyue@163.com

fi

# monitor  mysql server  监控 mysql服务

MYSQLPORT=$(netstat -na|grep "LISTEN"|grep "3306"|awk -F[:" "]+ '{print $5}')

if [ "$MYSQLPORT"  !=  "3306" ]

then

service  mysql start

echo "server:$hostip  mysql is down" | mail -s "warn!server: $hostip  mysql is down" dwchaoyue@163.com

fi

# monitor  diskspace  监控磁盘空间大小

diskspace=$(df  -lh | grep  / | sed -n '2'p |awk '{print $4}' |sed 's/%//g')

if [ $diskspace -gt 90 ]

then

echo "server:$hostip  disk space  is not  enough" | mail -s "warn! disk space  is not  enough  " dwchaoyue@163.com

fi

yum  -y  install   sendmail

配置mail

vi    /etc/mail.rc

set from="dwchaoyue@163.com"

set smtp="smtp.163.com"

set smtp-auth-user="dwchaoyue"

set smtp-auth-password="DW_chaoyue"

set smtp-auth=login

~

问题1:没有收到邮件

解决方案:

查看系统是否开启sendmail 服务。如果没有开启,开启即可。

[root@localhost ~]# service sendmail status

sendmail (pid  7177) is running...

问题3:

mail

-bash: mail: command not found

解决方法:

yum -y install mailx jwhois

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值