Module: check_mk
Branch: master
Commit: 435f6169c568acab681a99a1c0ac0db3df8d5f0d
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=435f6169c568ac…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Jul 27 12:10:30 2015 +0200
Some internal code cleanups
---
web/plugins/userdb/ldap.py | 125 ++++++++++++++++++++++++--------------------
1 file changed, 68 insertions(+), 57 deletions(-)
diff --git a/web/plugins/userdb/ldap.py b/web/plugins/userdb/ldap.py
index 6d6225a..390951d 100644
--- a/web/plugins/userdb/ldap.py
+++ b/web/plugins/userdb/ldap.py
@@ -630,73 +630,84 @@ class LDAPUserConnector(UserConnector):
return self.ldap_search(dn, filt, ['cn'], self._config['group_scope'])
- def group_members(self, filters, filt_attr = 'cn', nested = False):
- cache_key = '%s-%s-%s' % (filters, nested and 'n' or 'f', filt_attr)
+ def get_group_memberships(self, filters, filt_attr = 'cn', nested = False):
+ cache_key = (filters, nested, filt_attr)
if cache_key in self._group_cache:
return self._group_cache[cache_key]
- # When not searching for nested memberships, it is easy when using the an AD base LDAP.
- # The group objects can be queried using the attribute distinguishedname. Therefor we
- # create an alternating match filter to match that attribute when searching by DNs.
- # In OpenLDAP the distinguishedname is no user attribute, therefor it can not be used
- # as filter expression. We have to do one ldap query per group. Maybe, in the future,
- # we change the role sync plugin parameters to snapins to make this part a little easier.
if not nested:
- groups = {}
- filt = self.ldap_filter('groups')
- member_attr = self.member_attr().lower()
+ groups = get_direct_group_memberships(filters, filt_attr)
+ else:
+ groups = get_nested_group_memberships(filters, filt_attr)
+
+ self._group_cache[cache_key] = groups
+ return groups
- if self.is_active_directory() or filt_attr != 'distinguishedname':
- if filters:
- add_filt = '(|%s)' % ''.join([ '(%s=%s)' % (filt_attr, f) for f in filters ])
- filt = '(&%s%s)' % (filt, add_filt)
- for dn, obj in self.ldap_search(self.replace_macros(self._config['group_dn']),
- filt, ['cn', member_attr], self._config['group_scope']):
- groups[dn] = {
+ # When not searching for nested memberships, it is easy when using the an AD base LDAP.
+ # The group objects can be queried using the attribute distinguishedname. Therefor we
+ # create an alternating match filter to match that attribute when searching by DNs.
+ # In OpenLDAP the distinguishedname is no user attribute, therefor it can not be used
+ # as filter expression. We have to do one ldap query per group. Maybe, in the future,
+ # we change the role sync plugin parameters to snapins to make this part a little easier.
+ def get_direct_group_memberships(filters, filt_attr):
+ groups = {}
+ filt = self.ldap_filter('groups')
+ member_attr = self.member_attr().lower()
+
+ if self.is_active_directory() or filt_attr != 'distinguishedname':
+ if filters:
+ add_filt = '(|%s)' % ''.join([ '(%s=%s)' % (filt_attr, f) for f in filters ])
+ filt = '(&%s%s)' % (filt, add_filt)
+
+ for dn, obj in self.ldap_search(self.replace_macros(self._config['group_dn']),
+ filt, ['cn', member_attr], self._config['group_scope']):
+ groups[dn] = {
+ 'cn' : obj['cn'][0],
+ 'members' : [ m.encode('utf-8').lower() for m in obj.get(member_attr,[]) ],
+ }
+ else:
+ # Special handling for OpenLDAP when searching for groups by DN
+ for f_dn in filters:
+ for dn, obj in self.ldap_search(self.replace_macros(f_dn), filt,
+ ['cn', member_attr], 'base'):
+ groups[f_dn] = {
'cn' : obj['cn'][0],
'members' : [ m.encode('utf-8').lower() for m in obj.get(member_attr,[]) ],
}
- else:
- # Special handling for OpenLDAP when searching for groups by DN
- for f_dn in filters:
- for dn, obj in self.ldap_search(self.replace_macros(f_dn), filt,
- ['cn', member_attr], 'base'):
- groups[f_dn] = {
- 'cn' : obj['cn'][0],
- 'members' : [ m.encode('utf-8').lower() for m in obj.get(member_attr,[]) ],
- }
- else:
- # Nested querying is more complicated. We have no option to simply do a query for group objects
- # to make them resolve the memberships here. So we need to query all users with the nested
- # memberof filter to get all group memberships of that group. We need one query for each group.
- groups = {}
- for filter_val in filters:
- if filt_attr == 'cn':
- result = self.ldap_search(self.replace_macros(self._config['group_dn']),
- '(&%s(cn=%s))' % (self.ldap_filter('groups'), filter_val),
- ['dn'], self._config['group_scope'])
- if not result:
- continue # Skip groups which can not be found
- dn = result[0][0]
- cn = filter_val
- else:
- dn = filter_val
- # in case of asking with DNs in nested mode, the resulting objects have the
- # cn set to None for all objects. We do not need it in that case.
- cn = None
+ return groups
- filt = '(&%s(memberOf:1.2.840.113556.1.4.1941:=%s))' % (self.ldap_filter('users'), dn)
- groups[dn] = {
- 'members' : [],
- 'cn' : cn,
- }
- for user_dn, obj in self.ldap_search(self.replace_macros(self._config['user_dn']),
- filt, ['dn'], self._config['user_scope']):
- groups[dn]['members'].append(user_dn.lower())
- self._group_cache[cache_key] = groups
+ # Nested querying is more complicated. We have no option to simply do a query for group objects
+ # to make them resolve the memberships here. So we need to query all users with the nested
+ # memberof filter to get all group memberships of that group. We need one query for each group.
+ def get_nested_group_memberships(filters, filt_attr):
+ groups = {}
+ for filter_val in filters:
+ if filt_attr == 'cn':
+ result = self.ldap_search(self.replace_macros(self._config['group_dn']),
+ '(&%s(cn=%s))' % (self.ldap_filter('groups'), filter_val),
+ ['dn'], self._config['group_scope'])
+ if not result:
+ continue # Skip groups which can not be found
+ dn = result[0][0]
+ cn = filter_val
+ else:
+ dn = filter_val
+ # in case of asking with DNs in nested mode, the resulting objects have the
+ # cn set to None for all objects. We do not need it in that case.
+ cn = None
+
+ filt = '(&%s(memberOf:1.2.840.113556.1.4.1941:=%s))' % (self.ldap_filter('users'), dn)
+ groups[dn] = {
+ 'members' : [],
+ 'cn' : cn,
+ }
+ for user_dn, obj in self.ldap_search(self.replace_macros(self._config['user_dn']),
+ filt, ['dn'], self._config['user_scope']):
+ groups[dn]['members'].append(user_dn.lower())
+
return groups
@@ -1291,7 +1302,7 @@ def ldap_sync_groups_to_contactgroups(connection, plugin, params, user_id, ldap_
# 2. Load all LDAP groups which have a CN matching one contact
# group which exists in WATO
- ldap_groups = connection.group_members(cg_names, nested = params.get('nested', False))
+ ldap_groups = connection.get_group_memberships(cg_names, nested = params.get('nested', False))
# 3. Only add groups which the user is member of
return {'contactgroups': [ g['cn'] for dn, g in ldap_groups.items() if user_cmp_val in g['members']]}
@@ -1337,7 +1348,7 @@ def ldap_sync_groups_to_roles(connection, plugin, params, user_id, ldap_user, us
elif type(distinguished_names) in [ str, unicode ]:
groups_to_fetch.append(distinguished_names.lower())
- ldap_groups = dict(connection.group_members(groups_to_fetch,
+ ldap_groups = dict(connection.get_group_memberships(groups_to_fetch,
filt_attr = 'distinguishedname',
nested = params.get('nested', False)))
Module: check_mk
Branch: master
Commit: 07edb17438c002835f70114d34b1ddf6df7a0835
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=07edb17438c002…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jul 27 11:32:24 2015 +0200
new check hp_procurve_temp
---
checkman/hp_procurve_temp | 20 ++++++++++++++++
checks/hp_procurve_temp | 57 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 77 insertions(+)
diff --git a/checkman/hp_procurve_temp b/checkman/hp_procurve_temp
new file mode 100644
index 0000000..62c500e
--- /dev/null
+++ b/checkman/hp_procurve_temp
@@ -0,0 +1,20 @@
+title: HP Switches: System Temperature
+agents: snmp
+catalog: hw/network/hp
+license: GPL
+distribution: check_mk
+description:
+ This check monitors the system temperature of HP Switches which support
+ the HP-ICF-CHASSIS-MIB.
+ No default levels are set.
+
+ Upper or lower levels can be configured.
+
+item:
+ The system name of the switch.
+
+perfdata:
+ One variable: the system temperature in celsius.
+
+inventory:
+ One service is created for the system temperature.
diff --git a/checks/hp_procurve_temp b/checks/hp_procurve_temp
new file mode 100644
index 0000000..4b8aed9
--- /dev/null
+++ b/checks/hp_procurve_temp
@@ -0,0 +1,57 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+# +------------------------------------------------------------------+
+# | ____ _ _ __ __ _ __ |
+# | / ___| |__ ___ ___| | __ | \/ | |/ / |
+# | | | | '_ \ / _ \/ __| |/ / | |\/| | ' / |
+# | | |___| | | | __/ (__| < | | | | . \ |
+# | \____|_| |_|\___|\___|_|\_\___|_| |_|_|\_\ |
+# | |
+# | Copyright Mathias Kettner 2015 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.
+
+
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.2.0 Sys-1 # system name
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.3.0 21C # current temperature
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.4.0 22C # maximum temperature
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.5.0 18C # minimum temperature
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.6.0 2 # Over temperature
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.7.0 57C # temperature threshold
+# .1.3.6.1.4.1.11.2.14.11.1.2.8.1.1.9.0 17 # average temperature
+
+
+def inventory_hp_procurve_temp(info):
+ if len(info) == 1:
+ return [ (info[0][0], {}) ]
+
+
+def check_hp_procurve_temp(item, params, info):
+ if len(info) == 1:
+ temp, dev_unit = int(info[0][1][:-1]), info[0][1][-1].lower()
+ return check_temperature(temp, params, dev_unit)
+
+
+check_info['hp_procurve_temp'] = {
+ 'inventory_function' : inventory_hp_procurve_temp,
+ 'check_function' : check_hp_procurve_temp,
+ 'service_description' : 'Temperature %s',
+ 'has_perfdata' : True,
+ 'group' : 'temperature',
+ 'snmp_info' : ( ".1.3.6.1.4.1.11.2.14.11.1.2.8.1.1", [ "2", "3" ] ),
+ 'snmp_scan_function' : lambda oid: oid(".1.3.6.1.2.1.1.2.0").startswith(".1.3.6.1.4.1.11.2.3.7.11"),
+ 'includes' : [ 'temperature.include' ],
+}
monitors the system temperature of HP Switches which support the
HP-ICF-CHASSIS-Mib
Message-ID: <55b5fa59.cujLwDZM5bGI69FO%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: 757ecd57ae8cb9010909b2e38887ee9e4599dc3a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=757ecd57ae8cb9…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jul 27 11:14:34 2015 +0200
#2290 New check hp_procurve_temp: monitors the system temperature of HP Switches which support the HP-ICF-CHASSIS-Mib
---
.werks/2290 | 9 +++++++++
ChangeLog | 1 +
2 files changed, 10 insertions(+)
diff --git a/.werks/2290 b/.werks/2290
new file mode 100644
index 0000000..684d8d1
--- /dev/null
+++ b/.werks/2290
@@ -0,0 +1,9 @@
+Title: New check hp_procurve_temp: monitors the system temperature of HP Switches which support the HP-ICF-CHASSIS-Mib
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437988251
+Class: feature
+
+
diff --git a/ChangeLog b/ChangeLog
index 04dca7a..00cfb37 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -30,6 +30,7 @@
* 2288 check_mk_agent.aix: New sections for HACMP cluster manager...
* 2289 New checks: aix_hacmp_resources, aix_hacmp_services, aix_hacmp_nodes...
* 2410 ESX / agent_vsphere: Now able to re-use session cookies...
+ * 2290 New check hp_procurve_temp: monitors the system temperature of HP Switches which support the HP-ICF-CHASSIS-Mib
* 2315 FIX: windows agent: BOM replacement, fixed incorrect byte offset...
* 2316 FIX: windows agent: fix garbled output of cached agent plugins...
* 2358 FIX: check_mk_agent.solaris: more correct computation of zfs used space...
Module: check_mk
Branch: master
Commit: 4456c32c2e8426981347e95a15ca00c81f64aba5
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4456c32c2e8426…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 27 11:26:13 2015 +0200
#2486 Remove special handling for non-distributed-setups in WATO
The handling of the activation of changes of single site setups was completely
different than the case where you have a distributed setup with more than one
Check_MK site. In order to simplify code, documentation and user experiance
this distinction now has been removed. A single-site setup now exactly looks
like and behaves like a distributed setup with just one site. This has no
influence on performance or security.
---
.werks/2486 | 15 ++++++
ChangeLog | 1 +
web/htdocs/config.py | 58 +++++++++++++++++++----
web/htdocs/wato.py | 102 ++++++++++++++++++----------------------
web/plugins/sidebar/shipped.py | 5 +-
5 files changed, 113 insertions(+), 68 deletions(-)
Diff: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commitdiff;h=4456c32c2e…
Module: check_mk
Branch: master
Commit: 418ca64bfeeee864a6965c6fa617086249df135c
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=418ca64bfeeee8…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 24 16:34:41 2015 +0200
#2485 FIX Fix Icon "BI Aggregations containing this service", also avoid BI compilation without need
This werk contains a fix and a speedup: The fix repairs the BI icon that is now contained in
the drop down menu rather than directly in the view. The URL where the icon pointed was broken.
The second change is a speedup: Pages that do not show BI aggregates now do now trigger BI
compilation anymore. This is delayed until the command/icon menu is being opened. Here the
BI icon needs to be displayed and hence the compilation triggered.
---
.werks/2485 | 13 +++++++++++++
ChangeLog | 1 +
web/htdocs/bi.py | 22 ---------------------
web/htdocs/views.py | 6 +++---
web/plugins/icons/builtin.py | 2 +-
web/plugins/views/painters.py | 43 ++++++++++++++++++-----------------------
6 files changed, 37 insertions(+), 50 deletions(-)
diff --git a/.werks/2485 b/.werks/2485
new file mode 100644
index 0000000..fc90c00
--- /dev/null
+++ b/.werks/2485
@@ -0,0 +1,13 @@
+Title: Fix Icon "BI Aggregations containing this service", also avoid BI compilation without need
+Level: 2
+Component: bi
+Compatible: compat
+Version: 1.2.7i3
+Date: 1437748351
+Class: fix
+
+This werk contains a fix and a speedup: The fix repairs the BI icon that is now contained in
+the drop down menu rather than directly in the view. The URL where the icon pointed was broken.
+The second change is a speedup: Pages that do not show BI aggregates now do now trigger BI
+compilation anymore. This is delayed until the command/icon menu is being opened. Here the
+BI icon needs to be displayed and hence the compilation triggered.
diff --git a/ChangeLog b/ChangeLog
index d7f24df..04dca7a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -131,6 +131,7 @@
BI:
* 2369 FIX: Fix exception in BI availability via table "Hostname Aggregations"
* 2370 FIX: Fix computation of "in downtime" and "acknownledged" of hosts in BI aggregations...
+ * 2485 FIX: Fix Icon "BI Aggregations containing this service", also avoid BI compilation without need...
Event Console:
* 2411 Check check_mkevents: Now able to look for events matching the host alias...
diff --git a/web/htdocs/bi.py b/web/htdocs/bi.py
index 4477107..060abb8 100644
--- a/web/htdocs/bi.py
+++ b/web/htdocs/bi.py
@@ -1713,28 +1713,6 @@ def filter_tree_only_problems(tree):
return state, assumed_state, node, new_subtrees
-def page_timeline():
- aggr_group = html.var("av_aggr_group")
- aggr_name = html.var("av_aggr_name")
-
- # First compile the required BI aggregates.
- if config.bi_precompile_on_demand:
- compile_forest(config.user_id, only_groups = [ aggr_group ])
- else:
- compile_forest(config.user_id)
-
- # In the resulting collection of BI aggregates find
- # our tree
- for tree in g_user_cache["forest"][aggr_group]:
- if tree["title"] == aggr_name:
- break
- else:
- raise MKGeneralException("No aggregation with the name %s" %
- aggr_name)
- row = { "aggr_tree" : tree, "aggr_group" : aggr_group }
- views.render_bi_availability(aggr_name, [row])
-
-
# ____ _
# | _ \ __ _| |_ __ _ ___ ___ _ _ _ __ ___ ___ ___
diff --git a/web/htdocs/views.py b/web/htdocs/views.py
index 88df516..2ed61a0 100644
--- a/web/htdocs/views.py
+++ b/web/htdocs/views.py
@@ -2541,8 +2541,8 @@ def ajax_popup_action_menu():
html.write('<ul>\n')
for icon in icons:
html.write('<li>\n')
- if len(icon) == 5:
- icon_name, title, url = icon[2:]
+ if len(icon) == 4:
+ icon_name, title, url = icon[1:]
if url:
url = replace_action_url_macros(url, what, row)
onclick = ''
@@ -2555,6 +2555,6 @@ def ajax_popup_action_menu():
if url:
html.write('</a>')
else:
- html.write(icon[2])
+ html.write(icon[1])
html.write('</li>\n')
html.write('</ul>\n')
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 824ec70..1895e6c 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -713,7 +713,7 @@ def paint_aggregations(what, row, tags, host_custom_vars):
urivars += [
( "aggr_service_service", row["service_description"])
]
- url = html.makeuri_contextless(urivars)
+ url = html.makeuri_contextless(urivars, filename="view.py")
return 'aggr', _("BI Aggregations containing this %s") % \
(what == "host" and _("Host") or _("Service")), url
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index de8614f..2f6b5de 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -162,14 +162,16 @@ def get_multisite_icons():
return icons
-def process_multisite_icons(what, row, tags, custom_vars):
+def process_multisite_icons(what, row, tags, custom_vars, toplevel):
icons = []
for icon_id, icon in get_multisite_icons().items():
if icon.get('type', 'icon') == 'icon':
try:
title = None
url = None
- toplevel = icon['toplevel']
+ if icon['toplevel'] != toplevel:
+ continue
+
sort_index = icon['sort_index']
# In old versions, the icons produced html code directly. The new API
@@ -190,7 +192,7 @@ def process_multisite_icons(what, row, tags, custom_vars):
# case (html), it can simply be appended to the output. Otherwise
# extract the icon name from icon images
if html.output_format == "html":
- icons.append((toplevel, sort_index, result))
+ icons.append((sort_index, result))
else:
# Strip icon names out of HTML code that is generated by htmllib.render_icon()
for n in regex('<img src="([^"]*)"[^>]*>').findall(result):
@@ -202,7 +204,7 @@ def process_multisite_icons(what, row, tags, custom_vars):
n = n[:-4]
elif n.endswith(".gif"):
n = n[:-4]
- icons.append((toplevel, sort_index, n.encode('utf-8'), None, None))
+ icons.append((sort_index, n.encode('utf-8'), None, None))
continue
else:
@@ -212,15 +214,15 @@ def process_multisite_icons(what, row, tags, custom_vars):
icon_name, title = result
elif len(result) == 3:
icon_name, title, url = result
- icons.append((toplevel, sort_index, icon_name, title, url))
+ icons.append((sort_index, icon_name, title, url))
except Exception, e:
import traceback
- icons.append((toplevel, sort_index, 'Exception in icon plugin!<br />' + traceback.format_exc()))
+ icons.append((sort_index, 'Exception in icon plugin!<br />' + traceback.format_exc()))
return icons
-def process_custom_user_icons_and_actions(user_action_ids):
+def process_custom_user_icons_and_actions(user_action_ids, toplevel):
icons = []
for id in user_action_ids:
try:
@@ -228,10 +230,9 @@ def process_custom_user_icons_and_actions(user_action_ids):
except KeyError:
continue # Silently skip not existing icons
- toplevel = icon.get('toplevel', False)
- sort_index = icon.get('sort_index', 15)
-
- icons.append((toplevel, sort_index, icon['icon'], icon.get('title'), icon.get('url')))
+ if icon.get('toplevel', False) == toplevel:
+ sort_index = icon.get('sort_index', 15)
+ icons.append((sort_index, icon['icon'], icon.get('title'), icon.get('url')))
return icons
@@ -257,15 +258,9 @@ def get_icons(what, row, toplevel):
# is written to HTML
# -> or when an exception occured
# (toplevel, sort_index, icon_name, title, url)
- icons = process_multisite_icons(what, row, tags, host_custom_vars)
- icons += process_custom_user_icons_and_actions(user_action_ids)
-
- if toplevel:
- # Returns the toplevel icons
- return sorted([ i for i in icons if i[0] ], key = lambda i: i[1])
- else:
- # Returns the menu icons
- return sorted([ i for i in icons if not i[0] ], key = lambda i: i[1])
+ icons = process_multisite_icons(what, row, tags, host_custom_vars, toplevel)
+ icons += process_custom_user_icons_and_actions(user_action_ids, toplevel)
+ return sorted(icons, key = lambda i: i[0])
def replace_action_url_macros(url, what, row):
@@ -288,12 +283,12 @@ def paint_icons(what, row):
# In case of non HTML output, just return the top level icon names
# as space separated string
if html.output_format != 'html':
- return 'icons', ' '.join([ i[2] for i in toplevel_icons ])
+ return 'icons', ' '.join([ i[1] for i in toplevel_icons ])
output = ''
for icon in toplevel_icons:
- if len(icon) == 5:
- icon_name, title, url = icon[2:]
+ if len(icon) == 4:
+ icon_name, title, url = icon[1:]
if url:
url = replace_action_url_macros(url, what, row)
onclick = ''
@@ -305,7 +300,7 @@ def paint_icons(what, row):
if url:
output += '</a>'
else:
- output += icon[2]
+ output += icon[1]
return "icons", output
Module: check_mk
Branch: master
Commit: 130e8f13758f37b9a46eda4abb0910bc518e4d8a
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=130e8f13758f37…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jul 24 15:34:36 2015 +0200
Minor code optimization
---
modules/snmp.py | 21 +++++++++++++++------
1 file changed, 15 insertions(+), 6 deletions(-)
diff --git a/modules/snmp.py b/modules/snmp.py
index ad097a6..62f7e1c 100644
--- a/modules/snmp.py
+++ b/modules/snmp.py
@@ -242,10 +242,12 @@ def sanitize_snmp_table_columns(columns):
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)
+ # column has missing values in the middle of the tree.
+ if not are_ascending_oids(endoids):
+ endoids.sort(cmp = cmp_oids)
+ need_sort = True
+ else:
+ need_sort = False
# Now fill gaps in columns where some endois are missing
new_columns = []
@@ -253,8 +255,8 @@ def sanitize_snmp_table_columns(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)
+ if need_sort:
+ column.sort(cmp = cmp_oid_pairs)
i = 0
new_column = []
@@ -279,6 +281,13 @@ def sanitize_snmp_table_columns(columns):
return new_columns
+def are_ascending_oids(oid_list):
+ for a in range(len(oid_list) - 1):
+ if cmp_oids(oid_list[a], oid_list[a + 1) > 0: # == 0 should never happen
+ return False
+ return True
+
+
def construct_snmp_table_of_rows(columns):
if not columns:
return []