Module: check_mk
Branch: master
Commit: 441c743ff0f9e5fecc75723aa121054f32bce3ba
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=441c743ff0f9e5…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Tue May 12 16:38:04 2015 +0200
Additional try to fix availability for host- and servicegroup views based on host/service info
---
web/htdocs/views.py | 13 +++++++---
web/htdocs/visuals.py | 50 +++++++++++++++++++++++++++++++++-----
web/plugins/views/builtin.py | 4 +--
web/plugins/views/datasources.py | 13 +++++++++-
4 files changed, 68 insertions(+), 12 deletions(-)
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index f7ae63d..300ff4d 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -941,7 +941,8 @@ def show_view(view, show_heading = False, show_buttons = True,
# Filters to use in the view
# In case of single object views, the needed filters are fixed, but not always present
# in context. In this case, take them from the context type definition.
- use_filters = visuals.filters_of_visual(view, datasource['infos'], all_filters_active)
+ use_filters = visuals.filters_of_visual(view, datasource['infos'],
+ all_filters_active, datasource.get('link_filters', {}))
# Not all filters are really shown later in show_filter_form(), because filters which
# have a hardcoded value are not changeable by the user
@@ -955,7 +956,7 @@ def show_view(view, show_heading = False, show_buttons = True,
visuals.add_context_to_uri_vars(view, datasource["infos"], only_count)
# Check that all needed information for configured single contexts are available
- visuals.verify_single_contexts('views', view)
+ visuals.verify_single_contexts('views', view, datasource.get('link_filters', {}))
# Af any painter, sorter or filter needs the information about the host's
# inventory, then we load it and attach it as column "host_inventory"
@@ -1167,7 +1168,7 @@ def render_view(view, rows, datasource, group_painters, painters,
# Take into account: layout capabilities
can_display_checkboxes and not view.get("force_checkboxes"), show_checkboxes,
# Show link to availability
- "host" in datasource["infos"] or "service" in datasource["infos"] or "aggr" in datasource["infos"])
+ datasource["table"] in [ "hosts", "services" ] or "aggr" in datasource["infos"])
# User errors in filters
html.show_user_errors()
@@ -2091,6 +2092,12 @@ def url_to_view(row, view_name):
new_vars = filter_object.variable_settings(row)
vars += new_vars
+ # See get_link_filter_names() comment for details
+ for src_key, dst_key in visuals.get_link_filter_names(view, datasource['infos'],
+ datasource.get('link_filters', {})):
+ vars += visuals.get_filter(src_key).variable_settings(row)
+ vars += visuals.get_filter(dst_key).variable_settings(row)
+
do = html.var("display_options")
if do:
vars.append(("display_options", do))
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 573c5c9..fc64769 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -897,9 +897,33 @@ def filters_allowed_for_info(info):
allowed[fname] = filt
return allowed
+# For all single_infos which are configured for a view which datasource
+# does not provide these infos, try to match the keys of the single_info
+# attributes to a filter which can then be used to filter the data of
+# the available infos.
+# This is needed to make the "hostgroup" single_info possible on datasources
+# which do not have the "hostgroup" info, but the "host" info. This
+# is some kind of filter translation between a filter of the "hostgroup" info
+# and the "hosts" info.
+def get_link_filter_names(visual, info_keys, link_filters):
+ names = []
+ for info_key in visual['single_infos']:
+ if info_key not in info_keys:
+ for key in info_params(info_key):
+ if key in link_filters:
+ names.append((key, link_filters[key]))
+ return names
+
# Collects all filters to be used for the given visual
-def filters_of_visual(visual, info_keys, show_all=False):
+def filters_of_visual(visual, info_keys, show_all=False, link_filters=[]):
filters = []
+
+ # Collect all available filters for these infos
+ all_possible_filters = []
+ for filter_name, filter in multisite_filters.items():
+ if filter.info in info_keys:
+ all_possible_filters.append(filter)
+
for info_key in info_keys:
if info_key in visual['single_infos']:
for key in info_params(info_key):
@@ -909,10 +933,12 @@ def filters_of_visual(visual, info_keys, show_all=False):
if type(val) == dict: # this is a real filter
filters.append(get_filter(key))
+ # See get_link_filter_names() comment for details
+ for key, dst_key in get_link_filter_names(visual, info_keys, link_filters):
+ filters.append(get_filter(dst_key))
+
if show_all: # add *all* available filters of these infos
- for filter_name, filter in multisite_filters.items():
- if filter.info in info_keys:
- filters.append(filter)
+ filters += all_possible_filters
# add ubiquitary_filters that are possible for these infos
for fn in ubiquitary_filters:
@@ -941,6 +967,10 @@ def visible_filters_of_visual(visual, use_filters):
return show_filters
+def apply_link_filter_vars_to_uri_vars(visual, info_keys, link_filters):
+ for src_key, dst_key in get_link_filter_names(visual, info_keys, link_filters):
+ html.set_var(dst_key, html.var(src_key))
+
def add_context_to_uri_vars(visual, only_infos=None, only_count=False):
if only_infos == None:
only_infos = infos.keys() # all datasources!
@@ -1156,9 +1186,9 @@ def single_infos_spec(single_infos):
or _('Not restricted to showing a specific object.'),
))
-def verify_single_contexts(what, visual):
+def verify_single_contexts(what, visual, link_filters):
for k, v in get_singlecontext_html_vars(visual).items():
- if v == None:
+ if v == None and k not in link_filters:
raise MKUserError(k, _('This %s can not be displayed, because the '
'necessary context information "%s" is missing.') %
(visual_types[what]['title'], k))
@@ -1292,6 +1322,14 @@ def collect_context_links_of(visual_type_name, this_visual, active_filter_vars,
break
vars_values.append((var, val))
+ # See get_link_filter_names() comment for details. TODO Hack for host/service
+ # views with single hostgroup context. Will be cleaned up soon. hopefully
+ if visual.get('datasource') in ['hosts', 'services']:
+ if 'hostgroup' in visual['single_infos']:
+ vars_values.append(('opthost_group', html.var('hostgroup')))
+ if 'servicegroup' in visual['single_infos']:
+ vars_values.append(('optservice_group', html.var('servicegroup')))
+
if not skip:
# add context link to this visual. For reports we put in
# the *complete* context, even the non-single one.
diff --git a/web/plugins/views/builtin.py b/web/plugins/views/builtin.py
index 3e9b41b..d4753da 100644
--- a/web/plugins/views/builtin.py
+++ b/web/plugins/views/builtin.py
@@ -764,7 +764,7 @@ multisite_builtin_views.update({
'title': _('Problems of host')},
'hostgroup': {'browser_reload': 30,
'column_headers': 'off',
- 'datasource': 'hostsbygroup',
+ 'datasource': 'hosts',
'description': _('Lists members of a host group with the number of services in the different states.'),
'group_painters': [('site_icon', None),
('sitealias', 'sitehosts')],
@@ -1342,7 +1342,7 @@ multisite_builtin_views.update({
'topic': _('Other')},
'servicegroup': {'browser_reload': 30,
'column_headers': 'pergroup',
- 'datasource': 'servicesbygroup',
+ 'datasource': 'services',
'description': _('Services of a service group'),
'group_painters': [('sitealias', 'sitehosts'),
('host', 'host')],
diff --git a/web/plugins/views/datasources.py b/web/plugins/views/datasources.py
index a861ae7..7aa06c1 100644
--- a/web/plugins/views/datasources.py
+++ b/web/plugins/views/datasources.py
@@ -79,7 +79,11 @@ multisite_datasources["hosts"] = {
"keys" : [ "host_name", "host_downtimes" ],
"join" : ( "services", "host_name" ),
"idkeys" : [ "site", "host_name" ],
- "description" : _("Displays a list of hosts."),
+ "description" : _("Displays a list of hosts."),
+ # When the single info "hostgroup" is used, use the "opthostgroup" filter
+ # to handle the data provided by the single_spec value of the "hostgroup"
+ # info, which is in fact the name of the wanted hostgroup
+ "link_filters" : { "hostgroup": "opthostgroup" },
}
multisite_datasources["hostsbygroup"] = {
@@ -99,6 +103,13 @@ multisite_datasources["services"] = {
"keys" : [ "host_name", "service_description", "service_downtimes" ],
"joinkey" : "service_description",
"idkeys" : [ "site", "host_name", "service_description" ],
+ # When the single info "hostgroup" is used, use the "opthostgroup" filter
+ # to handle the data provided by the single_spec value of the "hostgroup"
+ # info, which is in fact the name of the wanted hostgroup
+ "link_filters" : {
+ "hostgroup" : "opthostgroup",
+ "servicegroup" : "optservicegroup",
+ },
}
multisite_datasources["servicesbygroup"] = {
Module: check_mk
Branch: master
Commit: 3a83b97d10989ea830771a254f9eebe7327d54fe
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a83b97d10989e…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Tue May 12 11:28:45 2015 +0200
Added manpages for icom_repeater checks
---
checkman/icom_repeater | 11 +++++++++++
checkman/icom_repeater.pll_volt | 24 +++++++++++++++++++++++
checkman/icom_repeater.temp | 40 +++++++++++++++++++++++++++++++++++++++
3 files changed, 75 insertions(+)
diff --git a/checkman/icom_repeater b/checkman/icom_repeater
new file mode 100644
index 0000000..a54ba2b
--- /dev/null
+++ b/checkman/icom_repeater
@@ -0,0 +1,11 @@
+title: ICOM Repeater: Operation Status
+agents: snmp
+catalog: hw/other
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the operation status of ICOM repeaters. It
+ interprets off as CRIT, on as OK and all other states as UNKNOWN.
+
+inventory:
+ One check per device is created.
diff --git a/checkman/icom_repeater.pll_volt b/checkman/icom_repeater.pll_volt
new file mode 100644
index 0000000..dc9f556
--- /dev/null
+++ b/checkman/icom_repeater.pll_volt
@@ -0,0 +1,24 @@
+title: ICOM Repeater: PLL Lock Voltage
+agents: snmp
+catalog: hw/other
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the RX and TX PLL lock voltage
+
+item:
+ "RX" or "TX"
+
+perfdata:
+ One value: The current voltage
+
+inventory:
+ One check per PLL is created.
+
+[parameters]
+ parameters(dict): This checks parameters are a dictionary with the
+ (optional) keys {"rx"} and {"tx"}, under each of which lies a list of
+ tuples (frequency, (warn_lower, crit_lower, warn, crit)), where frequency is
+ the upper boundary of the frequency range for which the parameters
+ (warn_lower, crit_lower, warn, crit)
+
diff --git a/checkman/icom_repeater.temp b/checkman/icom_repeater.temp
new file mode 100644
index 0000000..3f4f34f
--- /dev/null
+++ b/checkman/icom_repeater.temp
@@ -0,0 +1,40 @@
+title: ICOM Repeater: Temperature
+agents: snmp
+catalog: hw/other
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the system temperature of ICOM repeaters.
+
+item:
+ Always "System"
+
+perfdata:
+ One value: The current temperature.
+
+inventory:
+ One check per device is created.
+
+[parameters]
+parameters(dict): This checks parameters are a dictionary with the
+following (optional) keys:
+
+ {"levels"}: A tuple (warn, crit) containing the upper levels. Default: (50, 55)
+
+ {"levels_lower"}: A tuple (warn, crit) containing the lower levels. Default: (-20, -25)
+
+ {"output_unit"}: "c", "f" or "k", the check will output the temperature in the
+ specified unit. If this is not set, output is in degrees Celsius.
+
+ {"input_unit"}: "c, "f" or "k". By default, the check interprets the sensor value
+ according to the unit sent by the device. This key allows to override that. Tread
+ lightly, as this may lead to a misinterpreted temperature. Should only be used if
+ the device reports its unit incorrectly.
+
+ {"device_levels_handling"}: Specifies how the temperature status
+ (too hot/too cold) provided by the device, respectively the device's levels are
+ handled compared to levels set by the user. Options are "usr", "dev",
+ "best", "worst", "devdefault", "usrdefault". "usr" and "dev" means respecting
+ only the user's resp. the device's levels, wheras "usrdefault" and "devdefault"
+ take the user's resp. the device's levels if present, otherwise try to use the
+ device's resp. the user's levels.