使用Zabbix监控Mysql
使用Zabbix监控Mongodb
使用Zabbix监控Postfix
操作系统:Centos 5.5 x86_64
Zabbix版本:1.8.11
Mongodb版本:1.8.1
一、在Zabbix Server上安装php MongoDB驱动
php安装在/usr/loca/php目录
/usr/local/php/bin/pecl install mongo
二、修改php.ini文件,加载mongo.so[Zabbix Server上操作]
vi /usr/local/php/etc/php.ini
在extension_dir = “/usr/local/php/lib/php/extensions/no-debug-non-zts-20060613/”下面添加
extension=mongo.so
三、下载脚本[Zabbix Server上操作]
下载页面:http://mikoomi.googlecode.com/svn/plugins
mkdir /etc/zabbix/externalscripts
拷贝mikoomi-mongodb-plugin.php、mikoomi-mongodb-plugin.sh两个文件到/etc/zabbix/externalscripts目录。
修改mikoomi-mongodb-plugin.sh文件:
#!/bin/bash
#修改PATH环境变量,指定zabbix执行程序路径,特别是zabbix_sender
PATH=$PATH:/etc/zabbix/externalscripts:/usr/local/zabbix/bin:/bin:/usr/sbin:/usr/bin:/usr/local/bin:/usr/local/sbin
export PATH
shift
BASE_DIR=”`dirname $0`”
#修改php执行文件路径,这里php安装在/usr/local/php目录
/usr/local/php/bin/php $BASE_DIR/mikoomi-mongodb-plugin.php $*
echo 0
四、导入模板、建立主机
1.将MongoDB_Plugin_template_export.xml导入到zabbix中;
2.建立主机(用来监控的mongodb服务器),并建立三个宏:
{$HOSTNAME} :Mongodb服务器的主机名或IP地址;
{$PORT} :Mongodb服务器的端口;
{$SERVER} :在Zabbix中定义的Mongodb服务器的主机名。
添加监控项:
在创建主机时,在Linked templates处添加导入的Mongodb模板;
如想修改里面的值,需要在保存后,再编辑改主机,取消连接该模板(在Linked templates下面点击Unlink);
然后就可以修改监控项了,默认1分钟收集一次数据。
修改”Miscellaneous: Data Collector”监控项的key值,因默认提供的值有错误:mikoomi-mongodb-plugin.sh[-h {$SERVER} -p {$PORT} -z {$HOSTNAME}]
使用同样的方法添加Host和监控项可以监控多台mongodb服务器;
五、调试[在Zabbix Server服务器上操作]
cd /etc/zabbix/externalscripts/
./mikoomi-mongodb-plugin.sh -D -h 192.168.100.166 -p 27017 -z 192.168.100.166
less # less mikoomi-mongodb-plugin.php_192.168.100.166.log
mikoomi-mongodb-plugin.php:Successfully connected to mongoDB using connect string 58.83.219.236:27017
zabbix_sender [28458]: Warning: [line 41] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 42] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 43] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 44] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 45] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 46] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 47] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 48] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 66] ‘Key value’ required
zabbix_sender [28458]: Warning: [line 68] ‘Key value’ required
zabbix_sender [28459]: DEBUG: answer [{
“response”:”success”,
“info”:”Processed 58 Failed 5 Total 63 Seconds spent 0.000953″}]
Info from server: “Processed 58 Failed 5 Total 63 Seconds spent 0.000953”
sent: 63; skipped: 10; total: 73
如正常将会有数据。
参考:
http://code.google.com/p/mikoomi/wiki/03
http://blog.serverdensity.com/2010/12/29/mongodb-monitoring-db-serverstatus/
转载请注明:爱开源 » 使用Zabbix监控Mongodb