{"id":13480919,"url":"https://github.com/mzupan/nagios-plugin-mongodb","last_synced_at":"2025-04-12T19:48:50.270Z","repository":{"id":47433674,"uuid":"713714","full_name":"mzupan/nagios-plugin-mongodb","owner":"mzupan","description":"A Nagios plugin to check the status of MongoDB","archived":false,"fork":false,"pushed_at":"2024-07-29T11:15:08.000Z","size":432,"stargazers_count":346,"open_issues_count":95,"forks_count":273,"subscribers_count":33,"default_branch":"master","last_synced_at":"2025-04-12T19:48:35.378Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-2-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mzupan.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2010-06-10T15:05:39.000Z","updated_at":"2024-10-14T07:06:49.000Z","dependencies_parsed_at":"2024-12-14T10:01:11.086Z","dependency_job_id":"7583e235-d820-411b-89cf-de578930cdd4","html_url":"https://github.com/mzupan/nagios-plugin-mongodb","commit_stats":{"total_commits":232,"total_committers":80,"mean_commits":2.9,"dds":0.8017241379310345,"last_synced_commit":"d7c37d9668fd48587bd899684c97f32cac45c864"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzupan%2Fnagios-plugin-mongodb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzupan%2Fnagios-plugin-mongodb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzupan%2Fnagios-plugin-mongodb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mzupan%2Fnagios-plugin-mongodb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mzupan","download_url":"https://codeload.github.com/mzupan/nagios-plugin-mongodb/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248625501,"owners_count":21135513,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T17:00:46.547Z","updated_at":"2025-04-12T19:48:50.243Z","avatar_url":"https://github.com/mzupan.png","language":"Python","funding_links":[],"categories":["Nagios Monitoring","Tools"],"sub_categories":["Nagios Monitoring Plugins","Monitoring"],"readme":"# Nagios-MongoDB\n\n## Overview\n\nThis is a simple Nagios check script to monitor your MongoDB server(s). \n\n## Authors\n\n### Main Author\n Mike Zupan mike -(at)- zcentric.com\n### Contributers\n - Frank Brandewiede \u003cbrande -(at)- travel-iq.com\u003e \u003cbrande -(at)- bfiw.de\u003e \u003cbrande -(at)- novolab.de\u003e\n - Sam Perman \u003csam -(at)- brightcove.com\u003e\n - Shlomo Priymak \u003cshlomoid -(at)- gmail.com\u003e\n - @jhoff909 on github\n - Dag Stockstad \u003cdag.stockstad -(at)- gmail.com\u003e\n\n## Installation\n\nIn your Nagios plugins directory run\n\n\u003cpre\u003e\u003ccode\u003egit clone git://github.com/mzupan/nagios-plugin-mongodb.git\u003c/code\u003e\u003c/pre\u003e\n\nThen use pip to ensure you have all pre-requisites.\n\n\u003cpre\u003e\u003ccode\u003epip install -r requirements\u003c/code\u003e\u003c/pre\u003e\n\n## Usage\n\n### Install in Nagios\n\nEdit your commands.cfg and add the following\n\n\u003cpre\u003e\u003ccode\u003e\ndefine command {\n    command_name    check_mongodb\n    command_line    $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$\n}\n\ndefine command {\n    command_name    check_mongodb_database\n    command_line    $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$\n}\n\ndefine command {\n    command_name    check_mongodb_collection\n    command_line    $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -d $ARG5$ -c $ARG6$\n}\n\ndefine command {\n    command_name    check_mongodb_replicaset\n    command_line    $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -r $ARG5$\n}\n\ndefine command {\n    command_name    check_mongodb_query\n    command_line    $USER1$/nagios-plugin-mongodb/check_mongodb.py -H $HOSTADDRESS$ -A $ARG1$ -P $ARG2$ -W $ARG3$ -C $ARG4$ -q $ARG5$\n}\n\u003c/code\u003e\u003c/pre\u003e\n(add -D to the command if you want to add perfdata to the output)\nThen you can reference it like the following. This is is my services.cfg\n\n#### Check Connection\n\nThis will check each host that is listed in the Mongo Servers group. It will issue a warning if the connection to the server takes 2 seconds and a critical error if it takes over 4 seconds\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Connect Check\n    check_command           check_mongodb!connect!27017!2!4\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Percentage of Open Connections\n\nThis is a test that will check the percentage of free connections left on the Mongo server. In the following example it will send out an warning if the connection pool is 70% used and a critical error if it is 80% used. \n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Free Connections\n    check_command           check_mongodb!connections!27017!70!80\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Replication Lag\n\nThis is a test that will test the replication lag of Mongo servers. It will send out a warning if the lag is over 15 seconds and a critical error if its over 30 seconds. Please note that this check uses 'optime' from rs.status() which will be behind realtime as heartbeat requests between servers only occur every few seconds. Thus this check may show an apparent lag of \u003c 10 seconds when there really isn't any. Use larger values for reliable monitoring.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Replication Lag\n    check_command           check_mongodb!replication_lag!27017!15!30\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n#### Check Replication Lag Percentage\n\nThis is a test that will test the replication lag percentage of Mongo servers. It will send out a warning if the lag is over 50 percents and a critical error if its over 75 percents. Please note that this check gets oplog timeDiff from primary and compares it to replication lag. When this check reaches 100 percent full resync is needed. \n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Replication Lag Percentage\n    check_command           check_mongodb!replication_lag_percent!27017!50!75\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n#### Check Memory Usage\n\nThis is a test that will test the memory usage of Mongo server. In my example my Mongo servers have 32 gigs of memory so I'll trigger a warning if Mongo uses over 20 gigs of ram and a error if Mongo uses over 28 gigs of memory.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Memory Usage\n    check_command           check_mongodb!memory!27017!20!28\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Mapped Memory Usage\n\nThis is a test that will check the mapped memory usage of Mongo server. \n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Mapped Memory Usage\n    check_command           check_mongodb!memory_mapped!27017!20!28\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Lock Time Percentage\n\nThis is a test that will test the lock time percentage of Mongo server. In my example my Mongo I want to be warned if the lock time is above 5% and get an error if it's above 10%. When you start to have lock time it generally means your db is now overloaded.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Lock Percentage\n    check_command           check_mongodb!lock!27017!5!10\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Average Flush Time\n\nThis is a test that will check the average flush time of Mongo server. In my example my Mongo I want to be warned if the average flush time is above 100ms and get an error if it's above 200ms. When you start to get a high average flush time it means your database is write bound.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Flush Average\n    check_command           check_mongodb!flushing!27017!100!200\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Last Flush Time\n\nThis is a test that will check the last flush time of Mongo server. In my example my Mongo I want to be warned if the last flush time is above 200ms and get an error if it's above 400ms. When you start to get a high flush time it means your server might be needing faster disk or its time to shard.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Last Flush Time\n    check_command           check_mongodb!last_flush_time!27017!200!400\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check status of mongodb replicaset\nThis is a test that will check the status of nodes within a replicaset. Depending which status it is it sends a waring during status 0, 3 and 5, critical if the status is 4, 6 or 8 and a ok with status 1, 2 and 7.\n\nNote the trailing 2 0's keep those 0's as the check doesn't compare to anything.. So those values need to be there for the check to work.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB state\n      check_command           check_mongodb!replset_state!27017!0!0\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check status of index miss ratio\nThis is a test that will check the ratio of index hits to misses. If the ratio is high, you should consider adding indexes. I want to get a warning if the ratio is above .005 and get an error if it's above .01\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Index Miss Ratio\n      check_command           check_mongodb!index_miss_ratio!27017!.005!.01\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check number of databases and number of collections\nThese tests will count the number of databases and the number of collections. It is usefull e.g. when your application \"leaks\" databases or collections. Set the warning, critical level to fit your application.\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Number of databases\n      check_command           check_mongodb!databases!27017!300!500\n}\n\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Number of collections\n      check_command           check_mongodb!collections!27017!300!500\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n\n#### Check size of a database\nThis will check the size of a database. This is useful for keeping track of growth of a particular database.\nReplace your-database with the name of your database\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Database size your-database\n      check_command           check_mongodb_database!database_size!27017!300!500!your-database\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n\n#### Check index size of a database\nThis will check the index size of a database. Overlarge indexes eat up memory and indicate a need for compaction.\nReplace your-database with the name of your database\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Database index size your-database\n      check_command           check_mongodb_database!database_indexes!27017!50!100!your-database\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n\n#### Check index size of a collection\nThis will check the index size of a collection. Overlarge indexes eat up memory and indicate a need for compaction.\nReplace your-database with the name of your database and your-collection with the name of your collection\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Database index size your-database\n      check_command           check_mongodb_collection!collection_indexes!27017!50!100!your-database!your-collection\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n\n#### Check the primary server of replicaset\nThis will check the primary server of a replicaset. This is useful for catching unexpected stepdowns of the replica's primary server.\nReplace your-replicaset with the name of your replicaset\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Replicaset Master Monitor: your-replicaset\n      check_command           check_mongodb_replicaset!replica_primary!27017!0!1!your-replicaset\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n#### Check the number of queries per second\nThis will check the number of queries per second on a server. Since MongoDB gives us the number as a running counter, we store the last value in the local\ndatabase in the nagios_check collection. The following types are accepted: query|insert|update|delete|getmore|command\n\nThis command will check updates per second and alert if the count is over 200 and warn if over 150\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n      use                     generic-service\n      hostgroup_name          Mongo Servers\n      service_description     MongoDB Updates per Second\n      check_command           check_mongodb_query!queries_per_second!27017!200!150!update\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n#### Check Primary Connection\n\nThis will check each host that is listed in the Mongo Servers group. It will issue a warning if the connection to the primary server of current replicaset takes 2 seconds and a critical error if it takes over 4 seconds\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Connect Check\n    check_command           check_mongodb!connect_primary!27017!2!4\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n#### Check Collection State\n\nThis will check each host that is listed in the Mongo Servers group. It can be useful to check availability of a critical collection (locks, timeout, config server unavailable...).  It will issue a critical error if find_one query failed\n\n\u003cpre\u003e\u003ccode\u003e\ndefine service {\n    use                 generic-service\n    hostgroup_name          Mongo Servers\n    service_description     Mongo Collection State\n    check_command           check_mongodb!collection_state!27017!your-database!your-collection\n}\n\u003c/code\u003e\u003c/pre\u003e\n\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzupan%2Fnagios-plugin-mongodb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmzupan%2Fnagios-plugin-mongodb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmzupan%2Fnagios-plugin-mongodb/lists"}