[checkmk-commits] Check_MK Git: check_mk: printer_input/printer_output: Fixed inventory for printers without name/descr for in/out devices; Ignoring invalid values for current levels

Lars Michelsen lm at mathias-kettner.de
Thu Aug 28 11:49:49 CEST 2014


Module: check_mk
Branch: master
Commit: b71f6a64618efae3997f52982b92b048e8f02170
URL:    http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=b71f6a64618efae3997f52982b92b048e8f02170

Author: Lars Michelsen <lm at mathias-kettner.de>
Date:   Thu Aug 28 11:49:42 2014 +0200

printer_input/printer_output: Fixed inventory for printers without name/descr for in/out devices; Ignoring invalid values for current levels

---

 checks/printer_input      |    1 +
 checks/printer_io.include |   20 +++++++++++++-------
 checks/printer_output     |    1 +
 3 files changed, 15 insertions(+), 7 deletions(-)

diff --git a/checks/printer_input b/checks/printer_input
index b195313..783644c 100644
--- a/checks/printer_input
+++ b/checks/printer_input
@@ -31,6 +31,7 @@ check_info["printer_input"] = {
     'has_perfdata':            False,
     'snmp_info':               (
         '.1.3.6.1.2.1.43.8.2.1', [
+            OID_END,
             '13', # Printer-MIB::prtInputName
             '18', # Printer-MIB::prtInputDescription
             '11', # Printer-MIB::prtInputStatus
diff --git a/checks/printer_io.include b/checks/printer_io.include
index 013ef60..fdfe3b9 100644
--- a/checks/printer_io.include
+++ b/checks/printer_io.include
@@ -66,8 +66,9 @@ factory_settings['printer_output_default_levels'] = {
 
 def inventory_printer_io(info):
     for line in info:
+        index, name, descr, status = line[:4]
         ignore = False
-        snmp_status = saveint(line[2])
+        snmp_status = saveint(status)
         for state_val in sorted(printer_io_states,reverse=True):
             if state_val > 0 and snmp_status - state_val >= 0:
                 snmp_status -= state_val
@@ -76,19 +77,24 @@ def inventory_printer_io(info):
                     ignore = True
         if ignore == True:
             continue
-        if line[0]:
-            name = line[0]
+
+        # When no name is set
+        # a) try to use the description
+        # b) try to use the type otherwise use the index
+        if not name and descr:
+            name = descr
         else:
-            name = line[1]
+            name = index.split('.')[-1]
+
         yield (name, {})
 
 def check_printer_io(item, params, info, what):
     for line in info:
-        name, descr, snmp_status, capacity_unit, capacity_max, level = line
+        index, name, descr, snmp_status, capacity_unit, capacity_max, level = line
         snmp_status, level, capacity_max = saveint(snmp_status), saveint(level), saveint(capacity_max)
         capacity_unit = printer_io_units[capacity_unit]
 
-        if descr == item or name == item:
+        if name == item or descr == item or index.split('.')[-1] == item:
             state_txt = []
             state_state = 0
             if snmp_status == 0:
@@ -103,7 +109,7 @@ def check_printer_io(item, params, info, what):
 
             yield state_state, 'Status: %s' % ', '.join(state_txt)
 
-            if level in [-1, -2]:
+            if level in [-1, -2] or level < -3:
                 pass # totally skip this info when level is unknown or not limited
 
             elif capacity_max in [ -1, -2 ]:
diff --git a/checks/printer_output b/checks/printer_output
index 6e7d2a6..92bf7b7 100644
--- a/checks/printer_output
+++ b/checks/printer_output
@@ -31,6 +31,7 @@ check_info["printer_output"] = {
     'has_perfdata':            False,
     'snmp_info':               (
         '.1.3.6.1.2.1.43.9.2.1', [
+            OID_END,
              '7', # Printer-MIB::prtOutputName
             '12', # Printer-MIB::prtOutputDescription
              '6', # Printer-MIB::prtOutputStatus



More information about the checkmk-commits mailing list