Module: check_mk
Branch: master
Commit: 2d4013e450de292c1a2bd4b203acb1820bcef8c9
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2d4013e450de29…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Fri Apr 4 12:17:37 2014 +0200
printer_suply: New option to upturn toner levels
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
---
.werks/150 | 8 ++++++++
ChangeLog | 1 +
checkman/printer_supply | 1 +
checks/printer_supply | 14 +++++++++++---
web/plugins/wato/check_parameters.py | 25 ++++++++++++++++++++-----
5 files changed, 41 insertions(+), 8 deletions(-)
diff --git a/.werks/150 b/.werks/150
new file mode 100644
index 0000000..8385f1e
--- /dev/null
+++ b/.werks/150
@@ -0,0 +1,8 @@
+Title: printer_suply: New option to upturn toner levels
+Level: 1
+Component: checks
+Version: 1.2.5i3
+Date: 1396606612
+Class: feature
+
+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
diff --git a/ChangeLog b/ChangeLog
index a7cb5fd..b7c5b87 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -7,6 +7,7 @@
NOTE: Please refer to the migration notes!
* 0799 ibm_svc_systemstats.cpu_util: New check for CPU Utilization of an IBM SVC /
V7000 device in total
* 0800 ibm_svc_nodestats.cache, ibm_svc_systemstats.cache: New checks for Cache Usage
of IBM SVC / V7000 devices
+ * 0150 printer_suply: New option to upturn toner levels...
* 0777 FIX: special agent emcvnx: did not work with security file authentication...
Multisite:
diff --git a/checkman/printer_supply b/checkman/printer_supply
index 82b7ceb..ecde57a 100644
--- a/checkman/printer_supply
+++ b/checkman/printer_supply
@@ -27,6 +27,7 @@ inventory:
[parameters]
warning(int): The supply level in percentage at which (and below) a warning is triggered
critical(int): The supply level in percentage at which (and below) a critical state is
reached.
+upturn(bool): Upturn the toner levels
[configuration]
diff --git a/checks/printer_supply b/checks/printer_supply
index c4e70bc..95f1529 100644
--- a/checks/printer_supply
+++ b/checks/printer_supply
@@ -42,7 +42,8 @@
#['Fuser Unit OKI DATA CORP', '60000', '26174', '']
#['Waste Toner box OKI DATA CORP', '1', '-2', '']
-printer_supply_default_levels = (20, 10)
+# Warn/Crit/upturn current
+printer_supply_default_levels = (20, 10, False)
# When the printer reports -3 as fill threshold the toner
# might be empty or might have some small remaining capacities
@@ -85,7 +86,11 @@ def check_printer_supply(item, params, info):
if line[0].rstrip('\0') == item:
maxlevel = int(line[1])
current = saveint(line[2])
- warn, crit = params # in percent
+ 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
@@ -100,7 +105,10 @@ def check_printer_supply(item, params, info):
# no percentage possible. We compare directly against levels
return (0, "current level is %d" % current,
[("pages", current)])
- leftperc = 100.0 * current / maxlevel
+ if upturn:
+ 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)
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 2c7918d..2d2c845 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -2432,15 +2432,30 @@ register_check_parameters(
"dict",
)
+def transform_printer_supply(l):
+ if len(l) == 2:
+ return l[0], l[1], False
+ return l
+
register_check_parameters(
subgroup_printing,
"printer_supply",
_("Printer cardridge levels"),
- Tuple(
- help = _("Levels for printer cardridges."),
- elements = [
- Float(title = _("Warning remaining")),
- Float(title = _("Critical remaining"))]
+ Transform(
+ Tuple(
+ kelp = _("Levels for printer cardridges."),
+ elements = [
+ Float(title = _("Warning remaining")),
+ Float(title = _("Critical remaining")),
+ Checkbox(
+ title = _("Upturn toner levels" ),
+ 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 = _("cardridge specification"),