Module: check_mk
Branch: master
Commit: 237db7d923642ba8b6e7cd04aa8a39f11f02f409
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=237db7d923642b…
Author: Andreas Boesl <ab(a)mathias-kettner.de>
Date: Thu Jul 23 14:03:54 2015 +0200
#2411 Check check_mkevents: Now able to look for events matching the host alias
The WATO rule <i>Check event state in Event Console</i> got an update.
You can now also configure if the host alias should be used when looking for
events in the event console.
---
.werks/2411 | 12 ++++++++
ChangeLog | 1 +
mkeventd/checks/check_mkevents | 6 +++-
mkeventd/web/plugins/wato/mkeventd.py | 49 +++++++++++++++++++++++----------
4 files changed, 52 insertions(+), 16 deletions(-)
diff --git a/.werks/2411 b/.werks/2411
new file mode 100644
index 0000000..8388a7d
--- /dev/null
+++ b/.werks/2411
@@ -0,0 +1,12 @@
+Title: Check check_mkevents: Now able to look for events matching the host alias
+Level: 1
+Component: ec
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437652597
+Class: feature
+
+The WATO rule <i>Check event state in Event Console</i> got an update.
+You can now also configure if the host alias should be used when looking for
+events in the event console.
+
diff --git a/ChangeLog b/ChangeLog
index f977c4a..b5e5a67 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -130,6 +130,7 @@
* 2370 FIX: Fix computation of "in downtime" and "acknownledged"
of hosts in BI aggregations...
Event Console:
+ * 2411 Check check_mkevents: Now able to look for events matching the host alias...
* 2322 FIX: mkeventd: MIBs are now only loaded if SNMP Traps translation is
activated...
* 2460 FIX: Slightly more robust SNMP trap translation...
diff --git a/mkeventd/checks/check_mkevents b/mkeventd/checks/check_mkevents
index baf8cd3..f754198 100644
--- a/mkeventd/checks/check_mkevents
+++ b/mkeventd/checks/check_mkevents
@@ -16,7 +16,11 @@ def check_mkevents_arguments(params):
if params.get("less_verbose"):
args += "-l "
- args += params.get("hostspec", "$HOSTADDRESS$")
+ hostspec = params.get("hostspec", "$HOSTADDRESS$")
+ if type(hostspec) == list:
+ hostspec = "/".join(hostspec)
+ args += hostspec
+
if "application" in params:
args += " " + quote_shell_string(params["application"])
return args
diff --git a/mkeventd/web/plugins/wato/mkeventd.py
b/mkeventd/web/plugins/wato/mkeventd.py
index 17d7036..2f73de6 100644
--- a/mkeventd/web/plugins/wato/mkeventd.py
+++ b/mkeventd/web/plugins/wato/mkeventd.py
@@ -2550,6 +2550,18 @@ register_rulegroup("eventconsole",
group = "eventconsole"
+def convert_mkevents_hostspec(value):
+ if type(value) == list:
+ return value
+ elif value == "$HOSTADDRESS$":
+ return [ "$HOSTADDRESS$" ]
+ elif value == "$HOSTNAME$":
+ return [ "$HOSTNAME$" ]
+ elif value == "$HOSTNAME$/$HOSTADDRESS$":
+ return [ "$HOSTNAME$", "$HOSTADDRESS$" ]
+ else: # custom
+ return value
+
register_rule(
group,
"active_checks:mkevents",
@@ -2561,21 +2573,28 @@ register_rule(
"of the worst open event for that host."),
elements = [
( "hostspec",
- OptionalDropdownChoice(
- title = _("Host specification"),
- help = _("When quering the event status you can either use the
monitoring "
- "host name, the IP address or a custom host name for referring to
a "
- "host. This is needed in cases where the event source (syslog,
snmptrapd) "
- "do not send a host name that matches the monitoring host
name."),
- choices = [
- ( '$HOSTNAME$', _("Monitoring host
name") ),
- ( '$HOSTADDRESS$', _("Host IP address" )
),
- ( '$HOSTNAME$/$HOSTADDRESS$', _("Try both host name and
IP address" ) ),
- ],
- otherlabel = _("Specify explicitly"),
- explicit = TextAscii(allow_empty = False, attrencode = True),
- default_value = '$HOSTNAME$/$HOSTADDRESS$',
- )
+ Transform(
+ Alternative(
+ title = _("Host specification"),
+ elements = [
+ ListChoice(
+ title = _("Check with the hosts"),
+ choices = [
+ ( '$HOSTNAME$', _("Hostname")
),
+ ( '$HOSTADDRESS$', _("IP address"
) ),
+ ( '$HOSTALIAS$', _("Alias" ) ),
+ ]
+ ),
+ TextAscii(allow_empty = False, attrencode = True, title =
"Specify host explicitely"),
+ ],
+ default_value = [ '$HOSTNAME$', '$HOSTADDRESS$'
]
+ ),
+ help = _("When quering the event status you can either use the
monitoring "
+ "host name, the IP address, the host alias or a custom host
name for referring to a "
+ "host. This is needed in cases where the event source
(syslog, snmptrapd) "
+ "do not send a host name that matches the monitoring host
name."),
+ forth = convert_mkevents_hostspec
+ )
),
( "item",
TextAscii(