Module: check_mk
Branch: master
Commit: a4a99b22dcf1e9d30b0d3ae9788495b6facb67ae
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a4a99b22dcf1e9…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Fri Apr 22 15:15:24 2016 +0200
3473: fileinfo.groups: the include patterns now also support the pattern YESTERDAY, in
addition to DATE
---
.werks/3473 | 11 +++++++++++
ChangeLog | 1 +
checks/fileinfo | 18 +++++++++++-------
web/plugins/wato/check_parameters.py | 10 +++++++++-
4 files changed, 32 insertions(+), 8 deletions(-)
diff --git a/.werks/3473 b/.werks/3473
new file mode 100644
index 0000000..af09ac1
--- /dev/null
+++ b/.werks/3473
@@ -0,0 +1,11 @@
+Title: fileinfo.groups: the include patterns now also support the pattern YESTERDAY, in
addition to DATE
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.9i1
+Date: 1461330445
+Class: feature
+
+You can now specifiy include patterns with the following syntax<br>
+<i>/var/tmp/backups/$YESTERDAY:%Y%m%d$.txt</i>.<br>This includes files
of yesterdays date
+with the given date format spec. The YESTERDAY format should also consider daylight
saving time.
diff --git a/ChangeLog b/ChangeLog
index eb8226c..04c6189 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -67,6 +67,7 @@
NOTE: Please refer to the migration notes!
* 3414 New declarator BINARY(...) for OIDs - returning a list of byte values...
* 3423 papouch_th2e_sensors, papouch_th2e_sensors.dewpoint,
papouch_th2e_sensors.humidity: new checks which monitor the temperature, dew point and
humidity sensors of Papouch TH2E devices
+ * 3473 fileinfo.groups: the include patterns now also support the pattern YESTERDAY,
in addition to DATE...
* 3073 FIX: windows agent: relative paths to mrpe scripts are now treated as relative
to the agent installation directory...
* 3061 FIX: mk_jolokia: Fixed debugging of the agent plugin
* 3074 FIX: windows agent: fixed incorrect values for 32-bit performance counters
diff --git a/checks/fileinfo b/checks/fileinfo
index 51c46a4..b5580c9 100644
--- a/checks/fileinfo
+++ b/checks/fileinfo
@@ -60,13 +60,17 @@ def inventory_fileinfo(info, case):
inventory.append((group, {}))
return inventory
-def fileinfo_process_date(pattern,reftime):
- disect = re.match('(/.*)\$DATE:((?:%\w.?){1,})\$(.*)',pattern)
- if disect:
- prefix = disect.group(1)
- datepattern = time.strftime(disect.group(2),time.localtime(reftime))
- postfix = disect.group(3)
- pattern = prefix+datepattern+postfix
+def fileinfo_process_date(pattern, reftime):
+ for what, the_time in [ ("DATE", reftime), ("YESTERDAY", reftime
- 86400) ]:
+ the_regex = '(/.*)\$%s:((?:%%\w.?){1,})\$(.*)' % what
+ disect = re.match(the_regex, pattern)
+ if disect:
+ prefix = disect.group(1)
+ datepattern = time.strftime(disect.group(2),time.localtime(the_time))
+ postfix = disect.group(3)
+ pattern = prefix+datepattern+postfix
+ return pattern
+
return pattern
def fileinfo_groups_of_file(check_filename,reftime):
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index f2db844..b79f26e 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2654,7 +2654,15 @@ register_rule(group + '/' + subgroup_storage,
'<tt>/var/log/apache/*.log</tt>. For files contained in
a group '
'the inventory will automatically create a group service instead
'
'of single services for each file. This rule also applies when
'
- 'you use manually configured checks instead of inventorized
ones.'),
+ 'you use manually configured checks instead of inventorized ones.
'
+ 'Furthermore, the current time/date in a configurable format '
+ 'may be included in the include pattern. The syntax is as follows:
'
+ '$DATE:format-spec$ or $YESTERDAY:format-spec$, where format-spec
'
+ 'is a list of time format directives of the unix date command.
'
+ 'Example: $DATE:%Y%m%d$ is todays date, e.g. 20140127. A pattern
'
+ 'of /var/tmp/backups/$DATE:%Y%m%d$.txt would search for .txt files
'
+ 'with todays date as name in the directory /var/tmp/backups.
'
+ 'The YESTERDAY syntax simply subtracts one day from the reference
time.'),
valuespec = ListOf(
Tuple(
help = _("This defines one file grouping pattern"),