nagios监控mysql

在nagios上部署check_mysql_health 监控mysql

博客分类:

本监控为基于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

时间: 2024-08-25 20:56:40

nagios监控mysql的相关文章

Nagios监控MySQL报错:NRPE: Unable to read output的详细解决过程

前言:nagios界面上,看到监控mysql服务报错如下: Warning:NRPE: Unable to read output 1,去nagios监控服务器上check下 1.1,执行check_nrpe命令远程调用 在监控端nagios服务器上执行check_nrpe检查mysql状态报错如下: [[email protected] ~]# /usr/lib/nagios/plugins/check_nrpe  -H192.xx.180.xx -c check_mysql_status N

Nagios 监控mysql服务器详细实现过程

1.NRPE介绍 NRPE是Nagios的一个功能扩展,它可在远程Linux/Unix主机上执行插件程序.通过在远程服务器上安装NRPE插件及Nagios插件程序来向Nagios监控平台提供该服务器的本地情况,如CPU负载,内存使用,磁盘使用等.这里将Nagios监控端称为Nagios服务器端,而将远程被监控的主机称为Nagios客户端. Nagios监控远程主机的方法有多种,其方式包括SNMP,NRPE,SSH,NCSA等.这里介绍其通过NRPE监控远程Linux主机的方式. NRPE(Nag

zabbix监控mysql-如何使用zabbix自带的模板监控-nagios监控mysql主从

用zabbix监控mysql(源码安装)安装位置在/usr/local/zabbix/ 监控端(server): 在被监控端主机上关联该模板Template App MySQL 中文:组态->主机->名称一栏点击进去->模板,点击链接新模板->添加->Template App MySQL->存档 英文:Configuration->Hosts->Name->Templates,Link new templates->Add->Templat

nagios监控mysql tps---check_mysql_tps.py

#!/usr/bin/python2.7 # -*- coding:utf-8 -*- from __future__ import division from optparse import OptionParser import commands,sys,jastme,re from datetime import datetime """     Nagios plugin to report the mysql TPS     author jastme "

nagios监控mysql主从,并且邮件告警!

客户端操作: yum install -y nagios-plugins nagios-plugins-all nrpe nagios-plugins-nrpe#安装 vim /etc/nagios/nrpe.cfg    #更改客户端的nrpe配置文件 allowed_hosts=192.168.20.168    #IP更改成监控端的地址,如果是多个使用,分割开 #漏了这个后期会出现CHECK_NRPE: Error - Could not complete SSL handshake. 的

Nagios 监控 Mysql

被监控机的Mysql监控创建专用数据库.专用数据库账户mysql -uroot -pcreate database nagios_monitor;grant select on nagios_monitor.* to [email protected]'%' identified by 'nagiosMonitor';flush privileges;exit;测试check_mysql脚本运行是否正常cd /usr/lib64/nagios/plugins./check_mysql -unag

Nagios监控Mysql数据库

实验拓扑:地址分配:Nagios 192.168.1.1Mysql 192.168.1.2Nagios上的操作:1)安装nagios#make install //安装主程序,CGI和HTML文件 make install-init //在/etc/rc.d/init.d安装启动脚本 make install-commandmode //配置目录权限 make install-config //安装示例配置文件 make install-webconf //安装nagios的web接口,会在/e

nagios 监控 mysql 读写比 R/W

#!/usr/bin/python2.7 # -*- coding:utf-8 -*- from optparse import OptionParser import commands,sys,jastme,re from datetime import datetime """     Nagios plugin to report the mysql R/W Ratio     author jastme """ parser = Opti

第25章 MySQL replication(主从)配置及加入nagios监控

环境介绍: master:23.247.76.253 [[email protected]_client1 tool]# mysql -V mysql  Ver 14.14 Distrib 5.6.32, for linux-glibc2.5 (x86_64) using  EditLine wrapper [[email protected]_client1 tool]# cat /etc/redhat-release CentOS release 6.7 (Final) slave:23.2