Zabbix 监控Mongodb 的常用parameter

因为有些朋友问到,我就把很早以前写的zabbix监控mongodb的parameter与大家分享下。
PS:没有经过很仔细的效验,不过基本所需功能是OK的。

Zabbix的具体用法我就不介绍了,网上很多帖子~

这些parameter中很多取值可以更简单,但是我也不记得当初怎么想的了,反正都能实现。。我也就不改了。
templates如下(下载后将TXT修改为xml即可导入):
Mongodb_eshu

可以如下parameter可以实现的监控包括:

connections
BackgroundFlush
curosor
oplogstoragetime
pagefaults
queue
index
mem
network
Opcounters



UserParameter=mongo.service,ps -ef | grep mongo |grep -v grep |wc -l
UserParameter=mongo.mem_resident,echo "db.serverStatus().mem"| mongo|grep resident | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2
UserParameter=mongo.mem_virtual,echo "db.serverStatus().mem"| mongo|grep virtual | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2
UserParameter=mongo.mem_mapped,echo "db.serverStatus().mem"| mongo|grep '\bmapped\b' | cut -d ":" -f 2 |cut -d "," -f 1| cut -d " " -f 2
UserParameter=mongo.network[*],echo "db.serverStatus().network"|mongo | grep $1 | cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2
UserParameter=mongo.index[*],echo "db.serverStatus().indexCounters"|mongo | grep $1| cut -d ":" -f 2 |cut -d "," -f1 |cut -d " " -f 2
UserParameter=mongo.connection_current,echo "db.serverStatus().connections"| mongo| grep current|cut -d ":" -f 2|cut -d "," -f 1|cut -d " " -f 2
UserParameter=mongo.connection_available,echo "db.serverStatus().connections"| mongo| grep current| cut -d ":" -f 3|cut -d "," -f 1 |cut -d " " -f 2
UserParameter=mongo.opcounters[*],echo "db.serverStatus().opcounters" |mongo | grep $1|cut -d ":" -f 2|cut -d "," -f 1 |cut -d " " -f 2
UserParameter=mongo.rpstatus,echo "rs.status()"| mongo | grep myState| cut -d ":" -f 2| cut -d "," -f 1 |cut -d " " -f 2
UserParameter=mongo.queue_write,echo "db.serverStatus().globalLock.currentQueue.writers"|mongo |sed -n 3p
UserParameter=mongo.queue_reader,echo "db.serverStatus().globalLock.currentQueue.readers"|mongo |sed -n 3p
UserParameter=mongo.backgroundFlush,echo "db.serverStatus().backgroundFlushing.last_ms" |mongo |sed -n 3p
UserParameter=mongo.curosor_Totalopen,echo "db.serverStatus().cursors.totalOpen" |mongo |sed -n 3p
UserParameter=mongo.curospr_timedOu,echo "db.serverStatus().cursors.timedOut" |mongo |sed -n 3p
UserParameter=mongo.pagefaults,echo "db.serverStatus().extra_info.page_faults" |mongo|sed -n 3p
UserParameter=mongo.oplog_storetime,echo "db.printReplicationInfo()"|mongo|sed -n 4p|cut -d "(" -f 2|cut -d "h" -f 1

发表评论