Module: check_mk
Branch: master
Commit: 8df689b9c7122e78ebf5fba75b1d32fe12d3368f
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=8df689b9c7122e…
Author: Goetz Golla <gg(a)mathias-kettner.de>
Date: Tue Aug 19 13:32:05 2014 +0200
#0647 FIX printer_input, printer_output: multiple fixes to algorithm for state
determination and inventory function
The inventory function now considers the description of the unit if its name is not
configured. This should lead to
more and more meaningful items. Still, all units with empty name and description will be
merged into one single
service with an empty item name.
The algorithm to determine the states of a unit was plain wrong, so that a nonsense
collection of states were given.
This has been corrected. Still several states may be derived, but they should now
correctly describe the operational
state of the unit.
The inventory function also used the same algorithm to inventorize only units with
meaningful states. Therefore some
changes may be expected in the inventory of a printer as well.
---
.werks/647 | 18 ++++++++++++++++++
ChangeLog | 1 +
checks/printer_io.include | 27 ++++++++++++++++++++-------
3 files changed, 39 insertions(+), 7 deletions(-)
diff --git a/.werks/647 b/.werks/647
new file mode 100644
index 0000000..248eeed
--- /dev/null
+++ b/.werks/647
@@ -0,0 +1,18 @@
+Title: printer_input, printer_output: multiple fixes to algorithm for state determination
and inventory function
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1408447192
+Class: fix
+
+The inventory function now considers the description of the unit if its name is not
configured. This should lead to
+more and more meaningful items. Still, all units with empty name and description will be
merged into one single
+service with an empty item name.
+
+The algorithm to determine the states of a unit was plain wrong, so that a nonsense
collection of states were given.
+This has been corrected. Still several states may be derived, but they should now
correctly describe the operational
+state of the unit.
+
+The inventory function also used the same algorithm to inventorize only units with
meaningful states. Therefore some
+changes may be expected in the inventory of a printer as well.
diff --git a/ChangeLog b/ChangeLog
index 1a75065..40d3a00 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -38,6 +38,7 @@
* 1152 FIX: mk-job: The check now captures currently running jobs and their start
time...
* 0198 FIX: cisco_temp_sensor: Removed dicey detection for temperature value....
* 0645 FIX: brocade_fcport: since in newer firmware (7.*) swFCPortSpeed is
deprecated, we then calculate port speed from IF-MIB::ifHighSpeed
+ * 0647 FIX: printer_input, printer_output: multiple fixes to algorithm for state
determination and inventory function...
Multisite:
* 1066 Implemented Dashboard Designer...
diff --git a/checks/printer_io.include b/checks/printer_io.include
index 6d076e1..a95232c 100644
--- a/checks/printer_io.include
+++ b/checks/printer_io.include
@@ -56,7 +56,7 @@ printer_io_states = {
64: (0, 'Transitioning to intended state'),
}
-factory_settings['printer_default_levels'] = {
+factory_settings['printer_input_default_levels'] = {
'capacity_levels': (0.0, 0.0),
}
@@ -66,11 +66,21 @@ factory_settings['printer_output_default_levels'] = {
def inventory_printer_io(info):
for line in info:
+ ignore = False
snmp_status = saveint(line[2])
- # Skip sub units where it does not seem to make sense to monitor them
- if snmp_status & 5 and snmp_status & 3 and snmp_status & 1:
+ for state_val in sorted(printer_io_states,reverse=True):
+ if state_val > 0 and snmp_status - state_val >= 0:
+ snmp_status -= state_val
+ # Skip sub units where it does not seem to make sense to monitor them
+ if state_val in ( 1,3,5 ):
+ ignore = True
+ if ignore == True:
continue
- yield (line[0], {})
+ if line[0]:
+ name = line[0]
+ else:
+ name = line[1]
+ yield (name, {})
def check_printer_io(item, params, info, what):
for line in info:
@@ -78,16 +88,19 @@ def check_printer_io(item, params, info, what):
snmp_status, level, capacity_max = saveint(snmp_status), saveint(level),
saveint(capacity_max)
capacity_unit = printer_io_units[capacity_unit]
- if name == item:
+ if descr == item or name == item:
state_txt = []
state_state = 0
if snmp_status == 0:
state_txt.append(printer_io_states[0][1])
else:
- for state_val, (mon_state, text) in printer_io_states.items():
- if snmp_status & state_val:
+ for state_val in sorted(printer_io_states,reverse=True):
+ if state_val > 0 and snmp_status - state_val >= 0:
+ mon_state, text = printer_io_states[state_val]
state_state = max(mon_state, state_state)
state_txt.append(text)
+ snmp_status -= state_val
+
yield state_state, 'Status: %s' % ', '.join(state_txt)
if level in [-1, -2]: