Module: check_mk
Branch: master
Commit: bfa9cce34cde2c7aaa97c37d13e2cfeff24d8903
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bfa9cce34cde2c…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 24 15:08:20 2015 +0200
#2477 FIX SNMP: Fixed exception when processing specific SNMP data with missing columns
When processing SNMP tables which have a) end OIDs which are not increasing and
b) some columns are missing some indexes, this could lead into mixed up rows and
even exceptions during processing of this data.
This occured e.g. on Bintec RLX125000 devices where the interfaces OIDs were
not reported in numerical order by their end OIDs as one would expect in SNMP.
---
.werks/2477 | 14 +++++++
ChangeLog | 1 +
modules/snmp.py | 116 ++++++++++++++++++++++++++++++++-----------------------
3 files changed, 82 insertions(+), 49 deletions(-)
diff --git a/.werks/2477 b/.werks/2477
new file mode 100644
index 0000000..42ca28c
--- /dev/null
+++ b/.werks/2477
@@ -0,0 +1,14 @@
+Title: SNMP: Fixed exception when processing specific SNMP data with missing columns
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437743112
+Class: fix
+
+When processing SNMP tables which have a) end OIDs which are not increasing and
+b) some columns are missing some indexes, this could lead into mixed up rows and
+even exceptions during processing of this data.
+
+This occured e.g. on Bintec RLX125000 devices where the interfaces OIDs were
+not reported in numerical order by their end OIDs as one would expect in SNMP.
diff --git a/ChangeLog b/ChangeLog
index e52d97e..d0d64b6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -75,6 +75,7 @@
* 2377 FIX: cpu.loads: Fix output of reference for predition (was scaled wrongly by number of cores)
* 2473 FIX: cisco_asa_failover: Reworked check to reflect expected primary/secondary states of devices...
* 2476 FIX: check_bi_aggr: Fixed exception when authentication is enabled
+ * 2477 FIX: SNMP: Fixed exception when processing specific SNMP data with missing columns...
Multisite:
* 2385 SEC: Fixed possible reflected XSS on all GUI pages where users can produce unhandled exceptions...
diff --git a/modules/snmp.py b/modules/snmp.py
index 4e1231c..ad097a6 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -90,6 +90,10 @@ def oid_to_intlist(oid):
def cmp_oids(o1, o2):
return cmp(oid_to_intlist(o1), oid_to_intlist(o2))
+def cmp_oid_pairs(pair1, pair2):
+ return cmp(oid_to_intlist(pair1[0].lstrip('.')),
+ oid_to_intlist(pair2[0].lstrip('.')))
+
def snmpv3_contexts_of_host(hostname):
return host_extra_conf(hostname, snmpv3_contexts)
@@ -209,70 +213,84 @@ def get_snmp_table(hostname, ip, check_type, oid_info):
# prepend suboid to first column
- if suboid and len(columns) > 0:
+ if suboid and columns:
fetchoid, first_column = columns[0]
new_first_column = []
for o, val in first_column:
new_first_column.append((o, str(suboid) + "." + str(val)))
columns[0] = fetchoid, new_first_column
- # Swap X and Y axis of table (we want one list of columns per item)
# Here we have to deal with a nasty problem: Some brain-dead devices
# omit entries in some sub OIDs. This happens e.g. for CISCO 3650
# in the interfaces MIB with 64 bit counters. So we need to look at
# the OIDs and watch out for gaps we need to fill with dummy values.
+ new_columns = sanitize_snmp_table_columns(columns)
- # First compute the complete list of end-oids appearing in the output
- # by looping all results and putting the endoids to a flat list
- endoids = []
- for fetchoid, column in columns:
- for o, value in column:
- endoid = extract_end_oid(fetchoid, o)
- if endoid not in endoids:
- endoids.append(endoid)
-
- # The list needs to be sorted to prevent problems when the first
- # column has missing values in the middle of the tree. Since we
- # work with strings of numerical components, a simple string sort
- # is not correct. 1.14 must come after 1.2!
- endoids.sort(cmp = cmp_oids)
-
- # Now fill gaps in columns where some endois are missing
- new_columns = []
- for fetchoid, column in columns:
- i = 0
- new_column = []
- # Loop all lines to fill holes in the middle of the list. All
- # columns check the following lines for the correct endoid. If
- # an endoid differs empty values are added until the hole is filled
- for o, value in column:
- eo = extract_end_oid(fetchoid, o)
- if len(column) != len(endoids):
- while i < len(endoids) and endoids[i] != eo:
- new_column.append("") # (beginoid + '.' +endoids[i], "" ) )
- i += 1
- new_column.append(value)
- i += 1
-
- # At the end check if trailing OIDs are missing
- while i < len(endoids):
- new_column.append("") # (beginoid + '.' +endoids[i], "") )
- i += 1
- new_columns.append(new_column)
- columns = new_columns
-
- # Now construct table by swapping X and Y
- new_info = []
- index = 0
- if len(columns) > 0:
- for item in columns[0]:
- new_info.append([ c[index] for c in columns ])
- index += 1
- info += new_info
+ info += construct_snmp_table_of_rows(new_columns)
return info
+def sanitize_snmp_table_columns(columns):
+ # First compute the complete list of end-oids appearing in the output
+ # by looping all results and putting the endoids to a flat list
+ endoids = []
+ for fetchoid, column in columns:
+ for o, value in column:
+ endoid = extract_end_oid(fetchoid, o)
+ if endoid not in endoids:
+ endoids.append(endoid)
+
+ # The list needs to be sorted to prevent problems when the first
+ # column has missing values in the middle of the tree. Since we
+ # work with strings of numerical components, a simple string sort
+ # is not correct. 1.14 must come after 1.2!
+ endoids.sort(cmp = cmp_oids)
+
+ # Now fill gaps in columns where some endois are missing
+ new_columns = []
+ for fetchoid, column in columns:
+ # It might happen that end OIDs are not ordered. Fix the OID sorting to make
+ # it comparable to the already sorted endoids list. Otherwise we would get
+ # some mixups when filling gaps
+ # FIXME: Performance? Maybe check whether or not endoids has changed anything and only sort in this case
+ column.sort(cmp = cmp_oid_pairs)
+
+ i = 0
+ new_column = []
+ # Loop all lines to fill holes in the middle of the list. All
+ # columns check the following lines for the correct endoid. If
+ # an endoid differs empty values are added until the hole is filled
+ for o, value in column:
+ eo = extract_end_oid(fetchoid, o)
+ if len(column) != len(endoids):
+ while i < len(endoids) and endoids[i] != eo:
+ new_column.append("") # (beginoid + '.' +endoids[i], "" ) )
+ i += 1
+ new_column.append(value)
+ i += 1
+
+ # At the end check if trailing OIDs are missing
+ while i < len(endoids):
+ new_column.append("") # (beginoid + '.' +endoids[i], "") )
+ i += 1
+ new_columns.append(new_column)
+
+ return new_columns
+
+
+def construct_snmp_table_of_rows(columns):
+ if not columns:
+ return []
+
+ # Now construct table by swapping X and Y.
+ new_info = []
+ for index in range(len(columns[0])):
+ row = [ c[index] for c in columns ]
+ new_info.append(row)
+ return new_info
+
+
# SNMP-Helper functions used in various checks
def check_snmp_misc(item, params, info):
Module: check_mk
Branch: master
Commit: 6b01cfc4a2ea1db3f2fd8047068176730dc707c6
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6b01cfc4a2ea1d…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 24 13:41:08 2015 +0200
#2484 Virtual Host Tree now allows adding levels of WATO folders
Amongst host tag groups you now also can add levels of your WATO
folder hierarchy. This allows the creation of even more flexible
virtual host tree, that combine information from the folder tree
and from the tag groups.
---
.werks/2484 | 12 ++++++
ChangeLog | 1 +
web/htdocs/wato.py | 1 +
web/plugins/sidebar/shipped.py | 56 ++++++++++++++++++++++++++--
web/plugins/visuals/wato.py | 10 ++++-
web/plugins/wato/check_mk_configuration.py | 9 ++++-
6 files changed, 84 insertions(+), 5 deletions(-)
diff --git a/.werks/2484 b/.werks/2484
new file mode 100644
index 0000000..e6ccb5d
--- /dev/null
+++ b/.werks/2484
@@ -0,0 +1,12 @@
+Title: Virtual Host Tree now allows adding levels of WATO folders
+Level: 2
+Component: multisite
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437737995
+Class: feature
+
+Amongst host tag groups you now also can add levels of your WATO
+folder hierarchy. This allows the creation of even more flexible
+virtual host tree, that combine information from the folder tree
+and from the tag groups.
diff --git a/ChangeLog b/ChangeLog
index b5e5a67..0ae269e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -86,6 +86,7 @@
* 1268 The Snapins "Folders" and "Tree of Folders" can now be used by users without wato permission
* 1270 Multsite site Hostfilters for views can now be negated
* 2471 User IDs are now allowed to contain special characters (like German umlauts)...
+ * 2484 Virtual Host Tree now allows adding levels of WATO folders...
* 2314 FIX: Availability: fixed exception when grouping by host or service group
* 2361 FIX: Fix exception for missing key 'title' in certain cases of older customized views
* 2379 FIX: Plugin-Output: Fixed handling of URLs within output of check_http...
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index d5b00b4..20b0f7f 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -19404,6 +19404,7 @@ def render_folder_path(the_folder = 0, link_to_last = False, keepvarnames = ["mo
html.write("</ul></div>\n")
+
def may_see_hosts():
return config.may("wato.use") and \
(config.may("wato.seeall") or config.may("wato.hosts"))
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index e9bb5ec..a1a7f6e 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -1276,7 +1276,7 @@ if defaults.omd_root:
def compute_tag_tree(taglist):
html.live.set_prepend_site(True)
query = "GET hosts\n" \
- "Columns: host_name state num_services_ok num_services_warn num_services_crit num_services_unknown custom_variables"
+ "Columns: host_name filename state num_services_ok num_services_warn num_services_crit num_services_unknown custom_variables"
hosts = html.live.query(query)
html.live.set_prepend_site(False)
hosts.sort()
@@ -1293,6 +1293,12 @@ def compute_tag_tree(taglist):
# No empty entry found -> get default (i.e. first entry)
return groupentries[0][:2]
+ def need_wato_folder(taglist):
+ for tag in taglist:
+ if tag.startswith("folder:"):
+ return True
+ return False
+
# Prepare list of host tag groups and topics
taggroups = {}
topics = {}
@@ -1307,7 +1313,15 @@ def compute_tag_tree(taglist):
taggroups[groupname] = group
tree = {}
- for site, host_name, state, num_ok, num_warn, num_crit, num_unknown, custom_variables in hosts:
+ for site, host_name, wato_folder, state, num_ok, num_warn, num_crit, num_unknown, custom_variables in hosts:
+ if need_wato_folder:
+ if wato_folder.startswith("/wato/"):
+ folder_path = wato_folder[6:-9]
+ folder_path_components = folder_path.split("/")
+ folder_titles = wato.get_folder_title_path(folder_path)[1:] # omit main folder
+ else:
+ folder_titles = []
+
# make state reflect the state of the services + host
have_svc_problems = False
if state:
@@ -1331,7 +1345,8 @@ def compute_tag_tree(taglist):
# Now go through the levels of the tree. Each level may either be
# - a tag group id, or
# - "topic:" plus the name of a tag topic. That topic should only contain
- # checkbox tags.
+ # checkbox tags, or:
+ # - "folder:3", where 3 is the folder level (starting at 1)
# The problem with the "topic" entries is, that a host may appear several
# times!
@@ -1352,6 +1367,16 @@ def compute_tag_tree(taglist):
if tag_value in tags:
new_current_branches.append(tree_entry.setdefault((tag_title, tag_value), {}))
+ elif tag.startswith("folder:"):
+ level = int(tag[7:])
+ if level <= len(folder_titles):
+ tag_title = folder_titles[level-1]
+ tag_value = "folder:%d:%s" % (level, folder_path_components[level-1])
+ else:
+ tag_title = _("Hosts in this folder")
+ tag_value = "folder:%d:" % level
+
+ new_current_branches.append(tree_entry.setdefault((tag_title, tag_value), {}))
else:
if tag not in taggroups:
continue # Configuration error. User deleted tag group after configuring his tree
@@ -1376,6 +1401,8 @@ def compute_tag_tree(taglist):
return tree
def tag_tree_worst_state(tree):
+ if not tree.values():
+ return 3
if "_state" in tree:
return tree["_state"]
else:
@@ -1385,6 +1412,7 @@ def tag_tree_worst_state(tree):
return 2
return max(states)
+
def tag_tree_has_svc_problems(tree):
if "_svc_problems" in tree:
return tree["_svc_problems"]
@@ -1394,6 +1422,7 @@ def tag_tree_has_svc_problems(tree):
return True
return False
+
def tag_tree_url(taggroups, taglist, viewname):
urlvars = [("view_name", viewname), ("filled_in", "filter")]
if viewname == "svcproblems":
@@ -1410,10 +1439,31 @@ def tag_tree_url(taggroups, taglist, viewname):
urlvars.append(("host_tag_%d_op" % nr, "is"))
urlvars.append(("host_tag_%d_val" % nr, tag))
break
+ elif group.startswith("folder:"):
+ continue # handled later
else:
urlvars.append(("host_tag_%d_grp" % nr, group))
urlvars.append(("host_tag_%d_op" % nr, "is"))
urlvars.append(("host_tag_%d_val" % nr, tag or ""))
+
+ folder_components = {}
+ for tag in taglist:
+ if tag.startswith("folder:"):
+ level_text, component = tag[7:].split(":")
+ level = int(level_text)
+ folder_components[level] = component
+
+ if folder_components:
+ wato_path = []
+ for i in range(max(folder_components.keys())):
+ level = i + 1
+ if level not in folder_components:
+ wato_path.append("*")
+ else:
+ wato_path.append(folder_components[level])
+
+ urlvars.append(("wato_folder", "/".join(wato_path)))
+
return html.makeuri_contextless(urlvars, "view.py")
def tag_tree_bullet(state, path, leaf):
diff --git a/web/plugins/visuals/wato.py b/web/plugins/visuals/wato.py
index f464219..3238f53 100644
--- a/web/plugins/visuals/wato.py
+++ b/web/plugins/visuals/wato.py
@@ -74,7 +74,15 @@ class FilterWatoFile(Filter):
self.check_wato_data_update()
current = html.var(self.name)
if current:
- return "Filter: host_filename ~ ^/wato/%s/\n" % current.replace("\n", "") # prevent insertions attack
+ path_regex = "^/wato/%s" % current.replace("\n", "") # prevent insertions attack
+ if current.endswith("/"): # Hosts directly in this folder
+ path_regex += "hosts.mk"
+ if "*" in current: # used by virtual host tree snapin
+ path_regex = path_regex.replace(".", "\\.").replace("*", ".*")
+ op = "~~"
+ else:
+ op = "~"
+ return "Filter: host_filename %s %s\n" % (op, path_regex)
else:
return ""
diff --git a/web/plugins/wato/check_mk_configuration.py b/web/plugins/wato/check_mk_configuration.py
index 5763922..bd41b80 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -278,6 +278,13 @@ def wato_host_tag_group_choices():
return choices
+def virtual_host_tree_choices():
+ return wato_host_tag_group_choices() + [
+ ( "folder:%d" % l, _("WATO Folder Level %d") % l)
+ for l in range(1, 7)
+ ]
+
+
register_configvar(group,
"virtual_host_trees",
ListOf(
@@ -290,7 +297,7 @@ register_configvar(group,
DualListChoice(
allow_empty = False,
custom_order = True,
- choices = wato_host_tag_group_choices,
+ choices = virtual_host_tree_choices,
)
]
),
Module: check_mk
Branch: master
Commit: 9eaa9c84cc0e62f225c5224ca6021f5266d226dc
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9eaa9c84cc0e62…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Jul 24 11:42:42 2015 +0200
Cleaned up: autocheck items are handled as unicode strings
---
modules/check_mk.py | 20 +-------------------
modules/discovery.py | 19 ++++++++++++++++++-
2 files changed, 19 insertions(+), 20 deletions(-)
diff --git a/modules/check_mk.py b/modules/check_mk.py
index a100a12..1998b62 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -34,12 +34,6 @@
import os, sys, socket, time, getopt, glob, re, stat, py_compile, urllib, inspect
import subprocess, fcntl
-# Hack needed to fix UnicodeWarning in in_servicematcher_list(). This
-# can be removed once the encoding of autocheck's items are handled correctly
-# as unicode strings
-import warnings
-warnings.simplefilter("error", UnicodeWarning)
-
# These variable will be substituted at 'make dist' time
check_mk_version = '(inofficial)'
@@ -2000,19 +1994,7 @@ def in_extraconf_servicelist(servicelist, service):
def in_servicematcher_list(service_matchers, item):
for negate, func in service_matchers:
- try:
- result = func(item)
- except (UnicodeDecodeError, UnicodeWarning), e:
- # FIXME: items in autochecks might contain umlauts, the strings
- # are saved as UTF-8 encoded ascii strings. should be saved as
- # unicode strings in this case or at least converted after reading.
- try:
- result = func(item.decode('utf-8'))
- except:
- if opt_debug:
- raise
- result = False
-
+ result = func(item)
if result:
return not negate
diff --git a/modules/discovery.py b/modules/discovery.py
index 3ceb7fa..35217cf 100644
--- a/modules/discovery.py
+++ b/modules/discovery.py
@@ -496,6 +496,12 @@ def discover_check_type(hostname, ipaddress, check_type, use_caches, on_error):
(hostname, check_type, repr(entry)))
continue
+ # Check_MK 1.2.7i3 defines items to be unicode strings. Convert non unicode
+ # strings here seamless. TODO remove this conversion one day and replace it
+ # with a validation that item needs to be of type unicode
+ if type(item) == str:
+ item = decode_incoming_string(item)
+
description = service_description(check_type, item)
# make sanity check
if len(description) == 0:
@@ -810,6 +816,10 @@ def read_autochecks_of(hostname, world="config"):
if len(entry) == 4: # old format where hostname is at the first place
entry = entry[1:]
check_type, item, parameters = entry
+ # With Check_MK 1.2.7i3 items are now defined to be unicode strings. Convert
+ # items from existing autocheck files for compatibility. TODO remove this one day
+ if type(item) == str:
+ item = decode_incoming_string(item)
autochecks.append((check_type, item, compute_check_parameters(hostname, check_type, item, parameters)))
return autochecks
@@ -887,7 +897,14 @@ def parse_autochecks_file(hostname):
raise Exception("Invalid number of parts: %d" % len(parts))
checktypestring, itemstring, paramstring = parts
- table.append((eval(checktypestring), eval(itemstring), paramstring))
+
+ item = eval(itemstring)
+ # With Check_MK 1.2.7i3 items are now defined to be unicode strings. Convert
+ # items from existing autocheck files for compatibility. TODO remove this one day
+ if type(item) == str:
+ item = decode_incoming_string(item)
+
+ table.append((eval(checktypestring), item, paramstring))
except:
if opt_debug:
raise
Module: check_mk
Branch: master
Commit: d6b936f78e894f65db5300d8e8e86effb3143515
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d6b936f78e894f…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Thu Jul 23 15:21:31 2015 +0200
temperature.include: Fixed comments
---
checks/temperature.include | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/checks/temperature.include b/checks/temperature.include
index 23c11ea..c07938b 100644
--- a/checks/temperature.include
+++ b/checks/temperature.include
@@ -66,12 +66,13 @@ temp_unitsym = {
# Checks Celsius temperature against crit/warn levels defined in params. temp must
# be int or float. Parameters:
-# temp: temperature reading of the device (per default interpreted as Celsius)
+# reading: temperature reading of the device (per default interpreted as Celsius)
# params: check parameters (pair or dict)
# dev_unit: unit of the device reading if this is not Celsius ("f": Fahrenheit, "k": Kelvin)
# dev_levels: warn/crit levels of the device itself, if any. In the same unit as temp (dev_unit)
# dev_level_lower: lower warn/crit device levels
# dev_status: temperature state (0, 1, 2) as the device reports it (if applies)
+# dev_status_name: the device name (will be added in the check output)
# Note: you must not specify dev_status and dev_levels at the same time!
def check_temperature(reading, params, dev_unit = "c",
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(