Module: check_mk
Branch: master
Commit: 094b264a622d85667c0c323381ffb85e63e875a7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=094b264a622d85…
Author: Götz Golla <gg(a)mathias-kettner.de>
Date: Tue Jan 21 17:47:29 2014 +0100
fileinfo.groups: file groups now allow exclude patterns as well
---
.werks/570 | 8 ++++++++
ChangeLog | 3 ++-
checkman/fileinfo.groups | 27 +++++++++++++++++--------
checks/fileinfo | 13 +++++++-----
web/plugins/wato/check_parameters.py | 37 +++++++++++++++++++++-------------
5 files changed, 60 insertions(+), 28 deletions(-)
diff --git a/.werks/570 b/.werks/570
new file mode 100644
index 0000000..786f94d
--- /dev/null
+++ b/.werks/570
@@ -0,0 +1,8 @@
+Title: fileinfo.groups: file groups now allow exclude patterns as well
+Level: 1
+Component: checks
+Version: 1.2.5i1
+Date: 1390322713
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 367c754..dfbe039 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -55,6 +55,7 @@
* 0461 emcvnx_raidgroups.list_luns: New check for EMC VNX storage system...
* 0462 emcvnx_raidgroups.list_disks: New check for EMC VNX storage system...
* 0463 emcvnx_raidgroups.capacity, emcvnx_raidgroups.capacity_contiguous: New Checks
for EMC VNX Storage systems...
+ * 0570 fileinfo.groups: file groups now allow exclude patterns as well
* 0103 FIX: services: Fixed bug with service inventory defined in main.mk...
* 0299 FIX: borcade_mlx_fan: Prettified output, handling "other" state now
* 0300 FIX: cisco_fru_power: Trying not to inventorize not plugged in FRUs...
@@ -154,8 +155,8 @@
* 0425 FIX: Fix login loop bug in distributed environments with different auth
secrets
* 0117 FIX: Availability button is now visible for users without the right to edit
views
* 0431 FIX: LDAP: Fixed group syncrhonisation when nested group sync is enabled
- * 0569 FIX: recurring updates of serial numbers of disabled ldap users fixed...
* 0122 FIX: Multisite view editor not longer throwing a exception when loading views
from other users
+ * 0569 FIX: recurring updates of serial numbers of disabled ldap users fixed...
WATO:
* 0308 Multisite can now set rotation view permissions for NagVis...
diff --git a/checkman/fileinfo.groups b/checkman/fileinfo.groups
index 1c4eea8..04d3b03 100644
--- a/checkman/fileinfo.groups
+++ b/checkman/fileinfo.groups
@@ -5,28 +5,39 @@ license: GPL
distribution: check_mk
description:
This check monitors the size, age and the count of a group of files
- in the target host's filesystem.
- You can set lower and upper
+ in the target host's filesystem. You can set lower and upper
limits for each: size of files, age of oldest, the newest file
and for the total count of files.
- This check needs some configuration in the agent,
- as the agent needs to know the information about
- which files need to be sent.
+ This check needs some configuration in the agent, as the agent needs to
+ know the information about which files need to be sent. Please refer to
+ fileinfos manpage for information about setting up the agent.
- Please refer to fileinfos manpage for information
- about setting up the agent
+ The check also needs a configured file grouping pattern. File grouping
+ patterns combine a simple pattern based on {*} and {?} to join a subset
+ of the file names send by the agent into a file group. In addition an
+ {exclude} pattern may be define to exclude certain filenames.
+ The name of the file group is referenced in the check configuration
+ as the item.
item:
- Configured name of the filesize group
+ Configured name of the file group
examples:
+# old syntax of file group patterns, still valid
fileinfo_groups = [
([("Auth_group",r"/var/log/auth*")], ALL_HOSTS),
([("Message_group", r"/var/log/messages*")], ['test2'],
ALL_HOSTS),
]
+# new syntax of file group patterns, including exclude pattern
+ fileinfo_groups = [
+ ([("Auth_group",
("/var/log/auth*","/var/log/*.debug"))], ALL_HOSTS),
+ ([("Message_group", ("/var/log/messages*",""))],
['test2'], ALL_HOSTS),
+ ]
+
+# syntax of check
check_parameters = [
({
"minsize": (200.0, 300.0),
diff --git a/checks/fileinfo b/checks/fileinfo
index df28a08..7907fdf 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -65,7 +65,10 @@ def fileinfo_groups_of_file(check_filename):
groups = []
for line in host_extra_conf(g_hostname, fileinfo_groups):
for group_name, pattern in line:
- if fnmatch.fnmatch(check_filename, pattern):
+ if type(pattern) == str:
+ pattern = ( pattern, '' )
+ if fnmatch.fnmatch(check_filename, pattern[0]) \
+ and not fnmatch.fnmatch(check_filename, pattern[1]):
groups.append(group_name)
return groups
@@ -94,14 +97,13 @@ def check_fileinfo(item, params, info):
# Constructs simple list of patterns and makes them available for the check
def fileinfo_groups_precompile(hostname, item, params):
patterns = []
-
for line in host_extra_conf(hostname, fileinfo_groups):
for group_name, pattern in line:
if group_name == item:
+ if type(pattern) == str:
+ pattern = ( pattern, '' )
patterns.append(pattern)
-
params['precompiled_patterns'] = patterns
-
return params
def check_fileinfo_groups(item, params, info):
@@ -126,7 +128,8 @@ def check_fileinfo_groups(item, params, info):
# 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':
+ if fnmatch.fnmatch(line[0], pattern[0]) and str(line[1]) != 'missing'
\
+ and not fnmatch.fnmatch(line[0], pattern[1]):
size = int(line[1])
size_all += size
if size_smallest == None:
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index a54a578..5ee83ba 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -899,6 +899,7 @@ register_rule(group + '/' + subgroup_storage,
),
match = 'all',
)
+
register_rule(group + '/' + subgroup_storage,
varname = "fileinfo_groups",
title = _('File Grouping Patterns'),
@@ -915,20 +916,28 @@ register_rule(group + '/' + subgroup_storage,
'of single services for each file. This rule also applies when
'
'you use manually configured checks instead of inventorized
ones.'),
valuespec = ListOf(
- Tuple(
- help = _("This defines one file grouping pattern"),
- show_titles = True,
- orientation = "horizontal",
- elements = [
- TextAscii(
- title = _("Name of group"),
- ),
- TextAscii(
- title = _("File pattern (using * and ?)"),
- ),
- ]
- ),
- add_label = _("Add pattern"),
+ Tuple(
+ help = _("This defines one file grouping pattern"),
+ show_titles = True,
+ orientation = "horizontal",
+ elements = [
+ TextAscii(
+ title = _("Name of group"),
+ ),
+ Transform(
+ Tuple(
+ show_titles = True,
+ orientation = "vertical",
+ elements = [
+ TextAscii(title = _("Include Pattern")),
+ TextAscii(title = _("Exclude Pattern"))
+ ],
+ ),
+ forth = lambda params: type(params) == str and ( params, '' )
or params
+ ),
+ ],
+ ),
+ add_label = _("Add pattern group"),
),
match = 'all',
)