Module: check_mk
Branch: master
Commit: cefbefd75b85e157cd921eaf1d2a45ca4b814673
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=cefbefd75b85e1…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Jun 26 17:13:57 2012 +0200
mk_logwatch on Linux: new options regex and iregex for file selection
---
ChangeLog | 1 +
agents/plugins/mk_logwatch | 8 ++++++++
2 files changed, 9 insertions(+), 0 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 474f9db..57a6075 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -19,6 +19,7 @@
database - and using uncached direct SQL output.
* ORACLE agent: fix handling of EXCLUDE, new variable ONLY_SIDS
for explicitely listing SIDs to monitor
+ * mk_logwatch on Linux: new options regex and iregex for file selection
Multisite:
* Show number of rows and number of selected rows in header line
diff --git a/agents/plugins/mk_logwatch b/agents/plugins/mk_logwatch
index e4d86e3..beb19e9 100755
--- a/agents/plugins/mk_logwatch
+++ b/agents/plugins/mk_logwatch
@@ -240,6 +240,8 @@ for filenames, patterns in config:
# Initialize options with default values
opt_maxlines = None
opt_maxtime = None
+ opt_regex = None
+ opt_iregex = None
opt_overflow = 'C'
opt_overflow_level = 2
try:
@@ -254,6 +256,10 @@ for filenames, patterns in config:
raise Exception("Invalid value %s for overflow. Allowed are C, I
and W" % value)
opt_overflow = value
opt_overflow_level = {'C':2, 'W':1,
'I':0}[value]
+ elif key == 'regex':
+ opt_regex = re.compile(value)
+ elif key == 'iregex':
+ opt_iregex = re.compile(value, re.I)
else:
raise Exception("Invalid option %s" % key)
except Exception, e:
@@ -265,6 +271,8 @@ for filenames, patterns in config:
if '=' in glob:
continue
logfiles = [ l.strip() for l in os.popen("ls %s 2>/dev/null" %
glob).readlines() ]
+ if opt_regex:
+ logfiles = [ f for f in logfiles if opt_regex.search(f) ]
if len(logfiles) == 0:
print '[[[%s:missing]]]' % glob
else: