Module: check_mk
Branch: master
Commit: d7056e09ad698a4f88d01614abeb6b6545783078
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d7056e09ad698a…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Jun 6 09:29:07 2016 +0200
fixed empty info handling
---
checks/cisco_fru_powerusage | 49 ++++++++++++++++++++++---------------------
1 file changed, 25 insertions(+), 24 deletions(-)
diff --git a/checks/cisco_fru_powerusage b/checks/cisco_fru_powerusage
index 96118d5..bec4e47 100644
--- a/checks/cisco_fru_powerusage
+++ b/checks/cisco_fru_powerusage
@@ -46,33 +46,34 @@
def parse_cisco_fru_powerusage(info):
- powerunit, powervals = info
- oidend, powerunit_str = powerunit[0]
- factor_str, voltage_str = powerunit_str.lower().split("amps")
+ parsed = {}
+ powerunit, powervals = info
+ if powerunit and powervals:
+ oidend, powerunit_str = powerunit[0]
+ factor_str, voltage_str = powerunit_str.lower().split("amps")
- if "milli" in factor_str.lower():
- factor = 0.001
- elif "centi" in factor_str.lower():
- factor = 0.01
- else:
- factor = 1.0
+ if "milli" in factor_str.lower():
+ factor = 0.001
+ elif "centi" in factor_str.lower():
+ factor = 0.01
+ else:
+ factor = 1.0
- voltage = float(voltage_str.lower().replace("at", "").\
- replace("@", "").replace("v",
"").strip())
+ voltage = float(voltage_str.lower().replace("at", "").\
+ replace("@", "").replace("v",
"").strip())
- parsed = {}
- if oidend == powervals[0][0]:
- system_total, system_drawn, inline_total, inline_drawn = map(float,
powervals[0][1:])
- for what, val in [
- ("system total", system_total), # Gesamtstrom
- ("system drawn", system_drawn), # aufgenommene
Gesamtstromstaerke
- ("inline total", inline_total),
- ("inline drawn", inline_drawn)]:
- parsed.setdefault(what, {
- "power" : factor * val * voltage,
- "current" : factor * val,
- "voltage" : voltage,
- })
+ if oidend == powervals[0][0]:
+ system_total, system_drawn, inline_total, inline_drawn = map(float,
powervals[0][1:])
+ for what, val in [
+ ("system total", system_total), # Gesamtstrom
+ ("system drawn", system_drawn), # aufgenommene
Gesamtstromstaerke
+ ("inline total", inline_total),
+ ("inline drawn", inline_drawn)]:
+ parsed.setdefault(what, {
+ "power" : factor * val * voltage,
+ "current" : factor * val,
+ "voltage" : voltage,
+ })
return parsed