標籤:command 設定檔 version 伺服器 insert
一.原理
Zabbix監控mongodb的原理是通過echo "db.serverStatus()" | mongo admin 來查看mongodb的狀態
二.伺服器配置
1)添加mongo的全域變數
# vim /etc/profile.d/mongo.sh
export PATH=/usr/local/mongodb/bin:$PATH
# . /etc/profile.d/mongo.sh
2)執行之後可以看到mongodb一些狀態資訊
# echo "db.serverStatus().opcounters" | mongo admin
MongoDB shell version: 3.2.7
connecting to: admin
{
"insert" : 0,
"query" : 0,
"update" : 0,
"delete" : 0,
"getmore" : 0,
"command" : 594338669
}
Bye
3)在zabbix 用戶端的設定檔中添加以下內容:
# vim zabbix_agentd.conf
UserParameter=MongoDB.Status[*],/bin/echo "db.serverStatus().$1" | /usr/local/mongodb/bin/mongo admin | grep "\<$2\>"| awk -F : ‘{print $$2}‘|awk -F , ‘{print $$1}‘
4)重啟agent服務,在web端建立監控項
# /etc/init.d/zabbix-agent restart
三.web端配置
1)匯入Mongodb的模版(模版下載:650) this.width=650;" class="alignnone wp-image-219 size-full" src="http://www.mrliangqi.com/wp-content/uploads/2015/01/Download.png" width="85" height="29" style="border:5px solid rgb(235,235,235);height:auto;padding:0px;" />)
650) this.width=650;" class="aligncenter size-full wp-image-1383" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032701.png" width="493" height="507" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />650) this.width=650;" class="aligncenter size-full wp-image-1384" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032702.png" width="904" height="364" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
2)添加到主機並連結模版
650) this.width=650;" class="aligncenter size-full wp-image-1386" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032703.png" width="819" height="368" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
3)修改模版監控項中的詳細資料,把之前28018改成現在mongodb的連接埠即可~ 否則會一直警示。因為模版中預設監控的的連接埠是28018.
650) this.width=650;" class="aligncenter size-full wp-image-1387" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032704.png" width="791" height="649" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
4)在模版中,選擇Template MongoDB模版,然後批次更新,改成zabbix用戶端監控~
650) this.width=650;" class="aligncenter size-full wp-image-1388" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032705.png" width="565" height="504" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
650) this.width=650;" class="aligncenter size-full wp-image-1389" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032706.png" width="674" height="487" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
5)修改成功之後,可以在最新資料中查看狀態為1,就是運行中~
650) this.width=650;" class="aligncenter size-full wp-image-1390" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032707.png" width="1200" height="282" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
6)完成
查看監控情況:
650) this.width=650;" class="aligncenter size-full wp-image-1391" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032708.png" width="1200" height="649" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />650) this.width=650;" class="aligncenter size-full wp-image-1392" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032709.png" width="1200" height="575" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />650) this.width=650;" class="aligncenter size-full wp-image-1393" src="http://www.mrliangqi.com/wp-content/uploads/2017/03/2017032710.png" width="1200" height="603" style="border:5px solid rgb(235,235,235);margin-left:auto;margin-right:auto;height:auto;padding:0px;" />
本文來自:控企鵝的‘Blog,永久連結:http://www.mrliangqi.com/1382.html
本文出自 “Internet&Linux” 部落格,請務必保留此出處http://linuxsec.blog.51cto.com/10240211/1910879
Zabbix3.0.2監控Mongodb效能狀態