with MongoDB's extensive use monitoring MongoDB's business is now becoming very important now let's talk about how to monitor MongoDB in Nagios.
One: Download the Nagios-plugin-mongodb plugin.
Https://github.com/mzupan/nagios-plugin-mongodb
Second: Upload the check_mongodb.py plugin in the download package to the Nagios server.
Place the plugin in Nagios's libexec directory
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/3F/wKioL1fY-wXg2pg1AAAeqceeTBY734.png "title=" 2.png " alt= "Wkiol1fy-wxg2pg1aaaeqceetby734.png"/>
Note Adding permissions
# chown Nagios.nagios check_mongodb.py# chmod a+x check_mongodb.py
Third: Test whether the check_mongdb.py plug-in can be used.
#./check_mongodb.py--help
If the normal practical help option is available, the plug-in will work properly. If no module named Pymongo information is displayed, install the Pymongo module for the system.
Four: Download and install Pymongo.
Download the latest pymongo2.7.1
# wget--no-check-certificate https://pypi.python.org/packages/source/p/pymongo/pymongo-2.7.1.tar.gz
Installing Pymongo
# tar-zxvf pymongo-2.7.1.tar.gz# cd pymongo-2.7.1# python setup.py install
V: Test the MongoDB connection using the check_mongodb.py plugin.
650) this.width=650; "src=" Http://s2.51cto.com/wyfs02/M00/87/3F/wKioL1fY-xDDFuQQAAAXq9wSHfk161.png "title=" 1.png " alt= "Wkiol1fy-xddfuqqaaaxq9wshfk161.png"/>
Six: Configure Nagios.
Configuration commands
# vi /usr/local/nagios/etc/objects/commands.cfg##### #check_mongodb ####### #define command { command_name check_mongodb command_line $USER 1$/check_mongodb.py -h $ARG 1$ -a $ARG 2$ -p $ARG 3$ -W $ARG 4$ -c $ARG 5$ }define command { command_name check_mongodb_database command_line $ user1$/check_mongodb.py -h $ARG 1$ -a $ARG 2$ -p $ARG 3$ -w $ARG 4$ - c $ARG 5$ -d $ARG 6$}define command { command_name check_mongodb_collection command_line $USER 1$/check_ mongodb.py -h $ARG 1$ -a $ARG 2$ -p $ARG 3$ -w $ARG 4$ -c $ARG 5$ -d $ARG 6$ -c $ARG 7$}define command { command_name check_mongodb_replicaset command_line $USER 1$/check_mongodb.py -H $ARG 1$ -a $ARG 2$ -p $ARG 3$ -w $ARG 4$ -c $ARG 5$ -r $ARG 6$}define command { command_name check_ mongodb_query command_line $USER 1$/check_mongodb.py -h $ARG 1$ -a $ARG 2$ -p $ARG 3$ -w $ARG 4$ -c $ARG 5$ -q $ arg6$}
Configuration Services (the following separately monitor connections, idle connections, memory usage, replica set status, library size)
# vi /usr/local/nagios/etc/objects/localhost.cfg##### #check_mongodb ######### #define service{ use linux-service host_name 10.0.1.103 service_description check_ mongodb_connect_54 check_command check_mongodb!10.0.1.54!connect!27017!2!4 } define service{ use linux-service ; name of service template to use host_name 10.0.1.103 service_description check_mongodb_connections_54 check_command check_mongodb!10.0.1.54!connections!27017!70 !80 }define service{ use linux-service ; Name of service template to use host_name 10.0.1.103 service_description check_mongodb_memory_54 check_command check_mongodb! 10.0.1.54!memory!27017!20!28 }define service{ use linux-service ; Name of service template to use host_name 10.0.1.103 service_description check_mongodb_rep_state_54 check_command check_mongodb!10.0.1.54!replset_state!27017!0!0}define service{ use linux-service ; Name of service template to use host_name 10.0.1.103 service_ Description check_mongodb_ database_exam_54 check_command check_mongodb_database! 10.0.1.54!database_size!27017!300!500!exam}
Seven: Test syntax reread Nagios configuration
#/usr/local/nagios/bin/nagios-v/usr/local/nagios/etc/nagios.cfg
If there is no error rereading the configuration
# service Nagios Reload
Eight: Check the Nagios monitoring page for verification results.
650) this.width=650; "src=" Http://s1.51cto.com/wyfs02/M01/87/42/wKiom1fY-x7yp8wbAAAUSUjBnZg033.png "title=" 3.png " alt= "Wkiom1fy-x7yp8wbaaausujbnzg033.png"/>
The monitoring configuration is complete.
Can be configured according to the needs of MongoDB to add various monitoring indicators memory database.
This article from the "Play God Clown" blog, reproduced please contact the author!
Nagios Monitoring MongoDB