安装check_mysql_health插件
wget http://labs.consol.de/download/shinken-nagios-plugins/check_mysql_health-2.1.8.2.tar.gz
tar zxvf check_mysql_health-2.1.8.2.tar.gz
cd check_mysql_health-2.1.8.2
./configure
make
make install
check_mysql_health插件基本用法
/usr/local/nagios/libexec/check_mysql_health --hostname 192.168.163.130 --port 3306 --username nagios --password nagios --mode slow-queries [root@link-1 objects]# /usr/local/nagios/libexec/check_mysql_health --hostname 172.16.1.1 --port 3306 --username nagios --password nagios --mode slow-queries
CRITICAL - cannot connect to information_schema. install_driver(mysql) failed: Can't locate DBD/mysql.pm in @INC (@INC contains: /usr/local/nagios/libexec /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at (eval 18) line 3.
Perhaps the DBD::mysql perl module hasn't been fully installed,
or perhaps the capitalisation of 'mysql' isn't right.
Available drivers: DBM, ExampleP, File, Gofer, Proxy, SQLite, Sponge.
at /usr/local/nagios/libexec/check_mysql_health line 1963
[root@link-1 ~]# yum -y install perl-DBD-MySQL.x86_64
[root@link-166 objects]# /usr/local/nagios/libexec/check_mysql_health --hostname 172.16.1.1 --port 3306 --username nagios --password nagios --mode slow-queries
OK - 5 slow queries in 1464849671 seconds (0.00/sec) | slow_queries_rate=0.00%;0.1;1
各参数的含义,尤其–mode参数有很多监控的指标可以参考,具体查看官网可以知。
--hostname 定义被监控主机的IP或机器名
--port 定义被监控主机上MySQL的运行端口
--username 定义被监控主机上MySQL的用户名
--password 定义被监控主机上MySQL的密码
--mode 定义被监控主机上MySQL的监控指标
和官方插件类似,首先要建立一个可以用于远程登陆的mysql账号
GRANT ALL PRIVILEGES ON *.* TO 'nagios'@'192.168.163.130' IDENTIFIED BY 'nagios'; 在监控主机上添加可以让命令以便让监控主机识别这个插件。
vi /usr/local/nagios/etc/objects/commands.cfg
define command{