本监控为基于nagios服务器主动监控方法,利用check_mysql_health实现多种监控模式:
       connection-time          (Time to connect to the server)
       uptime                   (Time the server is running)
       threads-connected        (Number of currently open connections)线程数
       threadcache-hitrate      (Hit rate of the thread-cache)慢查询
       slave-lag                (Seconds behind master)
       slave-io-running         (Slave io running: Yes)主从热备
       slave-sql-running        (Slave sql running: Yes)主从热备
       qcache-hitrate           (Query cache hitrate)
       qcache-lowmem-prunes     (Query cache entries pruned because of low memory)
       keycache-hitrate         (MyISAM key cache hitrate)
       bufferpool-hitrate       (InnoDB buffer pool hitrate)
       bufferpool-wait-free     (InnoDB buffer pool waits for clean page available)
       log-waits                (InnoDB log waits because of a too small log buffer)
       tablecache-hitrate       (Table cache hitrate)
       table-lock-contention    (Table lock contention)锁表率
       index-usage              (Usage of indices)
       tmp-disk-tables          (Percent of temp tables created on disk)
       slow-queries             (Slow queries)
       long-running-procs       (long running processes)
       cluster-ndbd-running     (ndnd nodes are up and running)
       sql                      (any sql command returning a single number)

具体步骤如下:
1、安装
#wget http://labs.consol.de/wp-content/uploads/2009/10/check_mysql_health-2.1.tar.gz
#tar -zxvf check_mysql_health-2.1.tar.gz 
#cd check_mysql_health-2.1
#./configure --prefix=/usr/local/nagios --with-nagios-user=nagios --with-nagios-group=nagios --with-perl=/usr/bin/perl
#make && make install
2、命令测试
#cd /usr/local/nagios/libexec
#./check_mysql_health --hostname 192.168.0.1 --port 3306 --username myname --password mypassword --mode threads-connected --warning 700 --critical 1000
当出现Can't locate DBI.pm的错误时:
#yum install perl-DBI perl-DBD-MySQL -y
再次执行,结果如下:
OK - 607 client connection threads | threads_connected=607;700;1000

命令参数:
–hostname <hostname> 
Der Datenbankserver, der überwacht werden soll. Im Falle von "localhost" kann dieser Parameter weggelassen werden. 
–username <username> 
Der Datenbankuser. 
–password <password> 
Dessen Passwort. 
–mode <modus> 
Mit dem mode-Parameter teilt man dem Plugin mit, was es tun soll. 
–name <objektname> 
Hier kann die Prüfung auf ein einziges Objekt begrenzt werden. 
–name2 <string> 
Verwendet man –mode=sql, dann erscheint das SQL-Statement in der Ausgabe und den Performancedaten. 
–warning <range> 
–critical <range> 
–environment <variable>=<wert> 
–method <connectmethode> 
Mit diesem Parameter teilt man dem Plugin mit, wie es sich zur Datenbank verbinden soll. 
–units <%|KB|MB|GB>

3、nagios命令、服务配置
#vi /usr/local/nagios/etc/objects/commands.cfg
...
#'check_mysql_health'
define command{
        command_name    check_mysql_health
        command_line    $USER1$/check_mysql_health --hostname $ARG1$ --port $ARG2$ --username $ARG3$ --password $ARG4$ --mode $ARG5$
--warning $ARG6$ --critical $ARG7$
        }
...

#vi /usr/local/nagios/etc/objects/servers/localhost.cfg
...

define service{
        use                             local-service         ; Name of service template to use
        host_name                       myhostname
        service_description             check_mysql_connections
        check_command                   check_mysql_health!192.168.0.1!3306!myname!mypassword!threads-connected!1000!1500
        }

define service{
        use                             local-service         ; Name of service template to use
        host_name                       myhostname
        service_description             check_mysql_table_lock
        check_command                   check_mysql_health!192.168.0.1!3306!myname!mypassword!table-lock-contention!1!2
        }
...
4、重启nagios服务
#service nagios restart

最新文章

  1. Word2vec 模型载入(tensorflow)
  2. MySQL知识树-支持的数据类型
  3. php下载网络图片到服务器
  4. 将Sql Server迁移到Always on集群 - 账号的同步
  5. 【Spring】Spring系列6之Spring整合Hibernate
  6. thinkphp3.2+PHPExcel导出查询数据到excel表格的实例
  7. web.xml中load-on-startup的作用(转)
  8. IMP不到指定的表空间
  9. Paying for upgrades, by Bob Arnson
  10. 全球性WannaCry蠕虫勒索病毒感染前后应对措施
  11. echarts 折线图点击高亮
  12. .net缓存的应用研究(读篇)
  13. 试一下Markdown
  14. Django使用admin管理后台管理数据库表
  15. [转]2017年最具价值的十大开源项目!GitHub 年度报告~
  16. Android Data Binding Library
  17. rsync 数据备份+cron+mailx案例
  18. Castle ActiveRecord学习(五)使用HQL语句查询
  19. Nodejs学习笔记(十四)—Mongoose介绍和入门
  20. Linux-&gt;解决用userdel删除不掉用户的问题

热门文章

  1. spring boot设定mysql
  2. 【转载】用Pwnage + Redsnow 制作完美越狱固件
  3. php array_diff分析
  4. js中特殊转换字符为html标签
  5. 【WPF】XAML实现按钮背景图片的点击切换
  6. Liunx下NFS服务器的搭建与配置
  7. jffs2系统制作2
  8. javascript商务通
  9. iOS错误整理--自定义按钮,给按钮内部赋值出现的错误
  10. MongoDB Shell 了解使用