Module: check_mk
Branch: master
Commit: 66bd23dd12e5bfba57aff5ee8ccca9e639a20037
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=66bd23dd12e5bf…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Thu Sep 3 16:47:57 2015 +0200
#2571 FIX local: improved reporting of bad local check output
---
.werks/2571 | 9 +++++++++
ChangeLog | 1 +
checks/local | 18 ++++++++++++------
3 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/.werks/2571 b/.werks/2571
new file mode 100644
index 0000000..0aed2f8
--- /dev/null
+++ b/.werks/2571
@@ -0,0 +1,9 @@
+Title: local: improved reporting of bad local check output
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1441291579
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 8f4d1a8..9b03f53 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -168,6 +168,7 @@
* 2559 FIX: job: Trying to read job result files as non root when agent is not
executed as root
* 2570 FIX: winperf_msx_queues: fixed crash when winperf data is missing...
* 2593 FIX: cisco_wlc, cisco_wlc_clients: Fix discovery so that Cisco Virtual
Wireless Controller are detected...
+ * 2571 FIX: local: improved reporting of bad local check output
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce
unhandled exceptions...
diff --git a/checks/local b/checks/local
index 1ad3f4a..ee63afc 100644
--- a/checks/local
+++ b/checks/local
@@ -86,12 +86,12 @@ def local_compute_state(perfdata):
def inventory_local(info):
inventory = []
- # Ignore invalid lines, tolerate bugs in local checks
- # of unexperianced users. Lines with P do not need to
- # supply a text
+ # Lines with P do not need to supply a text
for line in info:
if len(line) >= 4 or len(line) == 3 and line[0] == 'P':
inventory.append( (line[1], None) )
+ else:
+ raise MKGeneralException("Invalid local check output: %s" % line)
return inventory
def check_local(item, params, info):
@@ -99,6 +99,9 @@ def check_local(item, params, info):
# Ignore invalid lines, tolerate bugs in local checks
# of unexperienced users
if len(line) >= 2 and line[1] == item:
+ if not (len(line) >= 4 or (len(line) == 3 and line[0] == 'P')):
+ return 3, "Invalid local check output: %s" % line
+
statechar = line[0]
perftxt = line[2]
output = " ".join(line[3:])
@@ -106,9 +109,12 @@ def check_local(item, params, info):
if perftxt != "-":
# new: allow multiple perfdata by using | as separator
for entry in perftxt.split('|'):
- varname, valuetxt = entry.split('=')
- values = valuetxt.split(';')
- perfdata.append(tuple( [varname] + values ))
+ try:
+ varname, valuetxt = entry.split('=')
+ values = valuetxt.split(';')
+ perfdata.append(tuple( [varname] + values ))
+ except ValueError:
+ return 3, "Invalid local check output: %s" % line
if statechar == 'P':
state, texts = local_compute_state(perfdata)
if output: