Module: check_mk
Branch: master
Commit: 3a7e5da2fac9585c6daebe348f45267dcde75cd8
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3a7e5da2fac958…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Aug 25 15:36:09 2014 +0200
#1147 FIX upc_capacity, ups_socomec_capacity: Fix checking of battery left levels
The fixes the execution of the levels for <i>Time left on battery</i>. These
levels where internally compared against the <t>Time running on battery</i>
- which is obviously quite the opposite.
Example: If you configure a warning level of <tt>50</tt> minutes for
<i>Time
left on battery</i> then the check gets critical if the estimated remaining
battery time is 50 minutes or less.
---
.werks/1147 | 16 +++++++++++++
ChangeLog | 1 +
checks/ups_capacity.include | 42 +++++++++++++++++++---------------
web/plugins/wato/check_parameters.py | 12 +++++-----
4 files changed, 46 insertions(+), 25 deletions(-)
diff --git a/.werks/1147 b/.werks/1147
new file mode 100644
index 0000000..c1c4065
--- /dev/null
+++ b/.werks/1147
@@ -0,0 +1,16 @@
+Title: upc_capacity, ups_socomec_capacity: Fix checking of battery left levels
+Level: 2
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1408973618
+Class: fix
+
+The fixes the execution of the levels for <i>Time left on battery</i>. These
+levels where internally compared against the <t>Time running on battery</i>
+- which is obviously quite the opposite.
+
+Example: If you configure a warning level of <tt>50</tt> minutes for
<i>Time
+left on battery</i> then the check gets critical if the estimated remaining
+battery time is 50 minutes or less.
+
diff --git a/ChangeLog b/ChangeLog
index d1b6b9f..2b7b6b5 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -58,6 +58,7 @@
NOTE: Please refer to the migration notes!
* 1145 FIX: windows_tasks: handle case correctly where task is currently running...
* 1378 FIX: mk_logwatch: remove exceeding \n when rewriting message and using \0...
+ * 1147 FIX: upc_capacity, ups_socomec_capacity: Fix checking of battery left
levels...
Multisite:
* 1066 Implemented Dashboard Designer...
diff --git a/checks/ups_capacity.include b/checks/ups_capacity.include
index 9c9a33b..fd175d5 100644
--- a/checks/ups_capacity.include
+++ b/checks/ups_capacity.include
@@ -30,36 +30,40 @@ def check_ups_capacity(item, params, info):
warn, crit = params
cap_warn, cap_crit = (95, 90)
elif type(params) is dict: # new dict format
- warn,crit = params.get('battime',(0,0))
- cap_warn,cap_crit = params.get('capacity',(95,90))
+ warn, crit = params.get('battime', (0, 0))
+ cap_warn, cap_crit = params.get('capacity', (95, 90))
else:
warn, crit = (0, 0)
cap_warn, cap_crit = (95, 90)
time_on_bat, minutes_left, percent_fuel = map(int, info[0])
- perf = [
- ('capacity', minutes_left, warn, crit),
- ('percent', percent_fuel),
- ]
- state = 0
- time_label = ""
- cap_label = ""
- if time_on_bat > crit:
+ # Check time left on battery
+ levelsinfo = ""
+ if minutes_left <= crit:
state = 2
- time_label = "On battery since %ds (levels at %ds/%ds)(!!), " %
(time_on_bat, warn, crit)
- elif time_on_bat > warn:
+ levelsinfo = " (crit at %d min)" % cap_crit
+ elif minutes_left < warn:
state = 1
- time_label = "On battery since %ds (levels at %ds/%ds)(!)" %
(time_on_bat, warn, crit)
- if percent_fuel < cap_crit:
+ 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) ]
+
+ # Check percentual capacity
+ levelsinfo = ""
+ if percent_fuel <= cap_crit:
state = 2
- cap_label = "(!!)"
+ levelsinfo = " (crit at %d%%)" % cap_crit
elif percent_fuel < cap_warn:
state = 1
- cap_label = "(!)"
+ levelsinfo = " (warn at %d%%)" % cap_warn
+ else:
+ state = 0
+ yield state, "capacity: %d%%" % percent_fuel + levelsinfo, [
('percent', percent_fuel, cap_warn, cap_crit) ]
- info_text = "%sremaining capacity %dmin, percentage %d%% (%d/%d) %s" \
- % (time_label, minutes_left, percent_fuel, cap_warn, cap_crit, cap_label )
- return(state, info_text, perf)
+ # Output time on battery
+ if time_on_bat > 0:
+ yield 0, "On battery for %d min" % time_on_bat
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 5e9a3fd..7f92ba5 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -4968,16 +4968,16 @@ register_check_parameters(
elements = [
("capacity",
Tuple(
- title = _("Battery Capacity"),
+ title = _("Battery capacity"),
elements = [
Integer(
- title = _("Warning Level"),
+ title = _("Warning at"),
help = _("The battery capacity in percent at and below which
a warning state is triggered"),
unit = "%",
default_value = 95,
),
Integer(
- title = _("Critical Level"),
+ title = _("Critical at"),
help = _("The battery capacity in percent at and below which
a critical state is triggered"),
unit = "%",
default_value = 90,
@@ -4987,16 +4987,16 @@ register_check_parameters(
),
("battime",
Tuple(
- title = _("Time Left on Battery"),
+ title = _("Time left on battery"),
elements = [
Integer(
- title = _("Warning Level"),
+ title = _("Warning at"),
help = _("Time left on Battery at and below which a warning
state is triggered"),
unit = _("min"),
default_value = 0,
),
Integer(
- title = _("Critical Level"),
+ title = _("Critical at"),
help = _("Time Left on Battery at and below which a critical
state is triggered"),
unit = _("min"),
default_value = 0,