Module: check_mk
Branch: master
Commit: 40f3ce3b7f1488da22ecc56b2aaa3a6f7b35894d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=40f3ce3b7f1488…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Thu Oct 29 13:26:11 2015 +0100
#2698 FIX ups_capacity: fixed missing battery time and fuel information
---
.werks/2698 | 10 +++++++++
ChangeLog | 1 +
checks/liebert_bat_temp | 2 +-
checks/ups_bat_temp | 2 +-
checks/ups_capacity.include | 50 +++++++++++++++++++++++--------------------
5 files changed, 40 insertions(+), 25 deletions(-)
diff --git a/.werks/2698 b/.werks/2698
new file mode 100644
index 0000000..620a68f
--- /dev/null
+++ b/.werks/2698
@@ -0,0 +1,10 @@
+Title: ups_capacity: fixed missing battery time and fuel information
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+State: unknown
+Version: 1.2.7i4
+Date: 1446121438
+
+
diff --git a/ChangeLog b/ChangeLog
index e5c4f35..4231352 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -27,6 +27,7 @@
* 2692 FIX: check_http: Fixed broken check when using Nagios (introduced with
1.2.7i3)
* 2706 FIX: winperf_if: fixed rare crashes of windows_if.ps1 plugin...
* 1297 FIX: emcvnx_hba: Prevent old emc versions from inventory...
+ * 2698 FIX: ups_capacity: fixed missing battery time and fuel information
Multisite:
* 2684 Added icons for downloading agent data / walks of hosts...
diff --git a/checks/liebert_bat_temp b/checks/liebert_bat_temp
index fd21e7e..766f91f 100644
--- a/checks/liebert_bat_temp
+++ b/checks/liebert_bat_temp
@@ -38,7 +38,7 @@ def check_liebert_bat_temp(item, params, info):
line = info[0]
temp = saveint(line[0])
perfdata = [ ( "temp", temp, warn, crit, 80 ) ]
- infotext = "temperature: %d°C , (warn/crit at %d°C/%d°C) " % \
+ infotext = "%d°C (warn/crit at %d°C/%d°C) " % \
(temp, warn, crit)
if temp >= crit:
diff --git a/checks/ups_bat_temp b/checks/ups_bat_temp
index 8a29847..8d684b9 100644
--- a/checks/ups_bat_temp
+++ b/checks/ups_bat_temp
@@ -35,7 +35,7 @@ def inventory_ups_bat_temp(info):
def check_ups_bat_temp(item, params, info):
for line in info:
- if line[0] == item:
+ if line[0] == item:
status, infotext, perfdata = check_temperature(int(line[1]), params)
perfdatanew = [ perfdata[0] + (80,) ]
return status, infotext, perfdatanew
diff --git a/checks/ups_capacity.include b/checks/ups_capacity.include
index fd175d5..70bd87f 100644
--- a/checks/ups_capacity.include
+++ b/checks/ups_capacity.include
@@ -36,34 +36,38 @@ def check_ups_capacity(item, params, info):
warn, crit = (0, 0)
cap_warn, cap_crit = (95, 90)
- time_on_bat, minutes_left, percent_fuel = map(int, info[0])
+ time_on_bat, minutes_left, percent_fuel = info[0]
# Check time left on battery
- levelsinfo = ""
- 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 minutes_left:
+ minutes_left = int(minutes_left)
+ levelsinfo = ""
+ 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) ]
# Check percentual capacity
- levelsinfo = ""
- 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 percent_fuel:
+ percent_fuel = int(percent_fuel)
+ levelsinfo = ""
+ 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) ]
# Output time on battery
- if time_on_bat > 0:
- yield 0, "On battery for %d min" % time_on_bat
+ if time_on_bat and int(time_on_bat) > 0:
+ yield 0, "On battery for %d min" % int(time_on_bat)