Module: check_mk
Branch: master
Commit: 4c227c5dbb8055d58c074c519a76606dc6fce112
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=4c227c5dbb8055…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 26 09:20:19 2015 +0100
#2163 FIX printer_supply: Now auto detects whether or not a supply is consumable or
filling up
This change is intended mainly as fix for an exception which occured for filling up
supplies which report a maximum capacity of 0. Meaning when the level reaches zero
it is fully filled up.
---
.werks/2163 | 12 ++++++++++
ChangeLog | 1 +
checks/printer_supply | 34 +++++++++++++++++++---------
web/plugins/wato/check_parameters.py | 41 ++++++++++++++++++++++------------
4 files changed, 64 insertions(+), 24 deletions(-)
diff --git a/.werks/2163 b/.werks/2163
new file mode 100644
index 0000000..7d9248a
--- /dev/null
+++ b/.werks/2163
@@ -0,0 +1,12 @@
+Title: printer_supply: Now auto detects whether or not a supply is consumable or filling
up
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1427357861
+
+This change is intended mainly as fix for an exception which occured for filling up
+supplies which report a maximum capacity of 0. Meaning when the level reaches zero
+it is fully filled up.
diff --git a/ChangeLog b/ChangeLog
index e29441f..50ecc9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -283,6 +283,7 @@
* 2159 FIX: netapp_api_disk.summary: Changed default thresholds to WARN on the first
broken disk, CRIT on 50%...
* 2161 FIX: heartbeat_crm: Fixed UnboundLocalError exception on some systems
* 2162 FIX: citrix_sessions: Handle not set thresholds on single values correctly...
+ * 2163 FIX: printer_supply: Now auto detects whether or not a supply is consumable or
filling up...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/checks/printer_supply b/checks/printer_supply
index 80f46d4..9c5a7f6 100644
--- a/checks/printer_supply
+++ b/checks/printer_supply
@@ -61,16 +61,20 @@ def printer_supply_fix_infos(info):
new_info = []
for index, line in enumerate(info):
line_0 = snmp_decode_string(line[0]) # give chance for latin1->utf8 decoding
+
+ # For toners or drum units add the color (if available)
if line_0.startswith('Toner Cartridge') \
or line_0.startswith('Image Drum Unit'):
- if line[3]:
- colors += [ line[3] ]
- color = line[3]
- elif line[3] == '':
+ if line[4]:
+ colors += [ line[4] ]
+ color = line[4]
+ elif line[4] == '':
color = colors[index - len(colors)]
line_0 = '%s %s' % (color.title(), line_0)
+
if " S/N:" in line_0:
line_0 = line_0[:line_0.find(" S/N:")]
+
new_info.append([line_0] + line[1:])
return new_info
@@ -84,13 +88,23 @@ def inventory_printer_supply(info):
def check_printer_supply(item, params, info):
for line in printer_supply_fix_infos(info):
if line[0].rstrip('\0') == item:
- maxlevel = int(line[1])
- current = saveint(line[2])
+ maxlevel = int(line[1])
+ current = saveint(line[2])
+
+ # When unit type is
+ # 1 = other
+ # 3 = supplyThatIsConsumed
+ # 4 = supplyThatIsFilled
+ # the value is contains the current level if this supply is a container
+ # but when the remaining space if this supply is a receptacle
+ unit_type = int(line[3])
+
if len(params) == 2:
warn, crit = params # in percent
upturn = False
else:
warn, crit, upturn = params
+
perfdata = [ ("pages", current, warn / 100.0 * maxlevel, crit /
100.0 * maxlevel, 0, maxlevel ) ]
# handle cases with partial data
@@ -105,10 +119,11 @@ def check_printer_supply(item, params, info):
# no percentage possible. We compare directly against levels
return (0, "current level is %d" % current,
[("pages", current)])
- if upturn:
+ if upturn or unit_type == 4: # it's filling up!
leftperc = 100 - current
else:
leftperc = 100.0 * current / maxlevel
+
infotext = "%.0f%% (levels at %.0f%% / %.0f%%)" % (leftperc, warn,
crit)
if leftperc <= crit:
return (2, infotext, perfdata)
@@ -117,8 +132,6 @@ def check_printer_supply(item, params, info):
else:
return (0, infotext, perfdata)
- return (3, 'not found')
-
check_config_variables.append("printer_supply_some_remaining_status")
check_info["printer_supply"] = {
@@ -131,7 +144,8 @@ check_info["printer_supply"] = {
'11.1.1.6', # Printer-MIB::prtMarkerSuppliesDescription
'11.1.1.8', # Printer-MIB::prtMarkerSuppliesMaxCapacity
'11.1.1.9', # Printer-MIB::prtMarkerSuppliesLevel
- '12.1.1.4',
+ '11.1.1.4', # Printer-MIB::prtMarkerSuppliesClass
+ '12.1.1.4', # Printer-MIB::prtMarkerColorantValue
]
),
'snmp_scan_function': \
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 1c3afa8..dc88f7f 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3371,20 +3371,33 @@ register_check_parameters(
_("Printer cartridge levels"),
Transform(
Tuple(
- help = _("Levels for printer cartridges."),
- elements = [
- Percentage(title = _("Warning remaining"), allow_int = True,
default_value = 20.0),
- Percentage(title = _("Critical remaining"), allow_int = True,
default_value = 10.0),
- Checkbox(
- title = _("Upturn toner levels"),
- label = _("Printer sends <i>used</i> material
instead of <i>remaining</i>"),
- help = _("Some Printers (eg. Konica for Drum Cartdiges)
returning the available"
- " fuel instead of what is left. In this case
it's possible"
- " to upturn the levels to handle this
behavior"
- )
- ),]
- ),
- forth = transform_printer_supply,
+ elements = [
+ Percentage(
+ title = _("Warning remaining"),
+ allow_int = True,
+ default_value = 20.0,
+ help = _("For consumable supplies, this is configured as the
percentage of "
+ "remaining capacity. For supplies that fill up, this is
configured "
+ "as remaining space."),
+ ),
+ Percentage(
+ title = _("Critical remaining"),
+ allow_int = True,
+ default_value = 10.0,
+ help = _("For consumable supplies, this is configured as the
percentage of "
+ "remaining capacity. For supplies that fill up, this is
configured "
+ "as remaining space."),
+ ),
+ Checkbox(
+ title = _("Upturn toner levels"),
+ label = _("Printer sends <i>used</i> material
instead of <i>remaining</i>"),
+ help = _("Some Printers (eg. Konica for Drum Cartdiges)
returning the available"
+ " fuel instead of what is left. In this case it's
possible"
+ " to upturn the levels to handle this behavior")
+ ),
+ ]
+ ),
+ forth = transform_printer_supply,
),
TextAscii(
title = _("cartridge specification"),