nagios监控mysql
首先下載目前最高的版本
http://sourceforge.net/projects/nagiosplug/files/nagiosplug/1.4.15/nagios-plugins-1.4.15.tar.gz/download(會(huì)有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
??????? }
檢查語(yǔ)法后重啟。
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=數(shù)據(jù)庫(kù) –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
解決方法因?yàn)閏heck_mysql_health是用perl寫(xiě)的,將check_mysql_health的第一行由原來(lái)的#! 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 就成功了,我有看到很多文章給這個(gè)用戶開(kāi)個(gè)權(quán)限賬戶和root一樣的權(quán)限,不明白是為什么,就是迷惑一下人?我的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
}
檢測(cè)配置文件后重啟。
查詢線程緩存命中率狀態(tài):threadcache-hitrate
查詢命中率:qcache-hitrate
查看鎖表率:table-lock-contention
查看數(shù)據(jù)庫(kù)服務(wù)器當(dāng)前連接數(shù)量:threads-connected
轉(zhuǎn)載于:https://blog.51cto.com/lxsym/484763
總結(jié)
以上是生活随笔為你收集整理的nagios监控mysql的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: LSI系新军搅局,PCIe固态盘混战?
- 下一篇: 骁龙8+/金属中框同价位罕见!拯救者Y7