#被监控端


 
   
  1. mysql> create database test;  
  2. mysql> grant select on test.* to 'nagiosmysql'@'%';  
  3. mysql> flush privileges; 

#监控端


 
   
  1. [root@cacti libexec]#/usr/local/nagios/libexec/check_mysql -H192.168.0.13 -unagiosmysql -d test 
  2. Uptime: 591432  Threads: 3  Questions: 2957867  Slow queries: 12  Opens: 3063  Flush tables: 1  Open tables: 64  Queries per second avg: 5.1 
  3. ------------------------------------------------------------------------------- 
  4.  
  5. [root@cacti objects]#  vi commands.cfg  
  6.  
  7. # check mysql 
  8. define command{ 
  9. command_name check_mysql 
  10. command_line $USER1$/check_mysql -H $HOSTADDRESS$ -unagiosmysql -d test 
  11.  
  12. ------------------------------------------------------------------------------- 
  13.  
  14. vi services.cfg 
  15. define service{ 
  16.         host_name               155 
  17.         service_description     mysql_status 
  18.         check_command           check_mysql 
  19.         max_check_attempts      2 
  20.         normal_check_interval   3 
  21.         retry_check_interval    2 
  22.         check_period            24x7 
  23.         notification_interval   10 
  24.         notification_period     24x7 
  25.         notification_options    w,u,c,r 
  26.         contact_groups          admins 
  27.         }  
  28.  
  29. [root@cacti objects]# checknagios    
  30. [root@cacti objects]# service nagios restart