nagios 监控mysql(check_mysql_health插件)
2012-04-23 14:44
375 查看
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)
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)
相关文章推荐
- nagios 监控slave(check_mysql_health插件)
- nagios监控插件 nagios_oracle_health+check_linux_stats.pl
- 使用nagios插件 check_mysql_health 过程中遇到的error
- 利用nagios+check_mysql_health监控mysql
- 在nagios上部署check_mysql_health 监控mysql (二)
- nagios check_mysql_health 监控window下mysql详细信息
- nagios中自己写的监控mysql主从复制的插件
- nagios使用check_mysql监控mysql
- Nagios监控内存插件check_mem
- nagios中自己写的监控mysql主从复制的插件 推荐
- 在nagios上部署check_mysql_health
- nagios监控check_mysql报错:libmysqlclient.so.18: cannot open shared object file
- 使用Linux C开发Nagios监控插件系列——监控MySQL状态的插件开发
- MongoDB nagios check_mongodb插件监控
- 配置nagios监控oracle,check_oracle_health
- nagios添加check_mysql_health
- Nagios通过check_megaraid_sas(基于MecaCli工具的插件)对RAID卡和硬盘进行监控的方法
- nagios监控mysql(check_mysql)及内存使用率(check_mem) 推荐
- 自己编写Nagios 监控Mysql插件
- 使用Linux C开发Nagios监控插件系列——监控MySQL状态的插件开发