Zabbix Monitoring of stand-alone MongoDB
Recently, the company has launched several new mongodb projects (stand-alone MongoDB), which need to sit down and monitor. There was a monitoring template before, but it didn't work well. So I went to google again and got the following record.
Reference https://github.com/oscm/zabbix/tree/master/mongodb for stand-alone version
Experimental environment:
CentOS6.8 X86_64
Percona-server-mongodb-3.2.9
Steps:
1. Copy the script mongodb.sh to / etc/zabbix/scripts and modify the environment that suits you.
(our online mongodb does not set a password, and the relevant code is commented out in the script), and chmod adds execution permission.
#! / bin/bash
# # #
# AUTHOR: Neo
# WEBSITE: http://www.netkiller.cn
# Description £ozabbix mongodb monitor
# Note £oZabbix 3.2
# DateTime: 2016-11-23
# # #
# the mongodb of my online environment does not have a password configured, but only the IP that restricts access through iptables
HOST=localhost
PORT=27017
# USER=monitor
# PASS=chen
Index=$ (echo$@ | 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. Copy userparameter_mongodb.conf to / etc/zabbix/zabbix_agentd.d, as shown below:
UserParameter=mongodb.status [*], / etc/zabbix/scripts/mongodb.sh$1 $2 $3 $4 $5
3. Import the monitoring template in the web backend of zabbix, and associate the mongodb host with the template.
The attachment is a package of the three files mentioned above.
The configured monitoring is as shown below:
The monitoring template of the copy set version of MongoDB is in the experiment, no problem and then post it.
Attachment: http://down.51cto.com/data/2366564