Module: check_mk
Branch: master
Commit: 3e799bd24fcc4e3989fc199b6824bc1d170faaaf
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=3e799bd24fcc4e…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Aug 11 17:35:46 2014 +0200
#1173 cisco_secure: Check creates now a summary instead one service by port
With this new behavier it's much easyer to handle fussy enviroments whith many portstate changes.
A re-service detection for the switch's with port security is necessary after Update.
---
.werks/1173 | 12 ++++++++++++
ChangeLog | 2 ++
checkman/cisco_secure | 7 +++----
checks/cisco_secure | 28 ++++++++++++----------------
4 files changed, 29 insertions(+), 20 deletions(-)
diff --git a/.werks/1173 b/.werks/1173
new file mode 100644
index 0000000..3a2f618
--- /dev/null
+++ b/.werks/1173
@@ -0,0 +1,12 @@
+Title: cisco_secure: Check creates now a summary instead one service by port
+Level: 1
+Component: checks
+Compatible: incomp
+Version: 1.2.5i6
+Date: 1407771069
+Class: feature
+
+With this new behavier it's much easyer to handle fussy enviroments whith many portstate changes.
+
+A re-service detection for the switch's with port security is necessary after Update.
+
diff --git a/ChangeLog b/ChangeLog
index 4f12d8f..62aabde 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -14,6 +14,8 @@
* 0200 arris_cmts_cpu,arris_cmts_temp: New Checks for Arris CMTS Devices ( Temperature and CPU Utilization)
* 0202 cisco_temp_sensor: It is now possible to configure this check in WATO....
* 1172 New check sap.value_groups...
+ * 1173 cisco_secure: Check creates now a summary instead one service by port...
+ NOTE: Please refer to the migration notes!
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
diff --git a/checkman/cisco_secure b/checkman/cisco_secure
index 41a508f..c084d47 100644
--- a/checkman/cisco_secure
+++ b/checkman/cisco_secure
@@ -6,12 +6,11 @@ distribution: check_mk
description:
This check monitors the port Security feature of cisco_switches. It returns a {CRITICAL} state for
each port which is locked due a security isse. If is port security configured but cant be enabled
- the check returns {WARNING}. If a port goes down, the check ignores that and only shows a information in the
- check output.
+ the check returns {WARNING}.
item:
- The description of the Port
+ None
inventory:
- One check for each port with enabled port security which is also up will be created
+ One summary check will be created
diff --git a/checks/cisco_secure b/checks/cisco_secure
index aa7e030..e82d7ec 100644
--- a/checks/cisco_secure
+++ b/checks/cisco_secure
@@ -35,12 +35,12 @@ def cisco_secure_convert(info):
def inventory_cisco_secure(info):
info = cisco_secure_convert(info)
- inventory = []
+ # search for at least one port with security
for name, op_state, enabled, status, violationCount, lastmac in info:
#if portsecurity enabled and port up OR currently there is sercurity issue`
if ( enabled == 1 and op_state == 1) or status == 3:
- inventory.append( (name, None) )
- return inventory
+ return [ (None, None) ]
+ return []
def check_cisco_secure(item, params, info):
secure_states = {
@@ -50,21 +50,17 @@ def check_cisco_secure(item, params, info):
}
info = cisco_secure_convert(info)
+ failed = []
for name, op_state, enabled, status, violationCount, lastmac in info:
- if name == item:
- message = "Port Security %s (Violation Count: %s, Last Mac: %s)" % \
- ( secure_states[status], violationCount, lastmac )
+ message = "Port %s: %s (Violation Count: %s, Last Mac: %s)" % \
+ ( name, secure_states[status], violationCount, lastmac )
- # If port cant be enabled and is up
- if status == 2 and op_state == 1:
- return 1, message
- # Port cant be enabled but is down, so no error state
- elif status == 2:
- return 0, "Port is down"
- # Security issue
- elif status == 3:
- return 2, message
- return 0, message
+ # If port cant be enabled and is up
+ if status == 2 and op_state == 1:
+ yield 1, message
+ # Security issue
+ elif status == 3:
+ yield 2, message
check_info["cisco_secure"] = {
"check_function" : check_cisco_secure,
Module: check_mk
Branch: master
Commit: e3a92f4d402a4015244931d9fe51c5f090b9a7c4
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=e3a92f4d402a40…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Aug 11 16:06:53 2014 +0200
#1172 New check sap.value_groups
With this check it's possible to create groups of SAP values to avoid dozen of service checks.
---
.werks/1172 | 10 ++++++++++
ChangeLog | 1 +
2 files changed, 11 insertions(+)
diff --git a/.werks/1172 b/.werks/1172
new file mode 100644
index 0000000..941ecee
--- /dev/null
+++ b/.werks/1172
@@ -0,0 +1,10 @@
+Title: New check sap.value_groups
+Level: 1
+Component: checks
+Compatible: compat
+Version: 1.2.5i6
+Date: 1407765950
+Class: feature
+
+With this check it's possible to create groups of SAP values to avoid dozen of service checks.
+
diff --git a/ChangeLog b/ChangeLog
index b373406..4f12d8f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -13,6 +13,7 @@
* 0199 veeam_client: Check rewritten to get a nicer output
* 0200 arris_cmts_cpu,arris_cmts_temp: New Checks for Arris CMTS Devices ( Temperature and CPU Utilization)
* 0202 cisco_temp_sensor: It is now possible to configure this check in WATO....
+ * 1172 New check sap.value_groups...
* 1051 FIX: tcp_conn_stats: fix missing performance data...
* 1142 FIX: winperf_ts_sessions: fix computation, check has never really worked
* 1090 FIX: zfsget: fixed exception which happened on incomplete zfs entries
Module: check_mk
Branch: master
Commit: 64721b5a2c60818f085eab255d93f4168a5ec649
URL: http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=64721b5a2c6081…
Author: Bastian Kuhn <bk(a)mathias-kettner.de>
Date: Mon Aug 11 16:04:43 2014 +0200
New check sap.value_groups
---
checkman/sap.value_groups | 20 +++++++++
checks/sap | 78 +++++++++++++++++++++++++++++++++-
web/plugins/wato/check_parameters.py | 31 ++++++++++++++
3 files changed, 128 insertions(+), 1 deletion(-)
diff --git a/checkman/sap.value_groups b/checkman/sap.value_groups
new file mode 100644
index 0000000..f7d39ca
--- /dev/null
+++ b/checkman/sap.value_groups
@@ -0,0 +1,20 @@
+title: SAP Single Value Monitoring Groups
+agents: linux
+catalog: app/sap
+license: GPL
+distribution: check_mk
+description:
+ Please refer to {sap.value} for details.
+ This check is only a subchecks who enables you to create Groups of values.
+
+ The rule "SAP R/3 Single Value Inventory" is not necessary for that, you
+ only need the rule "SAP Value Grouping Patterns" to define a name and an include
+ nor and exclusion list.
+ After the service detection, the check will display the total number of OK and Critical values,
+ in case of Critical values also these.
+
+item:
+ The Name of the Group
+
+inventory:
+ The check does not inventory all available values by default.
diff --git a/checks/sap b/checks/sap
index 5af2b49..8ee8f3b 100644
--- a/checks/sap
+++ b/checks/sap
@@ -78,7 +78,7 @@ check_info['sap.dialog'] = {
# at the moment the following parameters are supported:
# 1. match: the sap-path matching definition
inventory_sap_values = []
-
+sap_value_groups = []
def inventory_sap_value(info):
inv = []
@@ -157,3 +157,79 @@ check_info['sap.value'] = {
"service_description" : "%s",
"has_perfdata" : True,
}
+
+def sap_value_groups_precompile(hostname, item, _unused):
+ return host_extra_conf(hostname, sap_value_groups)
+
+def sap_groups_of_value( value_name, patterns=False ):
+ groups = []
+ if not patterns:
+ patterns = host_extra_conf(g_hostname, sap_value_groups)
+
+ for line in patterns:
+ for group_name, pattern in line:
+ no_match = False
+ inclusion, exclusion = pattern
+ # Exclude:
+ if exclusion:
+ reg = compiled_regexes.get(exclusion)
+ if not reg:
+ reg = re.compile(exclusion)
+ compiled_regexes[exclusion] = reg
+ if reg.match(value_name):
+ no_match = True
+ break
+ #no match for this group, go on with the next group
+ if no_match:
+ break
+
+ # Include
+ reg = compiled_regexes.get(inclusion)
+ if not reg:
+ reg = re.compile(inclusion)
+ compiled_regexes[inclusion] = reg
+ if reg.match(value_name):
+ groups.append(group_name)
+ return groups
+
+def inventory_sap_value_groups( info ):
+ inventory = []
+ found_groups = []
+ for line in info:
+ path = line[3]
+ for group in sap_groups_of_value( path ):
+ if group not in found_groups:
+ inventory.append(( group, None ))
+ found_groups.append(group)
+ return inventory
+
+def check_sap_value_groups( item, params, info ):
+ frontend = []
+ backend = []
+ count_ok = 0
+ count_crit = 0
+ state = 0
+ for line in info:
+ path = line[3]
+ if item in sap_groups_of_value( path, params ):
+ status = sap_nagios_state_map[int(line[1])]
+ output = ''
+ if line[4] == '-':
+ output = ' '.join(line[6:])
+ backend.append( path + output + " " + nagios_state_names[status] )
+ state = max(state, status)
+ if status > 0:
+ count_crit += 1
+ frontend.append( path + output + " " + nagios_state_names[status] )
+ else:
+ count_ok += 1
+
+ return state, "%s OK, %s Crit %s\n%s" % ( count_ok, count_crit, ", ".join(frontend), "\n".join(backend) )
+
+
+check_info['sap.value-groups'] = {
+ 'check_function': check_sap_value_groups,
+ 'inventory_function': inventory_sap_value_groups,
+ 'service_description': "%s",
+}
+precompile_params['sap.value-groups'] = sap_value_groups_precompile
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index 6036366..82c660a 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -476,6 +476,37 @@ register_rule(group + '/' + subgroup_inventory,
)
register_rule(group + '/' + subgroup_inventory,
+ varname = "sap_value_groups",
+ title = _('SAP Value Grouping Patterns'),
+ help = _('The check <tt>sap.value</tt> normaly creates one service for each sap value '
+ 'By defining grouping patterns you can switch to the check <tt>sap.value-groups</tt>. '
+ 'That check monitors a list of SAP values at once. This is usefull if you have '
+ 'a very big list of values which do you want to monitor'),
+ valuespec = ListOf(
+ Tuple(
+ help = _("This defines one value grouping pattern"),
+ show_titles = True,
+ orientation = "horizontal",
+ elements = [
+ TextAscii(
+ title = _("Name of group"),
+ ),
+ Tuple(
+ show_titles = True,
+ orientation = "vertical",
+ elements = [
+ RegExpUnicode(title = _("Include Pattern")),
+ RegExpUnicode(title = _("Exclude Pattern"))
+ ],
+ ),
+ ],
+ ),
+ add_label = _("Add pattern group"),
+ ),
+ match = 'all',
+)
+
+register_rule(group + '/' + subgroup_inventory,
varname = "inventory_heartbeat_crm_rules",
title = _("Heartbeat CRM Inventory"),
valuespec = Dictionary(