Module: check_mk
Branch: master
Commit: 53478b254194a6cb1ebba8f03c4f9a8a17afb1e7
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=53478b254194a6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Sep 26 10:12:59 2013 +0200
logwatch.ec: show logfiles from that we forwarded messages
---
ChangeLog | 1 +
checks/logwatch | 9 ++++++++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git a/ChangeLog b/ChangeLog
index f0f3611..b07771c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -99,6 +99,7 @@
* vSphere checks: secret is not shown to the user via WATO anymore
* WATO rule to check state of physical switch (currently used by etherbox check)
* cisco_wlc: Allows to configure handling of missing AP
+ * logwatch.ec: show logfiles from that we forwarded messages
* FIX: blade_blades: Fixed output of "(UNKNOWN)" even if state is OK
* FIX: apache_status: fix exception if parameter is None
* FIX: hr_mem: handle virtual memory correct on some devices
diff --git a/checks/logwatch b/checks/logwatch
index 1669bf2..c3d10e5 100644
--- a/checks/logwatch
+++ b/checks/logwatch
@@ -467,11 +467,13 @@ def check_logwatch_ec(item, params, info):
facility = params.get('facility', 17) << 3 # default to
"local1"
messages = []
cur_time = syslog_time()
+ forwarded_logfiles = set([])
for logfile, lines in logs.items():
for line in lines:
msg = '<%d>' % (facility + logwatch_to_prio(line[0]),)
msg += '%s %s %s: %s' % (cur_time, g_hostname, logfile, line[2:])
messages.append(msg)
+ forwarded_logfiles.add(logfile)
# 4. send lines to event console
# a) local in same omd site
@@ -520,7 +522,12 @@ def check_logwatch_ec(item, params, info):
file('%s/%s' % (spool_path, file_name),
'w').write('\n'.join(messages) + '\n')
os.rename('%s/%s' % (spool_path, file_name), '%s/%s' %
(spool_path, file_name[1:]))
- return (0, 'Forwarded %d messages to event console' % num_messages,
[('messages', num_messages)])
+ if forwarded_logfiles:
+ logfile_info = " from " +
",".join(list(forwarded_logfiles))
+ else:
+ logfile_info = ""
+ return (0, 'Forwarded %d messages%s to event console' % (
+ num_messages, logfile_info ), [('messages', num_messages)])
except Exception, e:
return (2, 'Unable to forward messages to event console (%s). Lost %d
messages.' %
(e, num_messages))