Module: check_mk
Branch: master
Commit: 6638b9e955444566595d328003b83cff0fed0943
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=6638b9e9554445…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu May 19 10:03:38 2016 +0200
3604 FIX ups_capacity.include: fixed displaying wrong levels and cleanup
---
.werks/3604 | 10 ++++++++++
ChangeLog | 1 +
checks/ups_capacity.include | 28 ++++++++++++++++------------
3 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/.werks/3604 b/.werks/3604
new file mode 100644
index 0000000..89aa36b
--- /dev/null
+++ b/.werks/3604
@@ -0,0 +1,10 @@
+Title: ups_capacity.include: fixed displaying wrong levels and cleanup
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1463644971
+
+
diff --git a/ChangeLog b/ChangeLog
index 1104eeb..8f3dde3 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -223,6 +223,7 @@
* 3603 FIX: wut_webtherm: fixed empty data handling
* 3535 FIX: docsis_cm_status: fixed missing performance data
* 3536 FIX: alcatel_timetra_chassis: fixed exception when check is not OK
+ * 3604 FIX: ups_capacity.include: fixed displaying wrong levels and cleanup
Multisite:
* 3187 notification view: new filter for log command via regex
diff --git a/checks/ups_capacity.include b/checks/ups_capacity.include
index 29672bb..fdb6801 100644
--- a/checks/ups_capacity.include
+++ b/checks/ups_capacity.include
@@ -41,30 +41,34 @@ def check_ups_capacity(item, params, info):
# Check time left on battery
if minutes_left:
minutes_left = int(minutes_left)
- levelsinfo = ""
+ state = 0
+ infotext = "%d min left on battery" % minutes_left
+
if minutes_left <= crit:
state = 2
- levelsinfo = " (crit at %d min)" % cap_crit
elif minutes_left < warn:
state = 1
- levelsinfo = " (warn at %d min)" % cap_warn
- else:
- state = 0
- yield state, "%d min left on battery" % minutes_left + levelsinfo, [
('capacity', minutes_left, warn, crit) ]
+
+ if state:
+ infotext += " (warn/crit below %d min/%d min)" % (warn, crit)
+
+ yield state, infotext, [ ('capacity', minutes_left, warn, crit) ]
# Check percentual capacity
if percent_fuel:
percent_fuel = int(percent_fuel)
- levelsinfo = ""
+ infotext = "capacity: %d%%" % percent_fuel
+ state = 0
+
if percent_fuel <= cap_crit:
state = 2
- levelsinfo = " (crit at %d%%)" % cap_crit
elif percent_fuel < cap_warn:
state = 1
- levelsinfo = " (warn at %d%%)" % cap_warn
- else:
- state = 0
- yield state, "capacity: %d%%" % percent_fuel + levelsinfo, [
('percent', percent_fuel, cap_warn, cap_crit) ]
+
+ if state:
+ infotext += " (warn/crit below %d%%/%d%%)" % (cap_warn, cap_crit)
+
+ yield state, infotext, [ ('percent', percent_fuel, cap_warn, cap_crit) ]
# Output time on battery
if time_on_bat and int(time_on_bat) > 0: