Module: check_mk
Branch: master
Commit: c264234db316f6d9d8cf8b46961efb6835b4ad99
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=c264234db316f6…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Oct 26 09:25:24 2012 +0200
check_mkevents outputs last worst line in service output
---
ChangeLog | 1 +
mkeventd/lib/check_mkevents | 11 +++++++----
2 files changed, 8 insertions(+), 4 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index c635862..82270c7 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -12,6 +12,7 @@
* FIX: rule simulator ("Try out") now handles cancelling rules correctly
* New global option for enabling log entries for rule hits (debugging)
* New icon linking to event views for the event services
+ * check_mkevents outputs last worst line in service output
Multisite:
* Enable automation login with _username= and _secret=, while
diff --git a/mkeventd/lib/check_mkevents b/mkeventd/lib/check_mkevents
index 6f2da5a..9d93fce 100755
--- a/mkeventd/lib/check_mkevents
+++ b/mkeventd/lib/check_mkevents
@@ -69,6 +69,7 @@ q += "Filter: event_phase in open ack\n"
response = query(q, remote_host)
headers = response[0]
worst_state = 0
+worst_row = None
count = 0
unhandled = 0
for line in response[1:]:
@@ -77,8 +78,10 @@ for line in response[1:]:
if s == 3:
if worst_state < 2:
worst_state = 3
- else:
- worst_state = max(worst_state, s)
+ worst_row = row
+ elif s >= worst_state:
+ worst_state = s
+ worst_row = row
count += 1
if row["event_phase"] == 'open':
unhandled += 1
@@ -96,8 +99,8 @@ elif count == 0:
sys.stdout.write("OK - no events for %s\n" % host_name)
else:
sys.stdout.write(nagios_state_names[worst_state] + \
- " - %d events (%d unacknowledged), worst state is %s\n" % \
- (count, unhandled, nagios_state_names[worst_state]))
+ " - %d events (%d unacknowledged), worst state is %s (Last line:
%s)\n" % \
+ (count, unhandled, nagios_state_names[worst_state],
worst_row['event_text'].encode('utf-8')))
sys.exit(worst_state)