Module: check_mk
Branch: master
Commit: 1750fd4719424158d4914e2720405773e4c46932
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1750fd47194241…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Thu Apr 11 16:05:05 2013 +0200
Added check parameter to sap_values check to limit the number of levels to use as
servicename
---
checks/sap | 20 ++++++++++++++++----
web/plugins/wato/check_parameters.py | 10 +++++++++-
2 files changed, 25 insertions(+), 5 deletions(-)
diff --git a/checks/sap b/checks/sap
index 9e6bf27..f27bdc1 100644
--- a/checks/sap
+++ b/checks/sap
@@ -91,12 +91,19 @@ def inventory_sap_value(info):
continue
v = rule[0]
- patterns.append(v['match'])
+ patterns.append((v['match'], v.get('limit_item_levels')))
for line in info:
- for pattern in patterns:
+ for pattern, limit_item_levels in patterns:
+ print pattern, limit_item_levels
if sap_value_path_matches(line[3], pattern):
- inv.append((line[0] + ' ' + line[3], {}))
+ params = {}
+ if limit_item_levels:
+ path =
'/'.join(line[3].split('/')[-limit_item_levels:])
+ params['limit_item_levels'] = limit_item_levels
+ else:
+ path = line[3]
+ inv.append((line[0] + ' ' + path, params))
return inv
@@ -122,7 +129,12 @@ def check_sap_value(item, params, info):
status = None
perfdata = []
for line in info:
- if line[0] + ' ' + line[3] == item:
+ if params.get('limit_item_levels'):
+ this_path =
'/'.join(line[3].split('/')[-params.get('limit_item_levels'):])
+ else:
+ this_path = line[3]
+
+ if line[0] + ' ' + this_path == item:
status = sap_nagios_state_map[int(line[1])]
if line[4] != '-':
# This is a performance value, has no output
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index c253cef..5d6ed73 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -418,8 +418,16 @@ register_rule(group + '/' + subgroup_inventory,
match = lambda x: (not x and 2) or (x[0] == '~' and 1 or 0),
default_value = 'SAP CCMS Monitor Templates/Dialog Overview/Dialog
Response Time/ResponseTime',
)),
+ ('limit_item_levels', Integer(
+ title = _("Limit Levels for Service Names"),
+ unit = _('levels'),
+ minvalue = 1,
+ help = _("The service descriptions of the inventorized services are
named like the paths "
+ "in SAP. You can use this option to let the inventory
function only use the last "
+ "x path levels for naming."),
+ )),
],
- optional_keys = [],
+ optional_keys = ['limit_item_levels'],
),
match = 'list',
)