Module: check_mk
Branch: master
Commit: 0cbe62c5cf4f9a1e97c55a9499adf70e0bf548b1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=0cbe62c5cf4f9a…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Fri Jan 30 11:08:17 2015 +0100
#1924 FIX cisco_power: Fixed missing power supplies in case where name is not unique
---
.bugs/2212 | 8 +++++---
.werks/1923 | 10 ++++++++++
.werks/1924 | 10 ++++++++++
ChangeLog | 2 ++
checks/cisco_power | 53 ++++++++++++++++++++++++++++++++++++++++------------
checks/cisco_qos | 5 +++--
6 files changed, 71 insertions(+), 17 deletions(-)
diff --git a/.bugs/2212 b/.bugs/2212
index b3095f2..fd4fbe5 100644
--- a/.bugs/2212
+++ b/.bugs/2212
@@ -1,10 +1,12 @@
Title: cisco_power: Check mixes up different sensors (non unique item)
Component: checks
-State: open
+Class: bug
+State: done
Date: 2014-12-11 10:40:05
Targetversion: 1.2.5i1
-Class: bug
-The walk switch-cisco-c4500-x-1chassis contains 4 power supply sensors, while two are
named
+The walk switch-cisco-c4500-6 contains 4 power supply sensors, while two are named
Power Supply 1 and two Power Supply 2. The check does not handled them correctly and
mixes
the data.
+
+2015-01-30 11:07:29: changed state open -> done
diff --git a/.werks/1923 b/.werks/1923
new file mode 100644
index 0000000..a464336
--- /dev/null
+++ b/.werks/1923
@@ -0,0 +1,10 @@
+Title: cisco_qos: Fixed exception in discovery that might lead to missing services
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422612381
+
+
diff --git a/.werks/1924 b/.werks/1924
new file mode 100644
index 0000000..28def32
--- /dev/null
+++ b/.werks/1924
@@ -0,0 +1,10 @@
+Title: cisco_power: Fixed missing power supplies in case where name is not unique
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1422612479
+
+
diff --git a/ChangeLog b/ChangeLog
index ecf7b09..44bf32c 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -121,6 +121,8 @@
* 1921 FIX: kemp_loadmaster_realserver: reimplementation, now use vendor specific
information
* 1859 FIX: cups_queues: linux agent now runs section cups_queues in cached mode...
* 1881 FIX: omd_status: Check works now event when a site is reported as not OK...
+ * 1923 FIX: cisco_qos: Fixed exception in discovery that might lead to missing
services
+ * 1924 FIX: cisco_power: Fixed missing power supplies in case where name is not
unique
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/checks/cisco_power b/checks/cisco_power
index d3ad1fd..8d67efc 100644
--- a/checks/cisco_power
+++ b/checks/cisco_power
@@ -31,23 +31,52 @@
# .1.3.6.1.4.1.9.9.13.1.5.1.4.1 1
# .1.3.6.1.4.1.9.9.13.1.5.1.4.2 2
-cisco_power_states = ('', 'normal', 'warning',
'critical',
- 'shutdown', 'notPresent',
'notFunctioning')
-cisco_power_source = ( '', 'unknown', 'ac', 'dc',
'externalPowerSupply', 'internalRedundant')
+cisco_power_states = (
+ '',
+ 'normal',
+ 'warning',
+ 'critical',
+ 'shutdown',
+ 'not present',
+ 'not functioning',
+)
+
+cisco_power_sources = (
+ '',
+ 'unknown',
+ 'AC',
+ 'DC',
+ 'external power supply',
+ 'internal redundant',
+)
def inventory_cisco_power(info):
- for line in info:
- # 5 in line[1] means cisco_power_states = notPresent
- if 'RPS NotExist' not in line[1] and line[2] != '5':
- yield cisco_sensor_item(line[1], line[0]), None
+ # Note: the name of the power supply is not unique. We have seen
+ # a Cisco with four entries in the MIB. So we force uniqueness
+ # by appending a "/4" for ID 4 if the name is not unique
+ discovered = {}
+ for sid, textinfo, state, source in info:
+ if 'RPS NotExist' not in textinfo and state != '5':
+ name = cisco_sensor_item(textinfo, sid)
+ discovered.setdefault(name, []).append(sid)
+
+ for name, entries in discovered.items():
+ if len(entries) == 1:
+ yield name, None
+ else:
+ for entry in entries:
+ yield ("%s/%s" % (name, entry)), None
+
def check_cisco_power(item, no_params, info):
+ if "/" in item:
+ item = item.split("/")[1]
for sid, textinfo, state, source in info:
- state = int(state)
- source = int(source)
- if cisco_sensor_item(textinfo, sid) == item:
- output = '%s, State: %s, Source: %s' % \
- (textinfo, cisco_power_states[state], cisco_power_source[source])
+ if sid == item or cisco_sensor_item(textinfo, sid) == item:
+ state = int(state)
+ source = int(source)
+ output = 'state: %s, source: %s' % \
+ (cisco_power_states[state], cisco_power_sources[source])
if state == 1:
return 0, "%s" % output
elif state == 2:
diff --git a/checks/cisco_qos b/checks/cisco_qos
index 6b515c5..19f0d18 100644
--- a/checks/cisco_qos
+++ b/checks/cisco_qos
@@ -136,8 +136,9 @@ def inventory_cisco_qos(info):
for class_id, class_name in info[2]:
# Get interface ids which use this qos class
for policy_id, objects_id in cisco_qos_get_config_entries_by_class_id(config,
class_id):
- if_name = if_names[ifs[policy_id]]
- items += [ ('%s: %s' % (if_name, class_name), {}) ]
+ if ifs[policy_id] in if_names:
+ if_name = if_names[ifs[policy_id]]
+ items += [ ('%s: %s' % (if_name, class_name), {}) ]
return items