nagios监控mysql性能_nagios监控mysql

首先下载目前最高的版本

http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download(会有mysql_check)

http://labs.consol.de/wp-content/uploads/2010/06/check_mysql_health-2.1.2.tar.gz(mysql_check_health check_mysql_query)

http://search.cpan.org/CPAN/authors/id/C/CA/CAPTTOFU/DBD-mysql-4.017.tar.gz  (如果有安装可以省略,安装mysql_check_health需要,如果你是rpm的可以直接yum如果缺少perl-DBD-Pg也可以yum)

1、tar xvzf nagios-plugins-1.4.15.tar.gz

cd  nagios-plugins-1.4.15

./configure –with-nagios-user=nagios –with-nagios-group=nagios –prefix=/usr/local/nagios –with-mysql=/usr/local/mysql

make && make install

chwon -R nagios.nagios /usr/local/nagios

2、vim commands.cfg

加入:

define command {

command_name check_mysql

command_line $USER1$/check_mysql -H $HOSTADDRESS$  -P $ARG1$ -u $ARG2$  -p $ARG3$

}

vim localhost.cfg

加入

define service{

use                             local-service         ; Name of service template to use

host_name                       test-linux

service_description             MYSQL

check_command                   check_mysql!3306!root!password

notifications_enabled           0

}

检查语法后重启。

3、tar xvzf  DBD-mysql-4.017.tar.gz

perl Makefile.PL –libs=”-L/usr/local/mysql/lib/mysql -lmysqlclient -lz” –cflags=-I/usr/local/mysql/include/mysql –testhost=127.0.0.1

例子:

# perl Makefile.PL –testdb=数据库 –testuser=用户 –testpassword=密码

make

make test

make install

4、tar xvzf check_mysql_health-2.1.2.tar.gz

cd  check_mysql_health-2.1.2

./configure –prefix=/usr/local/nagios –with-nagios-user=nagios –with-nagios-group=nagios –with-perl –with-statefiles-dir=/tmp

make && make install

cd /usr/local/nagios/libexec/

./check_mysql_health: yes: bad interpreter: No such file or directory

解决方法因为check_mysql_health是用perl写的,将check_mysql_health的第一行由原来的#! yes -w修改为#!/usr/bin/perl,这样就OK

./check_mysql_health –hostname 192.168.169.123 –port 3306 — username root –password linuxtone –mode threadcache-hitrate

返回:OK – thread cache hitrate 91.30% | thread_cache_hitrate=91.30%;90:;80: thread_cache_hitrate_now=91.30%

connections_per_sec=0.00 就成功了,我有看到很多文章给这个用户开个权限账户和root一样的权限,不明白是为什么,就是迷惑一下人?我的root也可以正常使用,也许是为了安全。

vi commands.cfg

输入:

#check_health_mysql

define command{

command_name check_mysql_health

command_line $USER1$/check_mysql_health –hostname $ARG1$ –port $ARG2$ –username $ARG3$ –password $ARG4$ –mode $ARG5$

}

vim localhost.cfg

加入

define service{

host_name dbss-slave

service_description threads-connected

check_command check_mysql_health!192.168.169.123!3306!root!linuxtone!threads-connected

}

检测配置文件后重启。

查询线程缓存命中率状态:threadcache-hitrate

查询命中率:qcache-hitrate

查看锁表率:table-lock-contention

查看数据库服务器当前连接数量:threads-connected

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值