1,过滤出监控内容,并写进脚本
[root@localhost scripts] mysqladmin extended-status |grep "Bytes_sent"|awk '{print $4}'
3969067
[root@localhost scripts] mysqladmin extended-status |grep "Bytes_received"|awk '{print $4}'
8960924
[root@localhost scripts] vim check_mysql.sh
[root@localhost scripts] cat check_mysql.sh
#!/bin/bash
case $1 in
slave_status)
mysql -ucheck -p123 -e "show slave status \G"|grep "Running"|grep "Yes"|awk '{print $2}'|wc -l
;;
Bytes_sent) #发送流量
mysqladmin extended-status |grep "Bytes_sent"|awk '{print $4}'
;;
Bytes_received) #接受流量
mysqladmin extended-status |grep "Bytes_received"|awk '{print $4}'
;;
esac
2,在服务端设置监控