nagios安装好默认提供了监控mysql的插件,只需要配置即可,下面是配置过程:

1、编辑/usr/local/nagios/etc/commands.cfg,添加监控mysql的字段:

#check mysql
define command{
        command_name   check_mysql
        command_line   $USER1$/check_mysql -H $HOSTADDRESS$ -u nagios -d nagios -p 123456
        }

PS:-u指定用户,-d指定监控的数据库,-p指定密码

2、编辑/usr/local/nagios/etc/objects/cfg/navyserver.cfg ,添加监控mysql项目:

define service{
        use             generic-service
        host_name       navy
        service_description     check-mysql
        check_command           check_mysql
        }

3、重启nagios就OK了

/etc/init.d/nagios restart