Module: check_mk
Branch: master
Commit: a124575b39361e2b1922f8ecb53f4945f8a5298d
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a124575b39361e…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Mon Nov 13 15:26:57 2017 +0100
5445 FIX apc_symmetra_output: Fixed exception 'could not convert string to float'
during discovery
Some devices do not provide all values for 'voltage',
'current' or 'output load' and might be empty strings.
This caused above exception during discovery. Fixed that.
Change-Id: Ie6a0b6a51d171c4e66c8730c5c7caeb2f296045b
---
.werks/5445 | 13 +++++++++++++
checks/apc_symmetra_output | 17 +++++++++++------
2 files changed, 24 insertions(+), 6 deletions(-)
diff --git a/.werks/5445 b/.werks/5445
new file mode 100644
index 0000000..33b3e7c
--- /dev/null
+++ b/.werks/5445
@@ -0,0 +1,13 @@
+Title: apc_symmetra_output: Fixed exception 'could not convert string to float'
during discovery
+Level: 1
+Component: checks
+Class: fix
+Compatible: compat
+Edition: cre
+State: unknown
+Version: 1.5.0i1
+Date: 1510583090
+
+Some devices do not provide all values for 'voltage',
+'current' or 'output load' and might be empty strings.
+This caused above exception during discovery. Fixed that.
diff --git a/checks/apc_symmetra_output b/checks/apc_symmetra_output
index 9e94d93..00637ac 100644
--- a/checks/apc_symmetra_output
+++ b/checks/apc_symmetra_output
@@ -38,12 +38,17 @@ factory_settings["apc_symmetra_output_default_levels"] = {
def parse_apc_symmetra_output(info):
if not info:
return {}
- voltage, current, load = map(float, info[0])
- return { "Output" : {
- "voltage" : voltage,
- "current" : current,
- "output_load" : load,
- }}
+
+ data = {}
+ for key, value_str in zip(["voltage", "current",
"output_load"], info[0]):
+ try:
+ value = float(value_str)
+ except ValueError:
+ continue
+ else:
+ data.setdefault("Output", {})
+ data["Output"].setdefault(key, value)
+ return data
check_info['apc_symmetra_output'] = {