Nagios监控数据库的方法

Nagios监控数据库的方法:

check_mysql_health监控数据库

1、check_mysql_health安装

在监控服务器上安装

 
  1. #cd/usr/local/src/tarbag
  2. #wgethttp://labs.consol.de/wp-content/uploads/2010/03/check_mysql_health-2.1.1.tar.gz
  3. #tarzxvfcheck_mysql_health-2.1.1.tar.gz-C../software/
  4. #./configure\
  5. prefix=/usr/local/nagios/\
  6. with-nagios-user=nagios\
  7. with-nagios-group=nagios\
  8. with-perl=/usr/bin/perl\
  9. with-statefiles-dir=/usr/local/nagios/var/tmp\
  10. –with-perlperl\程序运行路径
  11. –with-statefiles-dir状态信息文件路径
  12. #make
  13. #makeinstall

2、check_mysql_health选项

 
  1. Options:
  2. –hostname
  3. thedatabaseserver’shostname
  4. –port
  5. thedatabase’sport.(default:3306)
  6. –socket
  7. thedatabase’sunixsocket.
  8. –username
  9. themysqldbuser
  10. –password
  11. themysqldbuser’spassword
  12. –database
  13. thedatabase’sname.(default:information_schema)
  14. –warning
  15. thewarningrange
  16. –critical
  17. thecriticalrange
  18. –mode
  19. themodeoftheplugin.selectoneofthefollowingkeywords:
  20. connection-time连接到服务器上的时间
  21. uptime服务器运行的时间
  22. threads-connected当前连接到数据库的连接数
  23. threadcache-hitrate线程缓存命中率
  24. slave-lagslave落后master多少时间
  25. slave-io-runningslave复制是否正常
  26. slave-sql-runningslave复制是否正常
  27. qcache-hitrate查询缓存命中率
  28. qcache-lowmem-prunes(Querycacheentriesprunedbecauseoflowmemory)
  29. keycache-hitrate(MyISAMkeycachehitrate)
  30. bufferpool-hitrate(InnoDBbufferpoolhitrate)
  31. bufferpool-wait-free(InnoDBbufferpoolwaitsforcleanpageavailable)
  32. log-waits(InnoDBlogwaitsbecauseofatoosmalllogbuffer)
  33. tablecache-hitrate表缓存命中率
  34. table-lock-contention表锁率
  35. index-usage索引使用情况
  36. tmp-disk-tables(Percentoftemptablescreatedondisk)
  37. slow-queries慢查询
  38. long-running-procs长时间运行的进程
  39. cluster-ndbd-runningndb节点运行状况
  40. sql返回一个数字的任何SQL语句

3、check_mysql_health监控配置

监控服务器:10.59.97.42

MySQL数据授权:

在要监控的MySQL数据库服务器上

 
  1. mysql>grantusageon*.*[email protected]“honyho@8123“;
  2. mysql>flushprivileges;

在监控服务器上

1》查看当前连接到数据库的连接数

 
  1. #./check_mysql_health–hostname10.59.97.57–usernamehonyho–passwordhonyho@8123–modethreads-connected
  2. OK–3clientconnectionthreads|threads_connected=3;10;20
  3. threads_connected=3;10;20

3表示连接数

10 表示warning阀值(默认)

20 表示critical阀值(默认)

Nagios相关配置

1》配置commands.cfg文件

  
  1. definecommand{
  2. command_namecheck_mysql_health
  3. command_line$USER1$/check_mysql_health–hostname$ARG1$–username$ARG2$–password$ARG3$–warning$ARG4$–critical$ARG5$–mode$ARG6$
  4. }

2》配置121_207_231_17.cfg文件

  
  1. defineservice{
  2. uselocal-service
  3. host_name121.207.231.17
  4. service_descriptionthreads-connected
  5. check_commandcheck_mysql_health!10.59.97.57!honyho!honyho@8123!1000!1500!threads-connected
  6. }

你可能感兴趣的:(nagios)