Chinaunix首页 | 论坛 | 博客
  • 博客访问: 145301
  • 博文数量: 29
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 368
  • 用 户 组: 普通用户
  • 注册时间: 2013-09-17 18:06
个人简介

一个直来直去的人,被生活折磨的弯弯曲曲。

文章分类

全部博文(29)

文章存档

2019年(1)

2017年(1)

2014年(13)

2013年(14)

我的朋友

分类: Mysql/postgreSQL

2013-09-25 17:33:14

首先下载目前最高的版本
(会有mysql_check)
(mysql_check_health check_mysql_query)
  (如果有安装可以省略,安装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

阅读(1367) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~