Module: check_mk
Branch: master
Commit: d0ae4a86f668b9dee616b3f70b722bb391f7d5ce
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d0ae4a86f668b9…
Author: Sebastian Herbord <sh(a)mathias-kettner.de>
Date: Mon Jan 18 09:25:05 2016 +0100
#2921 printer_supply_ricoh: check now tries to handle negative readings properly
Negative values are used by the device to report "special" conditions.
Unfortunately these aren't
documented so current interpretation is only based on observation.
---
.werks/2921 | 10 ++++++++++
ChangeLog | 1 +
checks/printer_supply_ricoh | 46 ++++++++++++++++++++++++++++++++-----------
3 files changed, 45 insertions(+), 12 deletions(-)
diff --git a/.werks/2921 b/.werks/2921
new file mode 100644
index 0000000..913959e
--- /dev/null
+++ b/.werks/2921
@@ -0,0 +1,10 @@
+Title: printer_supply_ricoh: check now tries to handle negative readings properly
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i4
+Date: 1453105397
+Class: feature
+
+Negative values are used by the device to report "special" conditions.
Unfortunately these aren't
+documented so current interpretation is only based on observation.
diff --git a/ChangeLog b/ChangeLog
index de09450..73be677 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -83,6 +83,7 @@
* 2919 hp_webmgmt_status: New check for health status of various Hewlett-Packard
devices...
* 2920 hr_cpu: this check can now also supports per-core features...
* 1322 solaris_prtdiag: New Check for Solaris Hardware State based on prtdiag
+ * 2921 printer_supply_ricoh: check now tries to handle negative readings properly...
* 2660 FIX: fixed windows agent using the wrong working directory...
* 2664 FIX: ps: Speedup in situation with many matching processes...
* 2661 FIX: windows agent: fixed incomplete process list...
diff --git a/checks/printer_supply_ricoh b/checks/printer_supply_ricoh
index 3f55903..7b418b7 100644
--- a/checks/printer_supply_ricoh
+++ b/checks/printer_supply_ricoh
@@ -62,6 +62,37 @@ def inventory_printer_supply_ricoh(parsed):
def check_printer_supply_ricoh(item, params, parsed):
+ def handle_regular(supply_level):
+ infotext = "%.0f%%" % supply_level
+
+ if supply_level <= crit:
+ state = 2
+ elif supply_level <= warn:
+ state = 1
+ else:
+ state = 0
+
+ if state > 0:
+ infotext += " (warn/crit at %.0f%%/%.0f%%)" % (warn, crit)
+ return state, infotext, supply_level
+
+ def handle_negative(code):
+ # the following codes are based on the MP C2800
+ if code == -100:
+ # does not apply level. Since we don't get a proper reading
+ # the best we could do would be test against 0
+ return 2, "almost empty (<10%)", 0
+ elif code == -2:
+ # cartridge removed?
+ return 3, "unknown level", 0
+ elif code == -3:
+ # -3 = full is based on user claim, but other walks also show
+ # the device itself does not alert in this state
+ return 0, "100%", 100
+ else:
+ # unknown code
+ return handle_regular(0)
+
if type(params) == tuple:
params = { "levels" : params }
@@ -70,19 +101,10 @@ def check_printer_supply_ricoh(item, params, parsed):
for name, supply_level in parsed.items():
if item == name:
if supply_level < 0:
- supply_level = 0
-
- infotext = "%.0f%%" % supply_level
-
- if supply_level <= crit:
- state = 2
- elif supply_level <= warn:
- state = 1
+ # negative levels usually have special meaning
+ state, infotext, supply_level = handle_negative(supply_level)
else:
- state = 0
-
- if state > 0:
- infotext += " (warn/crit at %.0f%%/%.0f%%)" % (warn, crit)
+ state, infotext, supply_level = handle_regular(supply_level)
if "black" in name.lower():
perf_type = "black"