Module: check_mk
Branch: master
Commit: 51a0270ce6174e2d8508007faeacccc052586a83
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=51a0270ce6174e…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Sep 7 09:38:31 2018 +0200
6490 fileinfo.groups: Shows all matching files and marks files which exceed the
thresholds
Change-Id: I8b1aa0c8caff7704509914bae2630f4f10d6f33e
---
.werks/6490 | 10 ++++++++++
checks/fileinfo | 17 +++++++++--------
2 files changed, 19 insertions(+), 8 deletions(-)
diff --git a/.werks/6490 b/.werks/6490
new file mode 100644
index 0000000..b021153
--- /dev/null
+++ b/.werks/6490
@@ -0,0 +1,10 @@
+Title: fileinfo.groups: Shows all matching files and marks files which exceed the
thresholds
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1536305849
+Class: feature
+
+
diff --git a/checks/fileinfo b/checks/fileinfo
index 7120962..414fded 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -267,7 +267,7 @@ def check_fileinfo_groups(item, params, info):
include_patterns = set()
exclude_patterns = set()
files_not_readable = set()
- files_passes_thresholds = set()
+ files_passes_thresholds = {}
try:
reftime = int(info[0][0])
@@ -333,9 +333,9 @@ def check_fileinfo_groups(item, params, info):
("size", size),
]:
for state, _, __, ___ in _fileinfo_check_file(value, params, key):
- if not state:
- continue
- files_passes_thresholds.add((filename, size, age))
+ files_passes_thresholds.setdefault(filename, {
+ "size": size, "age": age, "states":
[]
+ })["states"].append(state)
if age_oldest is None:
age_oldest = 0
@@ -363,10 +363,11 @@ def check_fileinfo_groups(item, params, info):
if any(exclude_patterns):
long_output.append("Exclude patterns: %s" % ",
".join(exclude_patterns))
- for filename, size, age in files_passes_thresholds:
- long_output.append("[%s] Age: %s, Size: %s" % \
- (filename, get_age_human_readable(age),
- get_filesize_human_readable(size)))
+ for filename, attrs in files_passes_thresholds.iteritems():
+ long_output.append("[%s] Age: %s, Size: %s%s" % \
+ (filename, get_age_human_readable(attrs["age"]),
+ get_filesize_human_readable(attrs["size"]),
+ state_markers[max(attrs["states"])]))
if long_output:
yield 0, "\n%s" % "\n".join(long_output)