Nagios Monitoring MongoDB Shard Cluster Service combat

Source: Internet
Author: User
Tags mongodb commands mongodb monitoring



1 , monitoring plug-in download
Mongodb plug-ins are:  git://github.com/mzupan/nagios-plugin-mongodb.git, at first I did not install the gitpub Environment, Find users grassroots help download, and then uploaded to the csdn Resources page, the new is:http://download.csdn.net/detail/mchdba/8019077


2 , add a new MongoDB Monitoring Commands

Since the MongoDB service is a physical machine that is shared with MySQL from the library, it has already done the basic Nagios as well as the MySQL service monitoring, so it is only necessary to add MONGODB commands and services on the original basis. Nagios monitoring MySQL Please refer to: http://blog.itpub.net/26230597/viewspace-760141/and http://blog.itpub.net/26230597/viewspace-1217246/. So the MONGODB monitoring commands that need to be added here are as follows:

[[email protected] objects]# cd/usr/local/nagios/etc/objects[[email protected] objects]# vim Commands.cfgdefine command {command_name check_mongodb command_line $USER 1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS $-A $ARG 1$-P $ARG 2$-W $ARG 3$-C $ARG 4$}define command {command_name check_mongodb_database comman D_line $USER 1$/nagios-plugin-mongodb/check_mongodb.py-h $HOSTADDRESS $-A $ARG 1$-P $ARG 2$-W $ARG 3$-C $ARG 4$-D $ARG 5$}d  Efine command {command_name check_mongodb_collection command_line $USER 1$/nagios-plugin-mongodb/check_mongodb.py-h $HOSTADDRESS $-A $ARG 1$-P $ARG 2$-W $ARG 3$ c $ARG 4$-D $ARG 5$-C $ARG 6$}define command {command_name check_mongodb_ Replicaset command_line $USER 1$/nagios-plugin-mongodb/check_mongodb.py-h $HOSTADDRESS $-A $ARG 1$-P $ARG 2$-W $ARG 3$- C $ARG 4$-R $ARG 5$}define command {command_name check_mongodb_query command_line $USER 1$/nagios-plugin-mongodb/chec K_mongodb.py-h $HOSTADDRESS $-A $ARG 1$-P $ARG 2$-W $ARG 3$-C $ARG 4$-Q $ARG 5$} 


3 , adding MongoDB Monitoring Services MongoDB Services also need to be re-added separately, as follows:
#检测mongodb服务的连接时间, more than 2 seconds of ordinary alarm, 5 seconds on serious alarm define service{host_name dbm1slave1 service_description Mongo Connect Ch        Eck Check_command check_mongodb!connect!30000!2!5 max_check_attempts 5 normal_check_interval 3 Retry_check_interval 2 check_period 24x7 notification_interval notification_period 24x7 No Tification_options w,u,c,r contact_groups Ops} #检查mongodb的连接数, more than 150 ordinary alarms, 200 critical alarms define service{Host_n Ame dbm1slave1 service_description Mongo free Connections check_command check_mongodb!connections!27017!70!8        0 max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 Check_period 24x7        Notification_interval notification_period 24x7 notification_options w,u,c,r contact_groups Ops #检查mongodb复制完成的百分比率, make sure that the time of the primary and standby is consistent. Define service{host_name dbm1slave1 service_description MongoReplication Lag check_command check_mongodb!replication_lag!27017!15!30 max_check_attempts 5 Normal_c Heck_interval 3 retry_check_interval 2 check_period 24x7 notification_interval notification _period 24x7 notification_options w,u,c,r contact_groups Ops} #检查mongodb内存使用率, the threshold is the same as that of MongoDB machine Total memory related define service{host_name dbm1slave1 service_description Mongo memory Usage check_command Check        _mongodb!memory!27017!20!28 max_check_attempts 5 normal_check_interval 3 Retry_check_interval 2        Check_period 24x7 notification_interval notification_period 24x7 notification_options w,u,c,r Contact_groups OPS} #检查mongodb mapped memory usage, threshold associated with the total amount of memory in the machine where MongoDB is located define service{host_name DBM1        Slave1 service_description Mongo Mapped Memory Usage check_command check_mongodb!memory_mapped!27017!20!28 Max_check_attempts 5 Normal_check_interval 3 Retry_check_interval 2 check_period 24x7 Notification_interval 10 Notification_period 24x7 notification_options w,u,c,r contact_groups ops} #检查Lock time Percentage, if lock time occupies 5% of the MONGO runtime, the normal alarm, if more than 10% on the serious alarm define service{host_name dbm1slave1 service_description Mong o Lock Percentage check_command check_mongodb!lock!27017!5!10 max_check_attempts 5 normal_check_inter Val 3 retry_check_interval 2 check_period 24x7 Notification_interval notification_period 24 X7 notification_options w,u,c,r contact_groups ops}# check Average flush time, check the average Flush duration of the MONGO server, D Efine service{host_name dbm1slave1 service_description Mongo Flush Average check_command Check_mongo        db!flushing!27017!100!200 max_check_attempts 5 normal_check_interval 3 Retry_check_interval 2       Check_period 24x7 Notification_interval notification_period 24x7 notification_options w,u,c,r contact_groups Ops }# Check last flush time, checking the latest flush times, if more than 200ms on the ordinary alarm, more than 400ms on the serious alarm define service{host_name dbm1slave1 s Ervice_description Mongo last Flush time Check_command check_mongodb!last_flush_time!27017!200!400 Max_check _attempts 5 normal_check_interval 3 retry_check_interval 2 check_period 24x7 Notification_inte Rval notification_period 24x7 notification_options w,u,c,r contact_groups ops} # Ch Eck Status of MongoDB Replicaset, checking the status of MONGO replication define service{host_name dbm1slave1 service_description MongoD B State Check_command check_mongodb!replset_state!27017!0!0 max_check_attempts 5 Normal_check_interva         L 3 retry_check_interval 2 check_period 24x7 notification_interval notification_period 24x7 Notification_optIons w,u,c,r contact_groups ops}# Check status of index Miss ratio, check index hit ratio, define service{HOST_NAME Dbm1slave1 service_description MongoDB Index Miss Ratio check_command check_mongodb!index_miss_ratio!27017! .005!.        Max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 Check_period 24x7        Notification_interval notification_period 24x7 notification_options w,u,c,r contact_groups Ops # Check number of databases and number of Collectionsdefine service{host_name dbm1slave1 ser Vice_description MongoDB number of databases Check_command check_mongodb!databases!27017!300!500 max_check_a Ttempts 5 normal_check_interval 3 retry_check_interval 2 check_period 24x7 Notification_interv Al Notification_period 24x7 notification_options w,u,c,r contact_groups ops}define Service {HOST_NAME Dbm1slave1 service_description MongoDB Number of collections Check_command check_mongodb!collections!27017!        300!500 max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 Check_period 24x7 Notification_interval notification_period 24x7 notification_options w,u,c,r contact_groups OPS} # Check size of a database, check library sizes define service{host_name dbm1slave1 service_de Scription MongoDB Database size your-database check_command check_mongodb_database!database_size!27017!300!500!your -database max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 check_period 24x 7 notification_interval notification_period 24x7 notification_options w,u,c,r Contact_group         S OPS} # Check index size of a database, check the size of the library index define service{host_name dbm1slave1 Service_descriptIon MongoDB Database Index size your-database check_command check_mongodb_database!database_indexes!27017!50!100!yo Ur-database max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 Check_period 2 4x7 notification_interval notification_period 24x7 notification_options w,u,c,r Contact_gro  UPS OPS} # Check index size of a collection, check the collection of the collection define service{host_name Dbm1slave1 service_description MongoDB Database index size your-database check_command Check_mongodb_collec Tion!collection_indexes!27017!50!100!your-database!your-collection max_check_attempts 5 Normal_check_interva         L 3 retry_check_interval 2 check_period 24x7 notification_interval notification_period 24x7 Notification_options w,u,c,r contact_groups Ops} # Check the primary server of Replicaset, checking Replication of the primary service define Service{host_name dbm1slave1 service_description MongoDB replicaset Master monitor:your-replicaset Check _command check_mongodb_replicaset!replica_primary!27017!0!1!your-replicaset #示例: Check_command check_mongodb_repli Caset!replica_primary!27017!0!1!shard2 max_check_attempts 5 Normal_check_interval 3 Retry_check_inter  Val 2 check_period 24x7 notification_interval notification_period 24x7 notification_options        W,u,c,r contact_groups Ops} # Check the number of queries per second, checking the amount of queries per second define Service{ HOST_NAME dbm1slave1 service_description MongoDB Updates per Second check_command check_mongodb_query!que Ries_per_second!27017!200!150!update max_check_attempts 5 Normal_check_interval 3 Retry_check_interva L 2 check_period 24x7 notification_interval notification_period 24x7 notification_options W , U,c,r Contact_groUPS OPS} # Check Primary Connection, checking the connection time of the copy with Primary Library, more than 2 seconds of ordinary alarm, more than 4 seconds of serious alarm define service{HOST_NAME        Dbm1slave1 service_description Mongo Connect Check check_command check_mongodb!connect_primary!27017!2!4 Max_check_attempts 5 normal_check_interval 3 retry_check_interval 2 Check_period 24x7 not        Ification_interval notification_period 24x7 notification_options w,u,c,r contact_groups Ops }# Check Collection state, checking the Collection status, checking each host of the MONGO service group list, can check for high availability of critical Collection (lock, timeout, availability of service configuration), and alert if a query fails. Define service{host_name dbm1slave1 service_description Mongo Collection State Check_command Check_m        Ongodb!collection_state!27017!your-database!your-collection max_check_attempts 5 Normal_check_interval 3        Retry_check_interval 2 check_period 24x7 notification_interval notification_period 24x7    Notification_options W,u,c,r    Contact_groups OPS} 




4 to view the effects of some of the monitoring items

After configuring the Nagios Terminal Services, restart the service Nagios restart; After a few minutes, the Nagios monitoring interface will display the full MONGO service information as follows:




5
, from PS determined in MongoDB The Architecture

[Email protected] ~]# ps-eaf|grep MONGO

MongoDB 2457 1 0 2013? 2-03:39:08./mongod--configsvr--dbpath/home/data/mongodb/config--port 20000--logpath/home/data/mongodb/ Config.log--logappend--fork

MongoDB 2804 1 0 2013? 1-10:02:33 MONGOs--configdb 192.168.12.62:20000,192.168.12.63:20000,192.168.12.72:20000--port 30000--chunkSize 64- -logpath/home/data/mongodb/mongos.log--logappend--fork

MongoDB 3072 1 0 2013? 1-10:17:20 mongod--shardsvr--replset shard1--port 27017--dbpath/home/data/mongodb/shard11--oplogsize 2048--logpath /home/data/mongodb/shard11.log--logappend--fork

Root 11179 9391 0 11:14 pts/1 00:00:00 grep MONGO

MongoDB 30414 1 0 Feb14? 1-06:20:50 mongod--shardsvr--replset shard2--port 27018--dbpath/home/data/mongodb/shard21--oplogsize 2048--logpath /home/data/mongodb/shard21.log--logappend--fork

[Email protected] ~]#

See there are 4 MONGO processes,

A) The starting parameter is "--CONFIGDB" is the cluster entrance process;

b) Shard Server, start parameter with "--shardsvr--replset" is a slice group of cluster boot process, the user stores the actual data block, namely 27017 Port and 27018 Port MongoDB service instance. As to how to determine which of the 27017 ports is primary which is secondary need to go to login 27107 port to execute rs.status (); Go and check it out.

c) Config Server: The process of starting the parameter with "--configsvr", which stores the entire cluster Metadata, including the chunk information, which is the 20000-port MongoDB service instance.

d) Route Server: Start the process with "MONGOs--configdb", the front-end routing, the Client access, and make the entire cluster look like a single database, front-end applications can be used transparently, that is, 30000-Port MongoDB instance.


6, errors in debugging

Error 1:

[Email protected] Nagios ~]# tail-f/usr/local/nagios/var/nagios.log

[1412819956] Warning:return code of for check the service ' Mongo Memory Usage ' on host ' dbm1slave1 ' is out of bounds.

[1412819956] SERVICE alert:dbm1slave1; Mongo Memory Usage; CRITICAL; soft;1; (Return Code of Bounds)

[1412819975] Warning:return code of for check the service ' Mongodb Connect check ' on host ' dbm1slave1 ' is out of bound S.

[1412819975] SERVICE alert:dbm1slave1; Mongodb Connect Check; CRITICAL; soft;1; (Return Code of Bounds)

[1412820058] Warning:return code of for Check in service ' Mongo free Connections ' on host ' dbm1slave1 ' is out of Boun Ds.

need to assign a value Nagios all user rights and R Execute Permissions

chmod 770/usr/lib/nagios/plugins/check_mongodb.py

Chown-r nagios.nagios/usr/lib/nagios/plugins/check_mongodb.py

Error 2:

Monitoring interface status information A column appears No module named Pymongo error message:

This prompt appears because you need to install the Pymongo module, perform the Easy_install pymongo command installation, as follows:

[Email protected] objects]# Easy_install Pymongo

Searching for Pymongo

Reading http://pypi.python.org/simple/pymongo/

Best Match:pymongo 2.7.2

......

Zip_safe flag not set; Analyzing Archive Contents ...

Adding Pymongo 2.7.2 to easy-install.pth file

Installed/usr/lib/python2.6/site-packages/pymongo-2.7.2-py2.6-linux-x86_64.egg

Processing dependencies for Pymongo

Finished processing dependencies for Pymongo

--------------------------------------------------------------------------------------------------------------- -

< copyright, the article allows reprint, but must be linked to the source address, otherwise investigate legal liability!>
Original Blog Address: http://blog.itpub.net/26230597/viewspace-1293589/
Hara Douglas Fir (MCHDBA)

--------------------------------------------------------------------------------------------------------------- -


Reference article: HTTPS://GITHUB.COM/MZUPAN/NAGIOS-PLUGIN-MONGODB/BLOB/MASTER/README.MD


Nagios Monitoring MongoDB Shard Cluster Service combat

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.