Module: check_mk
Branch: master
Commit: 8b53efa3cb3c7715de507eff96e59bdf4ee2fc9a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8b53efa3cb3c77…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 26 09:45:55 2013 +0200
FIX: mrpe: gracefully handle invalid exit code of plugin
---
ChangeLog | 1 +
checks/mrpe | 4 ++++
2 files changed, 5 insertions(+)
diff --git a/ChangeLog b/ChangeLog
index 98893f9..a74ba76 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -114,6 +114,7 @@
by the check plugin
* FIX: check_disk_smb: Remove $ from share when creating service description.
Otherwise Nagios will not accept the service description.
+ * FIX: mrpe: gracefully handle invalid exit code of plugin
Notifications:
* notify.py: Matching service level: Use the hosts service level if a
diff --git a/checks/mrpe b/checks/mrpe
index aa1390e..986e73b 100644
--- a/checks/mrpe
+++ b/checks/mrpe
@@ -59,6 +59,7 @@ def check_mrpe(item, params, info):
check_name = None
if line[0] == item:
state = int(line[1])
+
# convert to original format by joining and replacing \1 back with \n
rest = " ".join(line[2:]).replace("\1", "\n")
# split into lines
@@ -66,6 +67,9 @@ def check_mrpe(item, params, info):
# First line: OUTPUT|PERFDATA
parts = lines[0].split("|", 1)
output = [parts[0].strip()]
+ if state not in [ 0, 1, 2, 3]:
+ output[0] = "Invalid plugin status %d. Output is: %s" % (state,
output[0])
+ state = 3
if len(parts) > 1:
perfdata = parts[1].strip().split()
else: