今天研究了check_mysql_health 这个nagios脚本,发现可以用来做很多基本的mysql数据库性能监控。
查询是否有长进程
./check_mysql_health -t 30 --hostname 172.26.128.XX --username monitor --password _YXXX --database information_schema --warning 30 --critical 40 --mode long-running-procs
查询是否有慢查询
./check_mysql_health -t 30 --hostname 172.26.128.XX --username monitor --password _YXXX --database information_schema --warning 30 --critical 40 --mode slow-queries
运行SQL,返回必须是一个数值
./check_mysql_health -t 30 --hostname 172.26.128.XX --username monitor --password _YXXX --database information_schema --warning 30 --critical 40 --mode sql -name select%20count%28%2A%29%20from%20v%24session%20where%20status%20%3D%20%27ACTIVE%27
SQL语句必须要用URLENCODE。