Module: check_mk
Branch: master
Commit: 9a4ad4340449172358f5ca21fa1a2115bd745113
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9a4ad434044917…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Fri Mar 2 15:33:35 2018 +0100
Minor cleanup
Change-Id: I796fd185ca5b4e989a60b27b4bd604ce9e51f80f
---
checks/printer_supply | 44 +++++++++++++++++++++-----------------------
1 file changed, 21 insertions(+), 23 deletions(-)
diff --git a/checks/printer_supply b/checks/printer_supply
index 611a3cb..a7dffd7 100644
--- a/checks/printer_supply
+++ b/checks/printer_supply
@@ -56,14 +56,13 @@ printer_supply_some_remaining_status = 1
# TODO: This variable is deprecated. Remove it in future
check_config_variables.append("printer_supply_some_remaining_status")
-
-
-
# Workaround for toners and drum units in c5900 devices
# which have equal names for the single parts.
# Add the color description to that item
# Fix name for toners in DELL devices that have serial
# numbers in item name
+
+
def printer_supply_fix_infos(info):
colors = []
new_info = []
@@ -89,6 +88,7 @@ def printer_supply_fix_infos(info):
new_info.append([line_0] + line[1:])
return new_info
+
def inventory_printer_supply(info):
# Ignore devices which show -2 for current value and -2 for max value -> useless
# Also fix trailing zero bytes (seen on HP Jetdirect 143)
@@ -96,6 +96,7 @@ def inventory_printer_supply(info):
for line in printer_supply_fix_infos(info)
if not (line[1] == '-2' and line[2] == '-2') and line[2] and
len(line[1]) > 0 ] # ignore useless devices
+
def check_printer_supply(item, params, info):
for line in printer_supply_fix_infos(info):
if line[0].rstrip('\0') == item:
@@ -156,7 +157,6 @@ def check_printer_supply(item, params, info):
if upturn:
leftperc = 100 - leftperc
-
infotext = "%.0f%% (warn/crit at %.0f%% / %.0f%%)" % (leftperc,
warn, crit)
if leftperc <= crit:
return (2, infotext, perfdata)
@@ -165,24 +165,22 @@ def check_printer_supply(item, params, info):
else:
return (0, infotext, perfdata)
+
check_info["printer_supply"] = {
- 'check_function': check_printer_supply,
- 'inventory_function': inventory_printer_supply,
- 'service_description': 'Supply %s',
- 'has_perfdata': True,
- 'snmp_info': (
- '.1.3.6.1.2.1.43', [
- '11.1.1.6', # Printer-MIB::prtMarkerSuppliesDescription
- '11.1.1.8', # Printer-MIB::prtMarkerSuppliesMaxCapacity
- '11.1.1.9', # Printer-MIB::prtMarkerSuppliesLevel
- '11.1.1.4', # Printer-MIB::prtMarkerSuppliesClass
- '12.1.1.4', # Printer-MIB::prtMarkerColorantValue
- ]
- ),
- 'snmp_scan_function': \
- lambda oid: oid(".1.3.6.1.2.1.43.11.1.1.6.1.1") != None \
- # exclude ricoh printer
- and oid(".1.3.6.1.2.1.1.2.0") !=
".1.3.6.1.4.1.367.1.1",
- 'group': 'printer_supply',
- 'default_levels_variable' : "printer_supply_default_levels",
+ 'inventory_function' : inventory_printer_supply,
+ 'check_function' : check_printer_supply,
+ 'service_description' : 'Supply %s',
+ 'snmp_info' : ('.1.3.6.1.2.1.43', [
+ '11.1.1.6', #
Printer-MIB::prtMarkerSuppliesDescription
+ '11.1.1.8', #
Printer-MIB::prtMarkerSuppliesMaxCapacity
+ '11.1.1.9', #
Printer-MIB::prtMarkerSuppliesLevel
+ '11.1.1.4', #
Printer-MIB::prtMarkerSuppliesClass
+ '12.1.1.4', #
Printer-MIB::prtMarkerColorantValue
+ ]),
+ 'snmp_scan_function' : lambda oid:
oid(".1.3.6.1.2.1.43.11.1.1.6.1.1") != None \
+ # exclude ricoh printer
+ and oid(".1.3.6.1.2.1.1.2.0") !=
".1.3.6.1.4.1.367.1.1",
+ 'has_perfdata' : True,
+ 'group' : 'printer_supply',
+ 'default_levels_variable' : 'printer_supply_default_levels',
}