一、mysql服务器端配置
复制代码代码如下:
mysql > create database testdb;
2、创建mysql账号nag-mysql-user:
复制代码代码如下:
mysql > GRANT select ON testdb.* TO identified by “123456”;
3、用插件检查配置:
复制代码代码如下:
[root@localhost libexec]# ./check_mysql -H 192.168.0.233 -u nag-mysql-user -p123456 -d testdb
Uptime: 8553 Threads: 1 Questions: 56 Slow queries: 0 Opens: 13 Flush tables: 1 Open tables: 7 Queries per second avg: 0.007
二、监控机端配置
复制代码代码如下:
define service {
host_name nagios-server service_description check_mysql check_period t247 max_check_attempts 4 check_interval 3 retry_check_interval 2 contact_groups tech-admins notification_interval 10 notification_period t247 notification_options w,u,c,r check_command check_mysql!nag-mysql-user!testdb!123456 } (三)、命令配置文件(command.cfg)追加检查mysql的定义:
复制代码代码如下:
define command {
command_name check_mysql command_line $USER1$/check_mysql –H $HOSTADDRESS$ -u $ARG1$ –d $ARG2$ -p $ARG3$ } (四)、检查并启动nagios
复制代码代码如下:
cd /usr/local/nagios
/usr/local/nagios/bin/nagios –v /usr/local/nagios/etc/nagios.cfg /usr/local/nagios/bin/nagios –d /usr/local/nagios/etc/nagios.cfg
访问http://localhost/nagios,即可监测到mysql的当前状态。 |