nagios 检查 mysql服务
http://blog.c1gstudio.com/archives/602nagios_plugin安装时正确关联mysql后会在libexec下产生check_mysql文件
[*]/usr/local/nagios/libexec/check_mysql -h
[*]
[*]check_mysql v2034 (nagios-plugins 1.4.13)
[*]Copyright (c) 1999-2007 Nagios Plugin Development Team
[*] <nagiosplug-devel@lists.sourceforge.net>
[*]
[*]This program tests connections to a mysql server
[*]
[*]
[*]Usage: check_mysql [-d database] [-H host] [-P port] [-s socket]
[*] [-u user] [-p password] [-S]
[*]
[*]Options:
[*] -h, --help
[*] Print detailed help screen
[*] -V, --version
[*] Print version information
[*] -H, --hostname=ADDRESS
[*] Host name, IP Address, or unix socket (must be an absolute path)
[*] -P, --port=INTEGER
[*] Port number (default: 3306)
[*] -s, --socket=STRING
[*] Use the specified socket (has no effect if -H is used)
[*] -d, --database=STRING
[*] Check database with indicated name
[*] -u, --username=STRING
[*] Connect using the indicated username
[*] -p, --password=STRING
[*] Use the indicated password to authenticate the connection
[*] ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==
[*] Your clear-text password could be visible as a process table entry
[*] -S, --check-slave
[*] Check if the slave thread is running properly.
[*] -w, --warning
[*] Exit with WARNING status if slave server is more than INTEGER seconds
[*] behind master
[*] -c, --critical
[*] Exit with CRITICAL status if slave server is more then INTEGER seconds
[*] behind master
[*]
[*] There are no required arguments. By default, the local database is checked
[*] using the default unix socket. You can force TCP on localhost by using an
[*] IP address or FQDN ('localhost' will use the socket as well).
[*]
[*]Send email to nagios-users@lists.sourceforge.net if you have questions
[*]regarding use of this software. To submit patches or suggest improvements,
[*]send email to nagiosplug-devel@lists.sourceforge.net
创建nagdb空数据库和naguser用户
[*]create database nagemptydb;
[*]GRANT select ON nagemptydb.* TO naguser@localhost identified by 'password123';
[*]FLUSH PRIVILEGES ;
测试check_mysql
[*]sudo -u nagios /usr/local/nagios/libexec/check_mysql -H localhost -u naguser -d nagemptydb -p password123
[*]Uptime:45850Threads: 1Questions: 493233Slow queries: 0Opens: 159 Flush tables: 1Open tables: 153Queries per second avg: 10.757
修改被子监控机nrpe.cfg增加监控命令
vi /usr/local/nagios/etc/nrpe.cfg
[*]command=/usr/local/nagios/libexec/check_mysql -H localhost -u naguser -d nagemptydb -p 'password123'
重启被监控机nrpe
[*]ps aux |grep nrpe
[*]kill $pid
[*]/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d
监控机polo.cfg增加
vi /etc/local/nagios/etc/objects/polo.cfg
[*]define service{
[*] use local-service ; Name of service template to use
[*] host_name polo
[*] service_description mysql_status
[*]check_commandcheck_nrpe!check_mysql_status
[*]notifications_enabled0
[*] }
重载入监控机nagios
[*]service nagios reload
访问http://localhost/nagios的service detail
[*]mysql_status
[*]
[*]Notifications for this service have been disabled
[*]PENDING N/A 0d 0h 0m 35s+ 1/4 Service check scheduled for Tue May 19 15:01:30 CST 2009
等一会
[*]mysql_status
[*]
[*]Notifications for this service have been disabled
[*] OK 05-19-2009 15:01:30 0d 0h 1m 5s 1/4 Uptime: 46758 Threads: 1Questions: 513579 Slow queries: 0 Opens: 160 Flush tables: 1 Opentables: 154 Queries per second avg: 10.983
页:
[1]