Module: check_mk
Branch: master
Commit: 9e1c391036684b5495bae9ee6f380a277c666848
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=9e1c391036684b…
Author: Simon Betz <si(a)mathias-kettner.de>
Date: Tue May 8 18:09:11 2018 +0200
hp_procurve_cpu: Fixed invalid parameter format
Change-Id: I49b0e334e41b77482b72a86bd7307206791ca441
---
.werks/6005 | 10 ++++++++++
checks/hp_procurve_cpu | 24 +++++++++++++-----------
2 files changed, 23 insertions(+), 11 deletions(-)
diff --git a/.werks/6005 b/.werks/6005
new file mode 100644
index 0000000..8e1ea4a
--- /dev/null
+++ b/.werks/6005
@@ -0,0 +1,10 @@
+Title: hp_procurve_cpu: Fixed invalid parameter format
+Level: 1
+Component: checks
+Compatible: compat
+Edition: cre
+Version: 1.6.0i1
+Date: 1525795585
+Class: fix
+
+
diff --git a/checks/hp_procurve_cpu b/checks/hp_procurve_cpu
index 9a45fef..92ae0e4 100644
--- a/checks/hp_procurve_cpu
+++ b/checks/hp_procurve_cpu
@@ -35,23 +35,25 @@ def inventory_hp_procurve_cpu(info):
if len(info) == 1 and int(info[0][0]) >= 0 <= 100:
return [ (None, 'hp_procurve_cpu_default_levels') ]
+
def check_hp_procurve_cpu(item, params, info):
+ if not isinstance(params, tuple):
+ params = (None, None)
+
if len(info) == 1:
cpu_util = int(info[0][0])
if cpu_util >= 0 and cpu_util <= 100:
- status = 0
- output = ''
- if cpu_util >= params[1]:
+ infotext = "Usage: %s%%" % cpu_util
+ warn, crit = params
+ if crit is not None and cpu_util >= crit:
status = 2
- output = ' (Above %d%%)' % params[1]
- elif cpu_util >= params[0]:
+ elif warn is not None and cpu_util >= warn:
status = 1
- output = ' (Above %d%%)' % params[0]
-
- return (status, 'CPU utilization is %d%% %s' % (cpu_util, output),
- [('util', '%d%%' % cpu_util, params[0], params[1], 0,
100)])
-
- return (3, "Invalid information in snmp data")
+ else:
+ status = 0
+ if status:
+ infotext += " (warn/crit at %s/%s)" % (warn, crit)
+ return status, infotext, [('util', '%d%%' % cpu_util, warn,
crit, 0, 100)]