Module: check_mk
Branch: master
Commit: 2cb81012f03527d9450eafd720572144d0cf608c
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=2cb81012f03527…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Jul 21 15:39:24 2014 +0200
Small cleanup of pdu_gude
---
checkman/pdu_gude_8310 | 2 +-
checks/pdu_gude.include | 48 ++++++++++++++++++++++++-----------------------
2 files changed, 26 insertions(+), 24 deletions(-)
diff --git a/checkman/pdu_gude_8310 b/checkman/pdu_gude_8310
index 97b647c..a36e6a4 100644
--- a/checkman/pdu_gude_8310
+++ b/checkman/pdu_gude_8310
@@ -7,7 +7,7 @@ description:
Monitors Power and Voltage on Gude PDU Units.
item:
- ID of the Phase
+ ID of the phase, an integer beginning with {1} for the first phase.
perfdata:
kWh, W, A, V, VA
diff --git a/checks/pdu_gude.include b/checks/pdu_gude.include
index 64fc745..cb9c2df 100644
--- a/checks/pdu_gude.include
+++ b/checks/pdu_gude.include
@@ -25,51 +25,53 @@
# Boston, MA 02110-1301 USA.
pdu_gude_default_levels = {
- "V" : ( 220, 210 ),
- "A" : ( 15, 16 ),
- "W" : ( 3500, 3600 ),
- }
+ "V" : ( 220, 210 ), # Volt
+ "A" : ( 15, 16 ), # Ampere
+ "W" : ( 3500, 3600 ), # Watt
+}
+
def inventory_pdu_gude(info):
if len(info) > 0:
- return [(x + 1, "pdu_gude_default_levels") for x in xrange(len(info))]
+ return [(x + 1, "pdu_gude_default_levels") for x in range(len(info))]
+
def check_pdu_gude(item, params, info):
try:
values = info[item - 1]
except ValueError:
- yield 3, "Item not found"
+ yield 3, "No phase %d found in agent output" % item
return
units = {
0 : ("kWh", 1000),
- 1 : ("W", False ),
- 2 : ("A", 1000),
- 3 : ("V", False),
- 4 : ("VA",False),
+ 1 : ("W", False),
+ 2 : ("A", 1000),
+ 3 : ("V", False),
+ 4 : ("VA", False),
}
- for pos, data in units.items():
- value = savefloat(values[pos])
- unit, div = data
+ for pos, (unit, div) in units.items():
+ value = float(values[pos])
if div:
value = value / div
+ infotext = "%.2f %s" % (value, unit)
+
warn, crit = params.get(unit, (None, None))
- perf = unit, value, warn, crit
- message = "%.2f%s" % (value, unit)
+ perfdata = [ (unit, value, warn, crit) ]
+ status = 0
+
if warn > crit:
if value < crit:
- yield 2, message, perf
+ status = 2
elif value < warn:
- yield 1, message, perf
- else:
- yield 0, message, perf
+ status = 1
+
else:
if crit != None and value > crit:
- yield 2, message, perf
+ status = 2
elif warn != None and value > warn:
- yield 1, message, perf
- else:
- yield 0, message, perf
+ status = 1
+ yield status, infotext, perfdata