[Pkg-nagios-changes] [pkg-nagios-plugins-contrib] 01/13: check_mongodb: Updating to latest version

Jan Wagner waja at moszumanska.debian.org
Fri Mar 6 09:57:09 UTC 2015


This is an automated email from the git hooks/post-receive script.

waja pushed a commit to branch master
in repository pkg-nagios-plugins-contrib.

commit 6ed8e1bc5f25d216092bae55d005f78e3a80b16e
Author: Jan Wagner <waja at cyconet.org>
Date:   Wed Mar 4 15:34:41 2015 +0100

    check_mongodb: Updating to latest version
---
 check_mongodb/check_mongodb.py | 29 +++++++++++++++++++++++++----
 check_mongodb/control          |  2 +-
 debian/control                 |  2 +-
 3 files changed, 27 insertions(+), 6 deletions(-)

diff --git a/check_mongodb/check_mongodb.py b/check_mongodb/check_mongodb.py
index 807847f..87b4ce0 100644
--- a/check_mongodb/check_mongodb.py
+++ b/check_mongodb/check_mongodb.py
@@ -16,6 +16,8 @@
 #   - @jbraeuer on github
 #   - Dag Stockstad <dag.stockstad at gmail.com>
 #   - @Andor on github
+#   - Steven Richards - Captainkrtek on github
+#   - Max Vernimmen
 #
 # USAGE
 #
@@ -375,7 +377,7 @@ def check_rep_lag(con, host, port, warning, critical, percent, perf_data, max_la
             for member in rs_status["members"]:
                 if member["stateStr"] == "PRIMARY":
                     primary_node = member
-                if member["name"].split(':')[0] == host and int(member["name"].split(':')[1]) == port:
+                if member.get('self') == True:
                     host_node = member
 
             # Check if we're in the middle of an election and don't have a primary
@@ -501,8 +503,22 @@ def check_memory(con, warning, critical, perf_data, mapped_memory):
     #
     # These thresholds are basically meaningless, and must be customized to your system's ram
     #
-    warning = warning or 8
-    critical = critical or 16
+
+    # Get the total system merory and calculate based on that how much memory used by Mongodb is ok or not.
+    meminfo = open('/proc/meminfo').read()
+    matched = re.search(r'^MemTotal:\s+(\d+)', meminfo)
+    if matched: 
+        mem_total_kB = int(matched.groups()[0])
+
+    # Old way
+    #critical = critical or 16
+    # The new way. if using >80% then warn, if >90% then critical level
+    warning = warning or (mem_total_kB * 0.8) / 1024.0 / 1024.0
+    critical = critical or (mem_total_kB * 0.9) / 1024.0 / 1024.0
+
+    # debugging
+    #print "mem total: {0}kb, warn: {1}GB, crit: {2}GB".format(mem_total_kB,warning, critical)
+
     try:
         data = get_server_status(con)
         if not data['mem']['supported'] and not mapped_memory:
@@ -593,7 +609,12 @@ def check_lock(con, warning, critical, perf_data):
         #
         # calculate percentage
         #
-        lock_percentage = float(data['globalLock']['lockTime']) / float(data['globalLock']['totalTime']) * 100
+        lockTime = data['globalLock']['lockTime']
+        totalTime = data['globalLock']['totalTime']
+        if lockTime > totalTime:
+            lock_percentage = 0.00
+        else:
+            lock_percentage = float(lockTime) / float(totalTime) * 100
         message = "Lock Percentage: %.2f%%" % lock_percentage
         message += performance_data(perf_data, [("%.2f" % lock_percentage, "lock_percentage", warning, critical)])
         return check_levels(lock_percentage, warning, critical, message)
diff --git a/check_mongodb/control b/check_mongodb/control
index 2efd95e..4a69ff8 100644
--- a/check_mongodb/control
+++ b/check_mongodb/control
@@ -1,6 +1,6 @@
 Uploaders: Jan Wagner <waja at cyconet.org>
 Recommends: python-pymongo
-Version: 60b639ef4c
+Version: 2032d64ba1
 Homepage: https://github.com/mzupan/nagios-plugin-mongodb
 Watch: https://github.com/mzupan/nagios-plugin-mongodb <span class="sha">([0-9a-f]+)</span>
 Description: Plugin script to monitor your MongoDB server(s)
diff --git a/debian/control b/debian/control
index cff41ac..1f16c7e 100644
--- a/debian/control
+++ b/debian/control
@@ -98,7 +98,7 @@ Description: Plugins for nagios compatible monitoring systems
      This plugin excludes the system cache and buffer, because
      on some system with very stable memory usage it is perfectly
      normal for system cache to fill in all available memory.
-   * check_mongodb (60b639ef4c): Plugin script to monitor your MongoDB server(s)
+   * check_mongodb (2032d64ba1): Plugin script to monitor your MongoDB server(s)
    * check_multipath (0.2.1): plugin to monitor the number of available and
      failed paths of multipath devices
    * check_mysql_health (2.1.8.2): plugin to check various parameters of a

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-nagios/pkg-nagios-plugins-contrib.git



More information about the Pkg-nagios-changes mailing list