Module: check_mk
Branch: master
Commit: b361fb7c7154565b93480b1b2b4ca82ce41bb5a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b361fb7c715456…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue Nov 12 10:58:54 2013 +0100
fileinfo.groups: Added minimum/maximum file size parameters
It is now possible to configure thresholds for the minimum and maximum
file size of all files found with a file grouping pattern.
---
.werks/208 | 9 +++++++++
ChangeLog | 1 +
checkman/fileinfo.groups | 16 +++++++++++++++
checks/fileinfo | 26 +++++++++++++++++++-----
web/plugins/wato/check_parameters.py | 36 ++++++++++++++++++++++++++++++++++
5 files changed, 83 insertions(+), 5 deletions(-)
diff --git a/.werks/208 b/.werks/208
new file mode 100644
index 0000000..f1eb56b
--- /dev/null
+++ b/.werks/208
@@ -0,0 +1,9 @@
+Title: fileinfo.groups: Added minimum/maximum file size parameters
+Level: 1
+Component: checks
+Version: 1.2.3i7
+Date: 1384250251
+Class: feature
+
+It is now possible to configure thresholds for the minimum and maximum
+file size of all files found with a file grouping pattern.
diff --git a/ChangeLog b/ChangeLog
index c68d710..e883fd5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,7 @@
* 0080 Added new checks for Brocade NetIron MLX switching / routing devices...
* 0091 apc_ats_output: new check for output measurements on APC ATS devices
* 0068 check_sql: support for mssql databases included
+ * 0208 fileinfo.groups: Added minimum/maximum file size parameters...
* 0024 FIX: cisco_wlc: removed configuration parameter ap_model
* 0065 FIX: veeam_client: check behaviour improved when backup is in progress
* 0066 FIX: veeam_jobs: check behaviour improved when backup is in progress
diff --git a/checkman/fileinfo.groups b/checkman/fileinfo.groups
index 5aa6d11..1c4eea8 100644
--- a/checkman/fileinfo.groups
+++ b/checkman/fileinfo.groups
@@ -37,6 +37,10 @@ examples:
"maxage_oldest": (100, 120),
"minage_newest": (10, 20),
"maxage_newest": (30, 40),
+ "minsize_largest": (2048, 1024),
+ "maxsize_largest": (2048, 1024),
+ "minsize_largest": (10240, 20480),
+ "maxsize_largest": (10240, 20480),
}, ALL_HOSTS, ["File group"]),
]
@@ -74,6 +78,18 @@ parameters (dict): This check uses dictionary based
{"maxage_newest"}: Pair of integers for the maximum file
age in seconds for the newest file found with file group pattern.
+ {"minsize_smallest"}: Pair of integers for the minimum file
+ size in bytes for the smallest file found with the file group pattern.
+
+ {"maxsize_smallest"}: Pair of integers for the maximum file
+ size in bytes for the smallest file found with the file group pattern.
+
+ {"minsize_largest"}: Pair of integers for the minimum file
+ size in bytes for the largest file found with the file group pattern.
+
+ {"maxsize_largest"}: Pair of integers for the maximum file
+ size in bytes for the largest file found with the file group pattern.
+
{"minsize"}: The minimum size for the aggregation of all files in bytes (pair
of
integers).
diff --git a/checks/fileinfo b/checks/fileinfo
index 5aa9008..023ff92 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -121,11 +121,20 @@ def check_fileinfo_groups(item, params, info):
age_oldest = None
age_newest = 0
size_all = 0
+ size_smallest = None
+ size_largest = 0
# Start counting all values
for line in info[1:]:
for pattern in params['precompiled_patterns']:
if fnmatch.fnmatch(line[0], pattern) and str(line[1]) != 'missing':
- size_all += int(line[1])
+ size = int(line[1])
+ size_all += size
+ if size_smallest == None:
+ size_smallest = size
+ else:
+ size_smallest = min(size_smallest, size)
+ size_largest = max(size_largest, size)
+
age = reftime - int(line[2])
if age_oldest == None: # very first match
age_oldest = age
@@ -133,6 +142,7 @@ def check_fileinfo_groups(item, params, info):
else:
age_oldest = max(age_oldest, age)
age_newest = min(age_newest, age)
+
count_all += 1
if age_oldest == None:
@@ -140,10 +150,16 @@ def check_fileinfo_groups(item, params, info):
# Start Checking
check_definition = [
- ("age_oldest", age_oldest, get_age_human_readable),
- ("age_newest", age_newest, get_age_human_readable),
- ("count", count_all, saveint),
- ("size", size_all, get_filesize_human_readable)]
+ ("age_oldest", age_oldest, get_age_human_readable),
+ ("age_newest", age_newest, get_age_human_readable),
+ ("count", count_all, saveint),
+ ("size", size_all, get_filesize_human_readable),
+ ]
+
+ if size_smallest is not None:
+ check_definition.append(("size_smallest", size_smallest,
get_filesize_human_readable))
+ if size_largest != 0:
+ check_definition.append(("size_largest", size_largest,
get_filesize_human_readable))
return fileinfo_check_function(check_definition, params)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 5260d38..e970bc3 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -969,6 +969,42 @@ register_check_parameters(
]
)
),
+ ("minsize_smallest",
+ Tuple(
+ title = _("Minimal size of smallest file"),
+ elements = [
+ Filesize(title = _("Warning if below")),
+ Filesize(title = _("Critical if below")),
+ ]
+ )
+ ),
+ ("maxsize_smallest",
+ Tuple(
+ title = _("Maximal size of smallest file"),
+ elements = [
+ Filesize(title = _("Warning if below")),
+ Filesize(title = _("Critical if below")),
+ ]
+ )
+ ),
+ ("minsize_largest",
+ Tuple(
+ title = _("Minimal size of largest file"),
+ elements = [
+ Filesize(title = _("Warning if above")),
+ Filesize(title = _("Critical if above")),
+ ]
+ )
+ ),
+ ("maxsize_largest",
+ Tuple(
+ title = _("Maximal size of largest file"),
+ elements = [
+ Filesize(title = _("Warning if above")),
+ Filesize(title = _("Critical if above")),
+ ]
+ )
+ ),
("minsize",
Tuple(
title = _("Minimal size"),