Module: check_mk
Branch: master
Commit: aa9b73d33cef0d47a089225ff293d434981fbdab
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=aa9b73d33cef0d…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri May 22 14:20:25 2015 +0200
#1249 alcatel_cpu, alcatel_temp: New checks for Alcatel switches based on IND1 MIB
---
.werks/1249 | 9 +++++++++
ChangeLog | 1 +
checkman/alcatel_cpu | 12 +++++++++++
checkman/alcatel_temp | 12 +++++++++++
checks/alcatel_cpu | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
checks/alcatel_temp | 54 +++++++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 142 insertions(+)
diff --git a/.werks/1249 b/.werks/1249
new file mode 100644
index 0000000..d1bd237
--- /dev/null
+++ b/.werks/1249
@@ -0,0 +1,9 @@
+Title: alcatel_cpu, alcatel_temp: New checks for Alcatel switches based on IND1 MIB
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1432297189
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index b46855b..4dad318 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -192,6 +192,7 @@
* 1247 alcatel_timetra_chassis: New Check for Slots, Power Supplies, MDAs, cf cards and Fans of Alcatel Switches Supporting the TIMETRA-CHASSIS-MIB
* 1248 acme_sbc, acme_sbc.settings: New Checks to monitor an ACME Session Border Controller...
* 2256 mk_mysql: MySQL monitoring is now available for windows...
+ * 1249 alcatel_cpu, alcatel_temp: New checks for Alcatel switches based on IND1 MIB
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checkman/alcatel_cpu b/checkman/alcatel_cpu
new file mode 100644
index 0000000..0f4ed01
--- /dev/null
+++ b/checkman/alcatel_cpu
@@ -0,0 +1,12 @@
+title: Alcatel switches: CPU utilization
+agents: snmp
+catalog: hw/network/alcatel
+license: GPL
+distribution: check_mk
+description:
+ This Check Monitors the CPU utilization on Alcatel switches supporting the ALCATEL-IND1-HEALTH-MIB.
+ The value is a average in percent over the last hour. This average is calculated by the device.
+
+inventory:
+ One check is created
+
diff --git a/checkman/alcatel_temp b/checkman/alcatel_temp
new file mode 100644
index 0000000..c7c4edf
--- /dev/null
+++ b/checkman/alcatel_temp
@@ -0,0 +1,12 @@
+title: Alcatel switches: Board and CPU Temperature
+agents: snmp
+catalog: hw/network/alcatel
+license: GPL
+distribution: check_mk
+description:
+ This Check Monitors CPU and Board Temperatures on Alcatel switches supporting the ALCATEL-IND1-CHASSIS-MIB.
+ If the CPU Temperature is supported depends on the switch mode (not supported on Hawk models)
+
+inventory:
+ One check is created
+
diff --git a/checks/alcatel_cpu b/checks/alcatel_cpu
new file mode 100644
index 0000000..09bc1ae
--- /dev/null
+++ b/checks/alcatel_cpu
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+alcatel_cpu_default_levels = (90.0, 95.0)
+
+def inventory_alcatel_cpu(info):
+ return [(None, "alcatel_cpu_default_levels")]
+
+def check_alcatel_cpu(_no_item, params, info):
+ cpu_perc = int(info[0][0])
+ warn, crit = params
+ state = 0
+ levelstext = ""
+ if cpu_perc >= crit:
+ state = 2
+ elif cpu_perc >= warn:
+ state = 1
+ if state:
+ levelstext = " (warn/crit at %.1f%%/%.1f%%)" % (warn, crit)
+ perfdata = [ ("util", cpu_perc, warn, crit, 0, 100) ]
+ return state, "total: %.1f%%" % cpu_perc + levelstext, perfdata
+
+check_info["alcatel_cpu"] = {
+ "check_function" : check_alcatel_cpu,
+ "inventory_function" : inventory_alcatel_cpu,
+ "service_description" : "CPU utilization",
+ "has_perfdata" : True,
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.6486.800"),
+ "snmp_info" : (".1.3.6.1.4.1.6486.800.1.2.1.16.1.1.1", [13]),
+}
+
diff --git a/checks/alcatel_temp b/checks/alcatel_temp
new file mode 100644
index 0000000..fa57f38
--- /dev/null
+++ b/checks/alcatel_temp
@@ -0,0 +1,54 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2014 mk(a)mathias-kettner.de |
+# +------------------------------------------------------------------+
+#
+# This file is part of Check_MK.
+# The official homepage is at http://mathias-kettner.de/check_mk.
+#
+# check_mk is free software; you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation in version 2. check_mk is distributed
+# in the hope that it will be useful, but WITHOUT ANY WARRANTY; with-
+# out even the implied warranty of MERCHANTABILITY or FITNESS FOR A
+# PARTICULAR PURPOSE. See the GNU General Public License for more de-
+# ails. You should have received a copy of the GNU General Public
+# License along with GNU Make; see the file COPYING. If not, write
+# to the Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+# Boston, MA 02110-1301 USA.
+
+factory_settings['alcatel_temp'] = {
+ "levels" : ( 45, 50 ),
+}
+
+def inventory_alcatel_temp(info):
+ for oid, name in enumerate(["Board", "CPU"]):
+ if info[0][oid] != '0':
+ yield name, {}
+
+def check_alcatel_temp(item, params, info):
+ items = { "Board" : 0, "CPU": 1 }
+ temp_celsius = int(info[0][items[item]])
+ return check_temperature(temp_celsius, params)
+
+check_info["alcatel_temp"] = {
+ "check_function" : check_alcatel_temp,
+ "inventory_function" : inventory_alcatel_temp,
+ "service_description" : "Temperature %s",
+ "group" : "temperature",
+ "default_levels_variable" : "alcatel_temp",
+ "has_perfdata" : True,
+ "snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.6486.800"),
+ "snmp_info" : (".1.3.6.1.4.1.6486.800.1.1.1.3.1.1.3.1", [
+ 4, # chasHardwareBoardTemp
+ 5, # chasHardwareCpuTemp
+ ]),
+ "includes" : [ "temperature.include" ],
+}
Module: check_mk
Branch: master
Commit: 25acf6382d0ce04a695ba2990db9e866612ae74c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=25acf6382d0ce0…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri May 22 12:56:53 2015 +0200
Normaly it is not allowed to have different hosts with equal name in Check_MK.
But it is possible to configure this, e.g. by creating hosts with an equal
name on different sites (we do not recommend to do this).
This change tries to fix handling of this situation in the GUIs views, where
a user clicks on a host/service which is present on multiple sites but the user intends
to get the host/service from a specific view. In the past this situation
was not handled clearly which lead to a view showing data of the two equal
named hosts where the user expected only data of one.
Conflicts:
ChangeLog
web/htdocs/views.py
web/htdocs/visuals.py
web/plugins/visuals/infos.py
---
.werks/2257 | 18 ++++++++++++++++++
ChangeLog | 1 +
web/htdocs/views.py | 38 ++++++++++++++++++++++++++------------
web/htdocs/visuals.py | 8 ++++++++
web/plugins/views/datasources.py | 14 ++++++++++++++
web/plugins/visuals/filters.py | 12 ------------
web/plugins/visuals/infos.py | 2 ++
7 files changed, 69 insertions(+), 24 deletions(-)
diff --git a/.werks/2257 b/.werks/2257
new file mode 100644
index 0000000..9b13859
--- /dev/null
+++ b/.werks/2257
@@ -0,0 +1,18 @@
+Title: Improved handling of duplicate hostnames across different sites
+Level: 1
+Component: multisite
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1432288983
+
+Normaly it is not allowed to have different hosts with equal name in Check_MK.
+But it is possible to configure this, e.g. by creating hosts with an equal
+name on different sites (we do not recommend to do this).
+
+This change tries to fix handling of this situation in the GUIs views, where
+a user clicks on a host/service which is present on multiple sites but the user intends
+to get the host/service from a specific view. In the past this situation
+was not handled clearly which lead to a view showing data of the two equal
+named hosts where the user expected only data of one.
diff --git a/ChangeLog b/ChangeLog
index a62c7e2..b46855b 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -455,6 +455,7 @@
* 2074 FIX: pnptemplate netapp_api_volume: fixed title
* 2251 FIX: Adding views to dashboards / reports is now respecing all set filters...
* 2253 FIX: Availability context button is now visible again for host- and servicegroups
+ * 2257 FIX: Improved handling of duplicate hostnames across different sites...
WATO:
* 1760 Added search form to manual checks page
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index f26fef7..6feea46 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -976,17 +976,20 @@ def show_view(view, show_heading = False, show_buttons = True,
# we convert this to the visuals principle the we need to optimize
# this.
filterheaders = ""
- only_sites = None
all_active_filters = [ f for f in use_filters if f.available() ]
for filt in all_active_filters:
header = filt.filter(tablename)
- if header.startswith("Sites:"):
- only_sites = header.strip().split(" ")[1:]
- else:
- filterheaders += header
+ filterheaders += header
if filt.need_inventory():
need_inventory_data = True
+ # Apply the site hint / filter
+ if config.is_multisite():
+ if html.var("site"):
+ only_sites = [html.var("site")]
+ else:
+ only_sites = None
+
# Prepare limit:
# We had a problem with stats queries on the logtable where
# the limit was not applied on the resulting rows but on the
@@ -2099,7 +2102,7 @@ def url_to_view(row, view_name):
if view:
# Get the context type of the view to link to, then get the parameters of this
# context type and try to construct the context from the data of the row
- vars = []
+ url_vars = []
datasource = multisite_datasources[view['datasource']]
for info_key in datasource['infos']:
if info_key in view['single_infos']:
@@ -2110,21 +2113,32 @@ def url_to_view(row, view_name):
filter_object = visuals.get_filter(filter_name)
# Get the list of URI vars to be set for that filter
new_vars = filter_object.variable_settings(row)
- vars += new_vars
+ url_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)
+ url_vars += visuals.get_filter(src_key).variable_settings(row)
+ url_vars += visuals.get_filter(dst_key).variable_settings(row)
+
+ # Some special handling for the site filter which is meant as optional hint
+ # Always add the site filter var when some useful information is available
+ add_site_hint = True
+ for filter_key in datasource.get('multiple_site_filters', []):
+ if filter_key in dict(url_vars):
+ add_site_hint = False
+
+ if add_site_hint:
+ url_vars.append(('site', row['site']))
do = html.var("display_options")
if do:
- vars.append(("display_options", do))
+ url_vars.append(("display_options", do))
filename = html.mobile and "mobile_view.py" or "view.py"
- return filename + "?" + html.urlencode_vars([("view_name", view_name)] + vars)
- return None
+ uri = filename + "?" + html.urlencode_vars([("view_name", view_name)] + url_vars)
+ content = "<a href=\"%s\">%s</a>" % (uri, content)
+ return content
def link_to_view(content, row, view_name):
if 'I' not in html.display_options:
diff --git a/web/htdocs/visuals.py b/web/htdocs/visuals.py
index 3b4cda3..39026a8 100644
--- a/web/htdocs/visuals.py
+++ b/web/htdocs/visuals.py
@@ -1175,6 +1175,9 @@ def unpack_context_after_editing(packed_context):
def declare_info(infoname, info):
infos[infoname] = info
+def is_single_site_info(info_key):
+ return infos[info_key].get('single_site', True)
+
def single_infos_spec(single_infos):
return ('single_infos', FixedValue(single_infos,
title = _('Show information of single'),
@@ -1318,6 +1321,11 @@ def collect_context_links_of(visual_type_name, this_visual, active_filter_vars,
break
vars_values.append((var, val))
+ # When all infos of the target visual are showing single site data, add
+ # the site hint when available
+ if html.var('site') and all([ is_single_site_info(info_key)for info_key in visual['single_infos']]):
+ vars_values.append(('site', html.var('site')))
+
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/datasources.py b/web/plugins/views/datasources.py
index 7aa06c1..99b8a22 100644
--- a/web/plugins/views/datasources.py
+++ b/web/plugins/views/datasources.py
@@ -84,6 +84,13 @@ multisite_datasources["hosts"] = {
# 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" },
+ # When these filters are set, the site hint will not be added to urls
+ # which link to views using this datasource, because the resuling view
+ # should show the objects spread accross the sites
+ "multiple_site_filters" : [
+ "hostgroup",
+ "servicegroup",
+ ],
}
multisite_datasources["hostsbygroup"] = {
@@ -110,6 +117,13 @@ multisite_datasources["services"] = {
"hostgroup" : "opthostgroup",
"servicegroup" : "optservicegroup",
},
+ # When these filters are set, the site hint will not be added to urls
+ # which link to views using this datasource, because the resuling view
+ # should show the objects spread accross the sites
+ "multiple_site_filters" : [
+ "hostgroup",
+ "servicegroup",
+ ],
}
multisite_datasources["servicesbygroup"] = {
diff --git a/web/plugins/visuals/filters.py b/web/plugins/visuals/filters.py
index a6bc303..54fe5f3 100644
--- a/web/plugins/visuals/filters.py
+++ b/web/plugins/visuals/filters.py
@@ -532,18 +532,6 @@ class FilterSite(Filter):
choices.append((sitename, config.site(sitename)["alias"]))
html.sorted_select("site", choices)
- def filter(self, infoname):
- if config.is_multisite():
- site = html.var("site")
- if site:
- return "Sites: %s\n" % (html.var("site", ""))
- elif not self.enforce:
- return ""
- else:
- return "Sites:\n" # no site at all
- else:
- return ""
-
def heading_info(self):
current_value = html.var("site")
if current_value:
diff --git a/web/plugins/visuals/infos.py b/web/plugins/visuals/infos.py
index 645c3b8..3c5f681 100644
--- a/web/plugins/visuals/infos.py
+++ b/web/plugins/visuals/infos.py
@@ -47,6 +47,7 @@ infos['service'] = {
infos['hostgroup'] = {
'title' : _('Host Group'),
'title_plural': _('Host Groups'),
+ 'single_site' : False, # spread over multiple sites
'single_spec' : [
('hostgroup', TextUnicode(
title = _('Host Group Name'),
@@ -57,6 +58,7 @@ infos['hostgroup'] = {
infos['servicegroup'] = {
'title' : _('Service Group'),
'title_plural': _('Service Groups'),
+ 'single_site' : False, # spread over multiple sites
'single_spec' : [
('servicegroup', TextUnicode(
title = _('Service Group Name'),