Module: check_mk
Branch: master
Commit: 53798c02fe7903b6f384379d57ce5d6ebe59902d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=53798c02fe7903…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Mar 26 09:33:14 2015 +0100
#2164 FIX printer_supply: Fixed handling different capacities than percentage when used
upturned levels
---
.werks/2164 | 10 ++++++++++
ChangeLog | 1 +
checks/printer_supply | 9 ++++++---
3 files changed, 17 insertions(+), 3 deletions(-)
diff --git a/.werks/2164 b/.werks/2164
new file mode 100644
index 0000000..67836ce
--- /dev/null
+++ b/.werks/2164
@@ -0,0 +1,10 @@
+Title: printer_supply: Fixed handling different capacities than percentage when used
upturned levels
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i1
+Date: 1427358759
+
+
diff --git a/ChangeLog b/ChangeLog
index 50ecc9d..c86e6da 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -284,6 +284,7 @@
* 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...
+ * 2164 FIX: printer_supply: Fixed handling different capacities than percentage when
used upturned levels
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 661972a..c7855ba 100644
--- a/checks/printer_supply
+++ b/checks/printer_supply
@@ -119,10 +119,13 @@ 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 or (unit_type == 3 and maxlevel == 0):
- leftperc = 100 - current
+ if maxlevel != 0:
+ leftperc = 100.0 * float(current) / maxlevel
else:
- leftperc = 100.0 * current / maxlevel
+ leftperc = float(current) # assume 100% as max
+
+ if upturn or (unit_type == 3 and maxlevel == 0):
+ leftperc = 100 - leftperc
infotext = "%.0f%% (levels at %.0f%% / %.0f%%)" % (leftperc, warn,
crit)
if leftperc <= crit: