Module: check_mk
Branch: master
Commit: 5ae1b093340ccbaae254abc2fa075595b1514f22
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=5ae1b093340ccb…
Author: Konstantin Büttner <kb(a)mathias-kettner.de>
Date: Fri Feb 27 12:54:15 2015 +0100
#1892 hp_procurve_mem: Now supports setting levels in WATO
To make the WATO rule applicable to the check, it now has a generic "" item.
Re-inventory required.
---
.werks/1892 | 10 ++++++++++
ChangeLog | 2 ++
checks/hp_procurve_mem | 35 ++++++++++++++++++----------------
web/plugins/wato/check_parameters.py | 8 ++++++--
4 files changed, 37 insertions(+), 18 deletions(-)
diff --git a/.werks/1892 b/.werks/1892
new file mode 100644
index 0000000..73492c3
--- /dev/null
+++ b/.werks/1892
@@ -0,0 +1,10 @@
+Title: hp_procurve_mem: Now supports setting levels in WATO
+Level: 1
+Component: checks
+Compatible: incomp
+Version: 1.2.7i1
+Date: 1425037947
+Class: feature
+
+To make the WATO rule applicable to the check, it now has a generic "" item.
+Re-inventory required.
diff --git a/ChangeLog b/ChangeLog
index ce063b6..d5d4e21 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -97,6 +97,8 @@
* 1947 agent_ucs_bladecenter: Monitors UCS Bladecenter via Web-API...
* 2039 mk_logwatch: new per-logfile-options maxfilesize and maxlinesize...
* 1891 apc_symmetra: Now supports setting levels on remaining battery time...
+ * 1892 hp_procurve_mem: Now supports setting levels in WATO...
+ NOTE: Please refer to the migration notes!
* 1457 FIX: logins: new check renamed from "users" check...
NOTE: Please refer to the migration notes!
* 1762 FIX: lnx_thermal: Now ignoring trip points with level 0...
diff --git a/checks/hp_procurve_mem b/checks/hp_procurve_mem
index b9f32f7..47db1fd 100644
--- a/checks/hp_procurve_mem
+++ b/checks/hp_procurve_mem
@@ -31,37 +31,40 @@
# hpLocalMemFreeBytes 1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.6
# hpLocalMemAllocBytes 1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1.7
-hp_procurve_mem_default_levels = (80, 90)
+factory_settings["hp_procurve_mem_default_levels"] = { "levels" :
("perc_used", (80, 90)) }
def inventory_hp_procurve_mem(info):
if len(info) == 1 and int(info[0][0]) >= 0:
- return [ (None, 'hp_procurve_mem_default_levels') ]
+ return [ ("", 'hp_procurve_mem_default_levels') ]
def check_hp_procurve_mem(item, params, info):
if len(info) == 1:
mem_total, mem_used = [ int(mem) for mem in info[0] ]
- if mem_total > 0 and mem_used > 0:
- perc = mem_used * 100 / float(mem_total)
- status = 0
- output = ''
- if perc >= params[1]:
- status = 2
- output = ' (Above %d%%)' % params[1]
- elif perc >= params[0]:
- status = 1
- output = ' (Above %d%%)' % params[0]
-
- return (status, 'Memory usage is %d%% %s' % (perc, output),
- [('bytes_used', '%db' % mem_used, params[0],
params[1], 0, mem_total)])
+ return check_memory(mem_used, mem_total, params)
+# if mem_total > 0:
+# perc = mem_used * 100 / float(mem_total)
+# status = 0
+# output = ''
+# if perc >= params[1]:
+# status = 2
+# output = ' (Above %d%%)' % params[1]
+# elif perc >= params[0]:
+# status = 1
+# output = ' (Above %d%%)' % params[0]
+#
+# return (status, 'Memory usage is %d%% %s' % (perc, output),
+# [('bytes_used', '%db' % mem_used, params[0],
params[1], 0, mem_total)])
- return (3, "Invalid information in snmp data")
check_info["hp_procurve_mem"] = {
'check_function': check_hp_procurve_mem,
'inventory_function': inventory_hp_procurve_mem,
'service_description': 'Memory',
+ 'group': 'memory_simple',
+ 'default_levels_variable': 'hp_procurve_mem_default_levels',
'has_perfdata': True,
'snmp_info': ('.1.3.6.1.4.1.11.2.14.11.5.1.1.2.1.1.1',
['5', '7']),
'snmp_scan_function': \
lambda oid: ".11.2.3.7.11" in oid(".1.3.6.1.2.1.1.2.0"),
+ 'includes': [ "memory.include" ],
}
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index e681159..7ca95a1 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -3019,9 +3019,13 @@ register_check_parameters(
],
optional_keys = [],
),
- forth = lambda old: type(old) != dict and { "levels" : (
"perc_used", old) },
+ forth = lambda v: type(v) != dict and { "levels" : (
"perc_used", v) } or v,
),
- None, None
+ TextAscii(
+ title = _("Module name"),
+ allow_empty = False
+ ),
+ "dict",
)
register_check_parameters(