Module: check_mk
Branch: master
Commit: 24cb171473ec0a2238503072e5cf4135f40fff58
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=24cb171473ec0a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 13 13:54:36 2012 +0200
FIX: zypper: deal with output with only 5 columns
---
checks/zypper | 19 +++++++++++--------
1 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/checks/zypper b/checks/zypper
index 49a6a4c..f5cb3c4 100644
--- a/checks/zypper
+++ b/checks/zypper
@@ -46,7 +46,7 @@ def check_zypper(_no_item, _no_params, info):
locks = []
for line in info:
# 5 patches needed (2 security patches)
- if len(line) >= 6 and line[4].strip() == 'needed':
+ if len(line) >= 5 and line[4].strip() == 'needed':
patch_type = line[3].strip()
patch_types.setdefault(patch_type, 0)
patch_types[patch_type] += 1
@@ -54,12 +54,7 @@ def check_zypper(_no_item, _no_params, info):
elif len(line) == 4:
locks.append(line[1])
- if patch_types.get('security'):
- state = 2
- elif updates:
- state = 1
- else:
- state = 0
+ state = 0
infotext = nagios_state_names[state] + " - %d updates" % updates
if updates:
@@ -67,7 +62,15 @@ def check_zypper(_no_item, _no_params, info):
patch_items.sort()
infos = []
for t,c in patch_items:
- infos.append("%s: %d(%s)" % (t, c, t == "security" and
'!!' or '!'))
+ if t == "security":
+ marker = '(!!)'
+ state = 2
+ elif t == "recommended":
+ marker = '(!)'
+ state = max(state, 1)
+ else:
+ marker = ''
+ infos.append("%s: %d%s" % (t, c, marker))
infotext += " (" + ", ".join(infos) + ")"
if locks: