[checkmk-commits] Check_MK Git: check_mk: FIX: postgres_sessions: handle case of no active/ no idle sessions

Mathias Kettner mk at mathias-kettner.de
Mon Nov 26 16:33:59 CET 2012


Module: check_mk
Branch: master
Commit: 24227c2901fa5fb30ed5bf0d49a11521bfee2f07
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=24227c2901fa5fb30ed5bf0d49a11521bfee2f07

Author: Mathias Kettner <mk at mathias-kettner.de>
Date:   Mon Nov 26 16:24:08 2012 +0100

FIX: postgres_sessions: handle case of no active/no idle sessions

---

 ChangeLog                |    3 +++
 checks/postgres_sessions |    8 +++++---
 2 files changed, 8 insertions(+), 3 deletions(-)

diff --git a/ChangeLog b/ChangeLog
index b810a0a..27958a2 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -169,6 +169,9 @@
     * FIX: fixed detection of existing groups when creating new groups
     * FIX: allow email addresses like test at test.test-test.com
 
+    Checks & Agents:
+    * FIX: postgres_sessions: handle case of no active/no idle sessions
+
 
 1.2.0p3:
     Mulitisite
diff --git a/checks/postgres_sessions b/checks/postgres_sessions
index aba0dc8..2d7b023 100644
--- a/checks/postgres_sessions
+++ b/checks/postgres_sessions
@@ -29,15 +29,17 @@
 # t 4
 
 # t -> idle sessions, f -> active sessions
+# Note: one (or both?) lines might be missing. They will never show 0.
 
 def inventory_postgres_sessions(info):
-    if len(info) == 2:
+    # inventorize only if at least one idle or active session exist
+    if info:
         return [(None, {})]
 
 def check_postgres_sessions(_no_item, params, info):
     parsed = dict(info)
-    idle = int(parsed['t'])
-    running = int(parsed['f'])
+    idle = int(parsed.get('t', 0))
+    running = int(parsed.get('f', 0))
     total = idle + running
 
     status = 0



More information about the checkmk-commits mailing list