全部博文(150)
分类: 系统运维
2013-08-17 15:51:50
在服务器上可以通过shell命令echo "db.serverStatus()" | mongo admin来查看MongoDB的状态。
[root@mongo163 ~]# echo "db.serverStatus()" | mongo admin
MongoDB shell version: 1.8.1
connecting to: admin
->db.serverStatus()
{
"host" : "mongo163",
"version" : "1.8.1",
"process" : "mongod",
"uptime" : 451749,
"uptimeEstimate" : 281868,
"localTime" : ISODate("2011-05-23T07:42:01.990Z"),
"globalLock" : {
"totalTime" : 451749911134,
"lockTime" : 50304542058,
"ratio" : 0.11135484660467028,
"currentQueue" : {
"total" : 0,
"readers" : 0,
"writers" : 0
},
"activeClients" : {
"total" : 1,
"readers" : 1,
"writers" : 0
}
},
"mem" : {
"bits" : 64,
"resident" : 21790,
"virtual" : 63679,
"supported" : true,
"mapped" : 58328
},
"connections" : {
"current" : 3,
"available" : 19997
},
"extra_info" : {
"note" : "fields vary by platform",
"heap_usage_bytes" : -1519420976,
"page_faults" : 179599
},
"indexCounters" : {
"btree" : {
"accesses" : 2324660,
"hits" : 2324619,
"misses" : 41,
"resets" : 0,
"missRatio" : 0.00001763698777455628
}
},
"backgroundFlushing" : {
"flushes" : 7528,
"total_ms" : 64933966,
"average_ms" : 8625.659670563231,
"last_ms" : 10583,
"last_finished" : ISODate("2011-05-23T07:41:10.754Z")
},
"cursors" : {
"totalOpen" : 1,
"clientCursors_size" : 1,
"timedOut" : 65
},
"network" : {
"bytesIn" : 31194795281,
"bytesOut" : 24269782063,
"numRequests" : 254375763
},
"repl" : {
"ismaster" : true
},
"opcounters" : {
"insert" : 38301524,
"query" : 1770,
"update" : 35909520,
"delete" : 10486310,
"getmore" : 42387,
"command" : 169619319
},
"asserts" : {
"regular" : 0,
"warning" : 0,
"msg" : 0,
"user" : 6,
"rollovers" : 0
},
"writeBacksQueued" : false,
"note" : "run against admin for more info",
"ok" : 1
因此可以考虑使用zabbix的UserParameter自定义监控,对MongoDB进行监控
添加MongoDB监控1、zabbix客户端配置文件zabbix_agentd.conf文件,添加如下内容:
UserParameter=MongoDB.Status[*],/bin/echo "db.serverStatus().$1" | /usr/local/sbin/mongo admin | grep "$2"|awk -F: '{print $$2}'|awk -F, '{print $$1}'
2、重新启动zabbix客户端
/etc/init.d/zabbix_agentd restart
添加编写MongoDB监控模板1、创建模板:
系统配置->模板,点击右上角的“创建模板”,添加“MongoDB Moniting”模板
2、添加监控项:
系统配置->“MongoDB Moniting”模板->监控项,点击右上角的“Create Item”,创建监控项:
3、添加图形显示:
系统配置->“MongoDB Moniting”模板->图形显示,点击右上角的“创建图形”,创建相应图形:
1、在装有MongoDB的服务器上应用该模板:
系统配置->主机,选择一台装有MongoDB的服务器,在右边的“Linked templates”,添加MongoDB监控模板,然后保存
2、MongoDB监控最新数据:
1、系统配置->配置图表,点击右上角的“create screen”,创建图表。
2、图表中添加如下内容:
MongoDB服务器的
(1) CPU使用情况
(2) Load Average服务器负载情况
(3) Memory服务器内存使用情况
(4) MongoDB Background Fluhes
(5) MongoDB Commands
(6) MongoDB Current Connetctions
(7) MongoDB Index Ops
(8) MongoDB Memory
(9) MongoDB Networks