Recently the company has a few new MongoDB projects (standalone MongoDB) that need to sit down and monitor. There was a monitoring template before, but the effect was not good. So I went to Google again, with the following record.
Stand-alone version reference Https://github.com/oscm/zabbix/tree/master/mongodb
Lab Environment:
CentOS6.8 x86_64
percona-server-mongodb-3.2.9
Steps:
1. will be mongodb.sh This script is copied to /etc/zabbix/scripts and modify it to suit your environment.
( our online MongoDB does not set the password, the script also commented out the relevant code ), and chmod Execute permissions
#!/bin/bash
##################################################
#AUTHOR: Neo <[email protected]>
#WEBSITE: http://www.netkiller.cn
#Description £ozabbix MongoDB Monitor
#Note £ozabbix 3.2
#DateTime: 2016-11-23
##################################################
# I'm here on the line environment MongoDB does not have config password, just restrict access to IP via iptables
Host=localhost
port=27017
#USER =monitor
#PASS =chen
index=$ ([email protected] | tr "" ".")
#status =$ (echo "Db.serverstatus (). ${index}" |mongo-u ${user}-P ${pass} admin--port ${port}|sed-n ' 3p ')
Status=$ (echo "Db.serverstatus (). ${index}" |/usr/local/mongodb/bin/mongo admin--port ${port}|sed-n ' 3p ')
#checkif the output contains "Numberlong"
if[["$status" =~ "Numberlong"]];then
echo $status |sed-n ' S/numberlong (//p ' |sed-n ' s/)//p '
Else
Echo $status
Fi
2. will be userparameter_mongodb.conf Copy to /etc/zabbix/zabbix_agentd.d Below , the specific content is as follows:
Userparameter=mongodb.status[*],/etc/zabbix/scripts/mongodb.sh$1 $ $4
3. Import the monitoring template in the Zabbix Web background and associate the MongoDB host with the template.
The attachment is packaged for the 3 files mentioned above.
Well-equipped monitoring such as:
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/8F/9C/wKiom1jma4KBBzSkAABjJ_YqOmM589.png "style=" float : none; "title=" 11.png "alt=" Wkiom1jma4kbbzskaabjj_yqomm589.png "/>
650) this.width=650; "src=" Https://s3.51cto.com/wyfs02/M00/8F/9B/wKioL1jma4LBy2v8AABWJrJ_NeE910.png "style=" float : none; "title=" 22.png "alt=" Wkiol1jma4lby2v8aabwjrj_nee910.png "/>
650) this.width=650; "src=" Https://s5.51cto.com/wyfs02/M01/8F/9C/wKiom1jma4OBlbyoAABzkMPr35w929.png "style=" float : none; "title=" 33.png "alt=" Wkiom1jma4oblbyoaabzkmpr35w929.png "/>
Copy set version of MongoDB's monitoring template in the experiment, no problem, then post it.
Zabbix monitoring of the single-machine version of MongoDB