成都创新互联网站制作重庆分公司

nagios监控mysql(check_mysql_health插件)

nagios 监控MySQL(check_mysql_health插件)

http://labs.consol.de/wp-content/uploads/2011/08/check_mysql_health-2.1.7.tar.gz
 
# mount /dev/cdrom /media/cdrom
# rpm -ivh /media/cdrom/Server/perl-DBI-1.52-2.el5.i386.rpm
# rpm -ivh /media/cdrom/Server/perl-DBD-MsSQL-3.0007-2.el5.i386.rpm --nodeps
 
# tar zxf check_mysql_health-2.1.7.tar.gz
# cd check_mysql_health-2.1.7
# ./configure
# make && make install
 
# mysql -u root -p123456
> grant all on *.* to ming@'localhost' identified by '123456';
> quit
 
注:让该用户有访问本地mysql的权限即可,可用mysql -u ming -p123456验证,权限不一定给all

 
方式一(localhost监控):
 
# vi /usr/local/nagios/etc/objects/commands.cfg
 
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$
        }
:wq

# vi /usr/local/nagios/etc/objects/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.1.10!3306!ming!123456!threads-connected!700!1000
        }

:wq
 

可先测试一下:
 
#./check_mysql_health --hostname 192.168.1.10 --port 3306 --username ming --password 123456 --mode threads-connected --warning 700 --critical 1000
 
注:在线程数(连接数)超过1000或无法连接时红灯报警,线程数在700以内0以上为绿灯,700到1000之间为黄灯。
 
方式二(nrpe监控):
 
下面要借助于nrpe(nrpe安装步骤略)

# vi /usr/local/nagios/etc/nrpe.cfg
command[check_mysql]=/usr/local/nagios/libexec/check_mysql_health --hostname 192.168.1.10 --port 3306 --username ming --password 123456 --mode threads-connected --warning 700 --critical 1500

:wq
 
重启nrpe:
 
# killall nrpe
# /usr/local/nagios/bin/nrpe  -c /usr/local/nagios/etc/nrpe.cfg -d

# vi /usr/local/nagios/etc/objects/ming.cfg                     (ming.cfg为监控主机的文件,自建的)

define service{
        use                             local-service         ; Name of service template to use
        host_name                       myhostname
        service_description             check_mysql
        check_command                   check_nrpe!check_mysql
        }

:wq
 
 
附:
利用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)

 

汝阳网站制作公司哪家好,找成都创新互联!从网页设计、网站建设、微信开发、APP开发、自适应网站建设等网站项目制作,到程序开发,运营维护。成都创新互联2013年至今到现在10年的时间,我们拥有了丰富的建站经验和运维经验,来保证我们的工作的顺利进行。专注于网站建设就选成都创新互联


本文题目:nagios监控mysql(check_mysql_health插件)
URL链接:http://cxhlcq.com/article/jseshp.html

其他资讯

在线咨询

微信咨询

电话咨询

028-86922220(工作日)

18980820575(7×24)

提交需求

返回顶部