# 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
# cd check_mysql_health-2.1.7
# ./configure
# make && make install
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/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
可先测试一下:
# vi /usr/local/nagios/etc/nrpe.cfg
:wq
# /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
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)