安装环境:已经安装部署完nagios.
安装完check_mysql_health插件
DBD:MYSQL模块(不然无法监控mysql)
安装 DBD:MYSQL:
tar -zxvf DBD-mysql***.tar.gz
cd DBD-mysql***
perl Makefile.PL --mysql_config=/usr/local/mysql/bin/mysql_config
##根据之前编译的mysql参数来编译 dbd
make ;
make install;
部署nagios上的 check_mysql_health
首先创建一个mysql用户。
mysql***/bin//mysqladmin -u root password 123321
手工在nagios/libexec下测试连接
./check_mysql_health --hostname localhost --username root --password 123321 --mode threads-connected
显示
OK - 1 client connection threads | threads_connected=1;10;20##其中10为warning值
20为critical值
可以增加 --warning 700
--critical 1000 参数修改这个值。
设置nagios客户端nrpe.cfg
添加
command[check_mysql]=/usr/local/nagios/libexec/check_mysql_health --hostname=localhost
这一行。
nagios的server端
cd nagios/etc/object
修改command.cfg
添加
define command{
command_name check_mysql_health
command_line $USER1$/check_mysql_health --hostname $ARG1$ --username $ARG2$ --password $ARG3$ --mode $ARG4$
}
修改 nagios/etc/services.cfg
添加
define service {
host_name linux-test
service_description check_mysql_health
check_period 24x7
max_check_attempts 4
normal_check_interval 3
retry_check_interval 2
contact_groups sagroup
notification_interval 10
notification_period 24x7
notification_options w,u,c,r
check_command check_mysql_health!127.0.0.1!root!123321!threads-connected
}
重新启动nagios,nrpe。
在nagios上的结果
这样就部署成功了。