nagios check_mysql uptime_使用check_mysql_health在Nagios上监控mysql数据库

姚烨
2023-12-01

# tar zxvf check_mysql_health-2.1.1.tar.gz

# ./configure \

–prefix=/usr/local/nagios/ \

–with-nagios-user=nagios \

–with-nagios-group=nagios \

–with-perl=/usr/bin/perl \

–with-statefiles-dir=/usr/local/nagios/var/tmp \

–with-perl=/usr/bin/perl

# make

# make install

— check_mysql_health监控配置

定义commands.cfg

#'check_mysql_health' command

definition

define command{

command_name

check_mysql_health

command_line

$USER1$/check_mysql_health --hostname $ARG1$ --username $ARG2$

--password $ARG3$ --mode $ARG4$ --warning $AR

G5$ --critical $ARG6$

}

–查看当前连接到数据库的连接数:

[root@localhost mysql]#

/usr/local/nagios/libexec/check_mysql_health --hostname IP --port

3306 --username "USER" --password

"PASSWORD" --mode

threads-connected

OK - 10 client connection threads |

threads_connected=10;10;20

如果此处报错:

CRITICAL - cannot connect to

information_schema. Can't locate DBI.pm in @INC (@INC contains:

/usr/local/nagios/libexec

/usr/lib/perl5/site_perl/5.8.8/i386-linux-thread-multi

/usr/lib/perl5/site_perl/5.8.8 /usr/lib/perl5/site_perl

/usr/lib/perl5/vendor_perl/5.8.8/i386-linux-thread-multi

/usr/lib/perl5/vendor_perl/5.8.8 /usr/lib/perl5/vendor_perl

/usr/lib/perl5/5.8.8/i386-linux-thread-multi /usr/lib/perl5/5.8.8

.)

或者当出现Can't locate DBI.pm的错误时

安装dbd-mysql:

yum install perl-DBD-MySQL perl-DBI

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)

 类似资料: