Module: check_mk
Branch: master
Commit: 15dbbdf0643b27096b21e8db3fc4212cef9e378d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=15dbbdf0643b27…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Mar 20 18:31:22 2015 +0100
#1896 FIX ups_socomec_capacity: Now no longer critical when device reports -1 minutes left
on battery
Some Socomec UPSes report -1 minutes left on battery at 100% capacity, which previously
led to the
check being critical all the time. The time left on battery subresult has been removed in
these
cases.
---
.werks/1896 | 11 ++++++++++
ChangeLog | 1 +
checks/ups_socomec_capacity | 47 +++++++++++++++++++++++++++++++++++++++++--
3 files changed, 57 insertions(+), 2 deletions(-)
diff --git a/.werks/1896 b/.werks/1896
new file mode 100644
index 0000000..c66271c
--- /dev/null
+++ b/.werks/1896
@@ -0,0 +1,11 @@
+Title: ups_socomec_capacity: Now no longer critical when device reports -1 minutes left
on battery
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.7i1
+Date: 1426872550
+Class: fix
+
+Some Socomec UPSes report -1 minutes left on battery at 100% capacity, which previously
led to the
+check being critical all the time. The time left on battery subresult has been removed in
these
+cases.
diff --git a/ChangeLog b/ChangeLog
index 669226e..3615a9d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -273,6 +273,7 @@
* 1233 FIX: Fixed fileinfo check for solaris in case of missing files
* 1236 FIX: multipath: Now show correct error in case of removed multipaths instead
of check crash
* 2152 FIX: apache_status: Fixed plugin to work on CentOS/RedHat 5.x...
+ * 1896 FIX: ups_socomec_capacity: Now no longer critical when device reports -1
minutes left on battery...
Multisite:
* 1758 Improved exception hander: Shows details without additional debug request,
added mailto link for error report...
diff --git a/checks/ups_socomec_capacity b/checks/ups_socomec_capacity
index 5aed2e4..3897008 100644
--- a/checks/ups_socomec_capacity
+++ b/checks/ups_socomec_capacity
@@ -39,13 +39,56 @@ def inventory_ups_socomec_capacity(info):
return [(None, 'ups_capacity_default_levels')]
+def check_ups_socomec_capacity(item, params, info):
+ # To support inventories with the old version
+ if type(params) is tuple: # old format with 2 params in tuple
+ 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))
+ else:
+ warn, crit = (0, 0)
+ cap_warn, cap_crit = (95, 90)
+
+ time_on_bat, minutes_left, percent_fuel = map(int, info[0])
+
+ # Check time left on battery
+ if minutes_left != -1:
+ 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) ]
+
+ # Output time on battery
+ if time_on_bat > 0:
+ yield 0, "On battery for %d min" % time_on_bat
+
+
check_info["ups_socomec_capacity"] = {
- "check_function" : check_ups_capacity,
+ "check_function" : check_ups_socomec_capacity,
"inventory_function" : inventory_ups_socomec_capacity,
"service_description" : "Battery capacity",
"has_perfdata" : True,
"group" : "ups_capacity",
"snmp_info" : (".1.3.6.1.4.1.4555.1.1.1.1.2" , [ 2,
3, 4 ] ) ,
- "includes" : [ "ups_capacity.include" ],
"snmp_scan_function" : lambda oid: oid(".1.3.6.1.2.1.1.2.0")
== ".1.3.6.1.4.1.4555.1.1.1",
}