Module: check_mk
Branch: master
Commit: 38f5a18ffa049589278c67fb98f34a3f1feee928
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=38f5a18ffa0495…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Mon Mar 17 14:55:39 2014 +0100
FIX zypper: agent plugin and check now lead to UNKNOWN result in case of repo problems
---
.werks/593 | 8 ++++++++
ChangeLog | 1 +
agents/plugins/mk_zypper | 22 ++++++++++++++++------
checks/zypper | 3 +++
4 files changed, 28 insertions(+), 6 deletions(-)
diff --git a/.werks/593 b/.werks/593
new file mode 100644
index 0000000..bf6ae16
--- /dev/null
+++ b/.werks/593
@@ -0,0 +1,8 @@
+Title: zypper: agent plugin and check now lead to UNKNOWN result in case of repo
problems
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1395064398
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index c35d1d3..40dfe0b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -204,6 +204,7 @@
* 0587 FIX: if64: problems resolved when running as a clustered service...
* 0563 FIX: windows agent: now able to process perl scripts...
* 0729 FIX: esx_vsphere_hostsystem: fixed incorrect status label (not state)...
+ * 0593 FIX: zypper: agent plugin and check now lead to UNKNOWN result in case of repo
problems
Multisite:
* 0371 Added log class filter to hostsvcevents view
diff --git a/agents/plugins/mk_zypper b/agents/plugins/mk_zypper
index 64f7bb9..f58f901 100755
--- a/agents/plugins/mk_zypper
+++ b/agents/plugins/mk_zypper
@@ -28,13 +28,23 @@ if type zypper > /dev/null ; then
if grep -q '^VERSION = 10' < /etc/SuSE-release
then
ZYPPER='waitmax 10 zypper --no-gpg-checks --non-interactive --terse'
- $ZYPPER refresh > /dev/null
- { $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lu ; } \
- | egrep '(patches needed|\|)' | egrep -v '^(#|Repository |Catalog
)'
+ REFRESH=`$ZYPPER refresh 2>&1`
+ if [ "$REFRESH" ]
+ then
+ echo "ERROR: $REFRESH"
+ else
+ { $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lu ; } \
+ | egrep '(patches needed|\|)' | egrep -v '^(#|Repository |Catalog
)'
+ fi
else
ZYPPER='waitmax 10 zypper --no-gpg-checks --non-interactive --quiet'
- $ZYPPER refresh > /dev/null
- { { $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lp ; } ; $ZYPPER
ll ; } \
- | egrep '(patches needed|\|)' | egrep -v '^(#|Repository)'
+ REFRESH=`$ZYPPER refresh 2>&1`
+ if [ "$REFRESH" ]
+ then
+ echo "ERROR: $REFRESH"
+ else
+ { { $ZYPPER pchk || [ $? = 100 -o $? = 101 ] && $ZYPPER lp ; } ;
$ZYPPER ll ; } \
+ | egrep '(patches needed|\|)' | egrep -v '^(#|Repository)'
+ fi
fi
fi
diff --git a/checks/zypper b/checks/zypper
index 291b44b..fb4fe48 100644
--- a/checks/zypper
+++ b/checks/zypper
@@ -46,6 +46,9 @@ def check_zypper(_no_item, _no_params, info):
patch_types = {}
updates = 0
locks = []
+ firstline = " ".join(info[0])
+ if re.match("ERROR:", firstline):
+ return 3, firstline
for line in info:
# 5 patches needed (2 security patches)
if len(line) >= 5 and line[4].lower().strip() == 'needed':