referenced before assignment
Message-ID: <5af2c6be.a6U4uLUAn+cHNtdN%si(a)mathias-kettner.de>
User-Agent: Heirloom mailx 12.5 6/20/10
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Module: check_mk
Branch: master
Commit: ffd04c3508a0df6c264b7d5b2ea1279f0529897a
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ffd04c3508a0df…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Wed May 9 11:59:51 2018 +0200
6071 FIX emcvnx_sp_util: Fixed UnboundLocalError 'busy_ticks' referenced before
assignment
Change-Id: Ie584caa9f14773b578ab8c868b4188936b36ba85
---
.werks/6071 | 10 ++++++++++
checks/emcvnx_sp_util | 29 +++++++++++++++++------------
2 files changed, 27 insertions(+), 12 deletions(-)
diff --git a/.werks/6071 b/.werks/6071
new file mode 100644
index 0000000..37cca4d
--- /dev/null
+++ b/.werks/6071
@@ -0,0 +1,10 @@
+Title: emcvnx_sp_util: Fixed UnboundLocalError 'busy_ticks' referenced before
assignment
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1525859964
+Class: fix
+
+
diff --git a/checks/emcvnx_sp_util b/checks/emcvnx_sp_util
index 46aac52..ed85a29 100644
--- a/checks/emcvnx_sp_util
+++ b/checks/emcvnx_sp_util
@@ -32,25 +32,29 @@
emcvnx_sp_util_default_levels = (50.0, 60.0)
-def inventory_emcvnx_sp_util(info):
- if info:
+def parse_emcvnx_sp_util(info):
+ parsed = {}
+ for line in info:
+ if len(line) == 2 and "busy" in line[0]:
+ parsed.setdefault("busy", float(line[1]))
+ elif len(line) == 2 and "idle" in line[0]:
+ parsed.setdefault("idle", float(line[1]))
+ return parsed
+
+
+def inventory_emcvnx_sp_util(parsed):
+ if "idle" in parsed and "busy" in parsed:
return [ (None, "emcvnx_sp_util_default_levels") ]
-def check_emcvnx_sp_util(item, params, info):
- if not info:
+def check_emcvnx_sp_util(item, params, parsed):
+ if not ("idle" in parsed and "busy" in parsed):
return
- for line in info:
- if len(line) == 2 and "busy" in line[0]:
- busy_ticks = float(line[1])
- elif len(line) == 2 and "idle" in line[0]:
- idle_ticks = float(line[1])
-
now = time.time()
warn, crit = params
- busy_ticks_rate = get_rate("emcvnx_sp_util.busy_ticks", now, busy_ticks )
- idle_ticks_rate = get_rate("emcvnx_sp_util.idle_ticks", now, idle_ticks )
+ busy_ticks_rate = get_rate("emcvnx_sp_util.busy_ticks", now,
parsed["busy"])
+ idle_ticks_rate = get_rate("emcvnx_sp_util.idle_ticks", now,
parsed["idle"])
if busy_ticks_rate + idle_ticks_rate == 0:
sp_util = 0
else:
@@ -70,6 +74,7 @@ def check_emcvnx_sp_util(item, params, info):
check_info['emcvnx_sp_util'] = {
+ "parse_function" : parse_emcvnx_sp_util,
"inventory_function" : inventory_emcvnx_sp_util,
"check_function" : check_emcvnx_sp_util,
"service_description" : "Storage Processor Utilization",