nagios 检查 mysql服务

 http://blog.c1gstudio.com/archives/602

nagios_plugin安装时正确关联mysql后会在libexec下产生check_mysql文件

  1. /usr/local/nagios/libexec/check_mysql -h
  2.  
  3. check_mysql v2034 (nagios-plugins 1.4.13)
  4. Copyright (c) 1999-2007 Nagios Plugin Development Team
  5.         <nagiosplug-devel@lists.sourceforge.net>
  6.  
  7. This program tests connections to a mysql server
  8.  
  9.  
  10. Usage: check_mysql [-d database] [-H host] [-P port] [-s socket]
  11.        [-u user] [-p password] [-S]
  12.  
  13. Options:
  14.  -h, --help
  15.     Print detailed help screen
  16.  -V, --version
  17.     Print version information
  18.  -H, --hostname=ADDRESS
  19.     Host name, IP Address, or unix socket (must be an absolute path)
  20.  -P, --port=INTEGER
  21.     Port number (default: 3306)
  22.  -s, --socket=STRING
  23.     Use the specified socket (has no effect if -H is used)
  24.  -d, --database=STRING
  25.     Check database with indicated name
  26.  -u, --username=STRING
  27.     Connect using the indicated username
  28.  -p, --password=STRING
  29.     Use the indicated password to authenticate the connection
  30.     ==> IMPORTANT: THIS FORM OF AUTHENTICATION IS NOT SECURE!!! <==
  31.     Your clear-text password could be visible as a process table entry
  32.  -S, --check-slave
  33.     Check if the slave thread is running properly.
  34.  -w, --warning
  35.     Exit with WARNING status if slave server is more than INTEGER seconds
  36.     behind master
  37.  -c, --critical
  38.     Exit with CRITICAL status if slave server is more then INTEGER seconds
  39.     behind master
  40.  
  41.  There are no required arguments. By default, the local database is checked
  42.  using the default unix socket. You can force TCP on localhost by using an
  43.  IP address or FQDN ('localhost' will use the socket as well).
  44.  
  45. Send email to nagios-users@lists.sourceforge.net if you have questions
  46. regarding use of this software. To submit patches or suggest improvements,
  47. send email to nagiosplug-devel@lists.sourceforge.net

创建nagdb空数据库和naguser用户

  1. create database nagemptydb;
  2. GRANT select ON nagemptydb.* TO naguser@localhost identified by 'password123';
  3. FLUSH PRIVILEGES ;

测试check_mysql

  1. sudo -u nagios /usr/local/nagios/libexec/check_mysql -H localhost -u naguser -d nagemptydb -p password123
  1. Uptime: 45850  Threads: 1  Questions: 493233  Slow queries: 0  Opens: 159  Flush tables: 1  Open tables: 153  Queries per second avg: 10.757

修改被子监控机nrpe.cfg增加监控命令
vi /usr/local/nagios/etc/nrpe.cfg

  1. command[check_mysql_status]=/usr/local/nagios/libexec/check_mysql -H localhost -u naguser -d nagemptydb -p 'password123'

重启被监控机nrpe

  1. ps aux |grep nrpe
  2. kill $pid
  3. /usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

监控机polo.cfg增加
vi /etc/local/nagios/etc/objects/polo.cfg

  1. define service{
  2.         use                             local-service         ; Name of service template to use
  3.         host_name                       polo
  4.         service_description             mysql_status
  5. check_command check_nrpe!check_mysql_status
  6. notifications_enabled 0
  7.         }

重载入监控机nagios

  1. service nagios reload

访问http://localhost/nagios的service detail

  1. mysql_status
  2. Notifications for this service have been disabled
  3. PENDING N/A 0d 0h 0m 35s+ 1/4 Service check scheduled for Tue May 19 15:01:30 CST 2009

等一会

  1. mysql_status
  2. Notifications for this service have been disabled
  3. OK 05-19-2009 15:01:30 0d 0h 1m 5s 1/4 Uptime: 46758 Threads: 1 Questions: 513579 Slow queries: 0 Opens: 160 Flush tables: 1 Open tables: 154 Queries per second avg: 10.983
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值