nagios使用check_mysql监控mysql

  1. nagios监控mysql服务器: 

  2. 在被监控机上

  3. 1、建立专用数据库: 

  4. [root@svr3 ~]# /usr/local/webserver/mysql/bin/mysql -u root -p 

  5. Enter password:  

  6. Welcome to the MySQL monitor.  Commands end with ; or \g. 

  7. Your MySQL connection id is 51910 

  8. Server version: 5.5.3-m3-log Source distribution 

  9. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. 

  10. mysql> create database nagios; 

  11. Query OK, 1 row affected (0.00 sec) 

  12. mysql> grant select on nagios.* to nagios@'%' identified by '123qweasd'; 

  13. Query OK, 0 rows affected (0.00 sec) 

  14. mysql> flush privileges; 

  15. Query OK, 0 rows affected (0.00 sec) 

  16. mysql> select User,Password,Host from user; 

  17. +----------------+-------------------------------------------+------------------+ 

  18. | User           | Password                                  | Host             | 

  19. +----------------+-------------------------------------------+------------------+ 

  20. | root           | *84BB5DF4823DA319BBF86C99624479A198E6EEE9 | localhost        | 

  21. | nagios         | *A1F1CB851D62F002C09A0C9C4A76262473432F55 | %                | 

  22. +----------------+-------------------------------------------+------------------+ 

  23. 14 rows in set (0.00 sec) 

  24. 12 rows in set (0.00 sec) 

  25. [root@svr3 ~]# /usr/local/nagios/libexec/check_mysql -H 10.1.1.30 -u nagios -d nagios -p 123qweasd 

  26. Uptime: 970046  Threads: 1  Questions: 684583  Slow queries: 3  Opens: 672  Flush tables: 1  Open tables:  

  27. 369  Queries per second avg: 0.705 

  28. [root@svr4 nrpe_install]# /usr/local/nagios/libexec/check_mysql -H 10.1.1.30 -u nagios -d nagios -p 123qweasd 

  29. Uptime: 970348  Threads: 1  Questions: 684584  Slow queries: 3  Opens: 672  Flush tables: 1  Open tables: 369  Queries per second avg: 0.705 

  30. 在nagios服务器上

  31. 果断开始设置: 

  32. #定义用户 

  33. #定义组,及隶属用户 

  34. #用户增加 

  35. 在command.cfg里增加插件命令: 

  36. #check mysql 

  37. define command{ 

  38. command_name check_mysql 

  39. command_line $USER1$/check_mysql -H $HOSTADDRESS$ -u nagios -d nagios -p 123qweasd 

  40. #定义服务: 

  41. define service { 

  42.         host_name svr3.labexam.com 

  43.         service_description MysqlDB 

  44.         check_period 24x7 

  45.         max_check_attempts 2 

  46.         normal_check_interval 1 

  47.         retry_check_interval 1 

  48.         contact_groups sagroup,dbagroup 

  49.         notification_interval 5 

  50.         notification_period 24x7 

  51.         notification_options w,u,c,r 

  52.         check_command check_mysql 

wKioL1MerFGgfnFYAAbFhawPPLw424.jpg

你可能感兴趣的:(监控)