Module: check_mk
Branch: master
Commit: 9ee8d6ff8c52325b884d533076cba667a24d5845
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9ee8d6ff8c5232…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue Jul 24 09:20:05 2018 +0200
6317 FIX fileinfo, fileinfo.groups: Prevent crash of all fileinfo services if one line
fails
Change-Id: Ifa6fa12886d055de78e6adb3a67e989096c02a59
---
.werks/6317 | 11 +++++++++++
checks/fileinfo | 24 +++++++++++++-----------
2 files changed, 24 insertions(+), 11 deletions(-)
diff --git a/.werks/6317 b/.werks/6317
new file mode 100644
index 0000000..95e47a1
--- /dev/null
+++ b/.werks/6317
@@ -0,0 +1,11 @@
+Title: fileinfo, fileinfo.groups: Prevent crash of all fileinfo services if one line
fails
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.6.0i1
+Date: 1532351797
+
+
diff --git a/checks/fileinfo b/checks/fileinfo
index f30055f..030e0c9 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -169,14 +169,16 @@ def check_fileinfo(item, params, info):
outof_range_txt = fileinfo_check_timeranges(params)
in_timerange = outof_range_txt == ""
- reftime = None
check_definition = False
state_missing = params.get("state_missing", 3)
- for line in info:
- if len(line) == 1:
- reftime = int(line[0])
- continue
+ try:
+ reftime = int(info[0][0])
+ except (IndexError, ValueError):
+ return 3, "Missing reference timestamp"
+
+ # Start counting values on all files
+ for line in info[1:]:
if item == line[0]:
if line[1] == "missing":
continue
@@ -222,7 +224,6 @@ def check_fileinfo_groups(item, params, info):
return
outof_range_txt = fileinfo_check_timeranges(params)
- reftime = None
count_all = 0
age_oldest = None
age_newest = 0
@@ -234,12 +235,13 @@ def check_fileinfo_groups(item, params, info):
exclude_patterns = set()
files_not_readable = set()
- # Start counting values on all files
- for line in info:
- if len(line) == 1:
- reftime = int(line[0])
- continue
+ try:
+ reftime = int(info[0][0])
+ except (IndexError, ValueError):
+ return 3, "Missing reference timestamp"
+ # Start counting values on all files
+ for line in info[1:]:
# Old format does not support '%s' in group name
group_patterns = set(params.get('precompiled_patterns', []))
for entry in params.get('group_patterns', []):