Module: check_mk
Branch: master
Commit: ca12dcf0eec63d352c3bbee26c95ffd471aace8c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ca12dcf0eec63d…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Oct 4 12:51:46 2012 +0200
Improved validation of inventory data reported by checks
---
ChangeLog | 3 +++
modules/check_mk.py | 13 ++++++++++++-
2 files changed, 15 insertions(+), 1 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 6268d32..cb6bcac 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,4 +1,7 @@
1.2.1i2:
+ Core:
+ * Improved validation of inventory data reported by checks
+
Event Console:
* Moved source of Event Console into Check_MK project
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 4491a82..7073f6e 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -2287,10 +2287,21 @@ def make_inventory(checkname, hostnamelist, check_only=False,
include_state=Fals
for entry in inventory:
state_type = "new" # assume new, change later if wrong
+
+ if not isinstance(entry, tuple):
+ sys.stderr.write("%s: Check %s returned invalid inventory data
(entry not a tuple): %s\n" %
+ (hostname,
checkname, repr(inventory)))
+ continue
+
if len(entry) == 2: # comment is now obsolete
item, paramstring = entry
else:
- item, comment, paramstring = entry
+ try:
+ item, comment, paramstring = entry
+ except ValueError:
+ sys.stderr.write("%s: Check %s returned invalid inventory
data (not 2 or 3 elements): %s\n" %
+ (hostname,
checkname, repr(inventory)))
+ continue
description = service_description(checkname, item)
# make sanity check