Module: check_mk
Branch: master
Commit: 0f9c3ac06729226b9bf6b9c2805650a94378a2b2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0f9c3ac0672922…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Mon Apr 28 15:18:16 2014 +0200
Check event state: New option "Less Verbose Output"
If enabled the check reports less information in its output.<br>
You will see no information regarding the worst state or unacknowledged events.<br>
For example a default output without this option <br>
<tt>WARN - 1 events (1 unacknowledged), worst state is WARN (Last line: Incomplete
Content)</tt><br>
Output with less verbosity<br>
<tt>WARN - 1 events (Worst line: Incomplete Content)</tt>
---
.werks/908 | 14 ++++++++++++++
ChangeLog | 1 +
mkeventd/checks/check_mkevents | 4 ++++
mkeventd/lib/check_mkevents | 24 ++++++++++++++++++------
mkeventd/web/plugins/wato/mkeventd.py | 15 ++++++++++++++-
5 files changed, 51 insertions(+), 7 deletions(-)
diff --git a/.werks/908 b/.werks/908
new file mode 100644
index 0000000..357662c
--- /dev/null
+++ b/.werks/908
@@ -0,0 +1,14 @@
+Title: Check event state: New option "Less Verbose Output"
+Level: 1
+Component: wato
+Version: 1.2.5i3
+Date: 1398690971
+Class: feature
+
+If enabled the check reports less information in its output.<br>
+You will see no information regarding the worst state or unacknowledged
events.<br>
+ For example a default output without this option <br>
+<tt>WARN - 1 events (1 unacknowledged), worst state is WARN (Last line: Incomplete
Content)</tt><br>
+Output with less verbosity<br>
+<tt>WARN - 1 events (Worst line: Incomplete Content)</tt>
+
diff --git a/ChangeLog b/ChangeLog
index 40d3f51..e4b6a1e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -68,6 +68,7 @@
* 0784 Improved security of WATO bulk inventory by using transaction ids
* 0880 Added support for 389 Directory Server to LDAP connector
* 0607 online help text for host creation in WATO now also explains hostname caching
+ * 0908 Check event state: New option "Less Verbose Output"...
* 0781 FIX: host diag page: fixed problem with update of diagnose subwindows...
* 0904 FIX: Fixed exception in host parameter overview...
diff --git a/mkeventd/checks/check_mkevents b/mkeventd/checks/check_mkevents
index aa9a3f3..b8575b2 100644
--- a/mkeventd/checks/check_mkevents
+++ b/mkeventd/checks/check_mkevents
@@ -11,6 +11,10 @@ def check_mkevents_arguments(params):
args += "-H %s " % quote_shell_string(remote)
if params.get("ignore_acknowledged"):
args += "-a "
+
+ if params.get("less_verbose"):
+ args += "-l "
+
args += params.get("hostspec", "$HOSTADDRESS$")
if "application" in params:
args += " " + quote_shell_string(params["application"])
diff --git a/mkeventd/lib/check_mkevents b/mkeventd/lib/check_mkevents
index 563b779..8d745d9 100755
--- a/mkeventd/lib/check_mkevents
+++ b/mkeventd/lib/check_mkevents
@@ -56,6 +56,12 @@ try:
except:
opt_ignore_acknowledged = False
+ try:
+ del sys.argv[sys.argv.index('-l')]
+ opt_less_verbose = True
+ except:
+ opt_less_verbose = False
+
if sys.argv[1] == '-H':
remote_host = sys.argv[2]
del sys.argv[1:3]
@@ -65,8 +71,9 @@ try:
else:
application = None
except:
- sys.stdout.write("Usage: check_mkevents [-H (REMOTE:PORT|/path/to/unix/socket)]
[-a] HOST [APPLICATION]\n")
+ sys.stdout.write("Usage: check_mkevents [-H (REMOTE:PORT|/path/to/unix/socket)]
[-a] [-l] HOST [APPLICATION]\n")
sys.stdout.write("\n -a do not take into account acknowledged
events.\n")
+ sys.stdout.write("\n -l less verbose output.\n")
sys.stdout.write("\n")
sys.exit(3)
@@ -112,11 +119,16 @@ if count == 0 and application:
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)" % (count, unhandled))
- if worst_row:
- sys.stdout.write(", worst state is %s (Last line: %s)" % \
- (nagios_state_names[worst_state],
worst_row['event_text'].encode('utf-8')))
+ if opt_less_verbose:
+ sys.stdout.write(nagios_state_names[worst_state] + " - %d events" %
(count))
+ if worst_row:
+ sys.stdout.write(" (Worst line: %s)" %
(worst_row['event_text'].encode('utf-8')))
+ else:
+ sys.stdout.write(nagios_state_names[worst_state] + \
+ " - %d events (%d unacknowledged)" % (count, unhandled))
+ if worst_row:
+ sys.stdout.write(", worst state is %s (Last line: %s)" % \
+ (nagios_state_names[worst_state],
worst_row['event_text'].encode('utf-8')))
sys.stdout.write("\n")
sys.exit(worst_state)
diff --git a/mkeventd/web/plugins/wato/mkeventd.py
b/mkeventd/web/plugins/wato/mkeventd.py
index 0366a9e..b8ca802 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -1938,6 +1938,19 @@ register_rule(
totext = _("acknowledged events will not be honored"),
)
),
+ ( "less_verbose",
+ FixedValue(
+ True,
+ title = _("Less Verbose Output"),
+ help = _("If enabled the check reports less information in its
output.<br>"
+ "You will see no information regarding the worst state or
unacknowledged events.<br>"
+ " For example a default output without this option
<br>"
+ "<tt>WARN - 1 events (1 unacknowledged), worst
state is WARN (Last line: Incomplete Content)</tt><br>"
+ "Output with less verbosity<br>"
+ "<tt>WARN - 1 events (Worst line: Incomplete
Content)</tt><br>"
+ ),
+ )
+ ),
( "remote",
Alternative(
title = _("Access to the Event Console"),
@@ -1976,7 +1989,7 @@ register_rule(
)
),
],
- optional_keys = [ "application", "remote",
"ignore_acknowledged", "item" ],
+ optional_keys = [ "application", "remote",
"ignore_acknowledged", "less_verbose", "item" ],
),
match = 'all',
)