Module: check_mk
Branch: master
Commit: 439491daaeb7bfbf96cadc981e77cec7ed9b3515
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=439491daaeb7bf…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Oct 9 23:53:15 2013 +0200
services: Windows inventory now also matches against display names
---
ChangeLog | 1 +
checks/services | 25 +++++++++++++++----------
web/plugins/wato/check_parameters.py | 5 +++--
3 files changed, 19 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index b172afd..67b71d8 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -15,6 +15,7 @@
* check_icmp: New WATO rule for custom PING checks
* agent_vsphere: now able to handle < > & ' " in login
credentials
* if/if64 and friends: add 95% percentiles to graphs
+ * services: inventory now also matches against display names of services
* FIX: windows_agent: fixed bug in cleanup of open thread handles
* FIX: cups default printer is now monitored again in linux agent
* FIX: host notification email in html format: fixed formating error
diff --git a/checks/services b/checks/services
index 6eb9b02..b08146f 100644
--- a/checks/services
+++ b/checks/services
@@ -67,7 +67,7 @@ inventory_services_rules = []
def inventory_windows_services(info):
# Handle single entries (type str)
- def add_matching_services(name, state, start_type, entry):
+ def add_matching_services(name, description, state, start_type, entry):
if type(entry) == tuple:
# New wato rule handling
svc = entry[0]
@@ -80,12 +80,14 @@ def inventory_windows_services(info):
svc = entry
statespec = "running"
- # First match name (optional since rule based config option available)
+ # First match name or description (optional since rule based config option
available)
+ use_as_item = None
if svc:
if svc.startswith("~"):
- if not get_regex(svc[1:]).match(name):
+ r = get_regex(svc[1:])
+ if not r.match(name) and not r.match(description):
return []
- elif svc != name:
+ elif svc != name and svc != description:
return []
if type(statespec) == tuple:
@@ -102,7 +104,7 @@ def inventory_windows_services(info):
return [(name, {})]
# Handle entries like ( [ "term" ], ALL_HOSTS, [ "FooBar auto",
".*TEST running" ] )
- def add_services_with_tags(name, state, start_type, entry):
+ def add_services_with_tags(name, description, state, start_type, entry):
matching = []
if len(entry) == 2:
entry = ( [], ) + entry
@@ -110,7 +112,7 @@ def inventory_windows_services(info):
if hosttags_match_taglist(tags_of_host(g_hostname), taglist):
if in_extraconf_hostlist(hostlist, g_hostname):
for svc in svclist:
- matching += add_matching_services(name, state, start_type, svc)
+ matching += add_matching_services(name, description, state,
start_type, svc)
return matching
# Filter WATO compatible rules by tags/hostlist
@@ -136,6 +138,7 @@ def inventory_windows_services(info):
inventory = []
for line in info:
name = line[1]
+ description = " ".join(line[3:])
if '/' in line[2]:
state, start_type = line[2].split('/')
else:
@@ -147,9 +150,9 @@ def inventory_windows_services(info):
#
for entry in inventory_services:
if type(entry) == str:
- inventory += add_matching_services(name, state, start_type, entry)
+ inventory += add_matching_services(name, description, state, start_type,
entry)
elif type(entry) == tuple:
- inventory += add_services_with_tags(name, state, start_type, entry)
+ inventory += add_services_with_tags(name, description, tate, start_type,
entry)
else:
raise MKGeneralException("Invalid entry %r in
inventory_services" % entry)
@@ -158,7 +161,7 @@ def inventory_windows_services(info):
#
for rule in rules:
- inventory += add_matching_services(name, state, start_type, rule)
+ inventory += add_matching_services(name, description, state, start_type,
rule)
return inventory
@@ -180,7 +183,9 @@ def check_windows_services(item, params, info):
# states
found = []
for line in info:
- if item == line[1]:
+ # allow to match agains the internal name or agains the display name
+ # of the service
+ if item == line[1] or item == " ".join(line[3:]):
# newer agents also send start type as part of state,
# e.g. running/auto
if '/' in line[2]:
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index f37416f..db0ae8f 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -107,8 +107,9 @@ register_rule(group + '/' + subgroup_inventory,
elements = [
('services', ListOfStrings(
title = _("Services (Regular Expressions)"),
- help = _('Matching the begining of the service names (regular
expression). '
- 'If no service is given, this rule will match all services.
The '
+ help = _('Regular expressions matching the begining of the internal
name '
+ 'or the description of the service. '
+ 'If no name is given then this rule will match all
services. The '
'match is done on the <i>beginning</i> of the
service name. It '
'is done <i>case sensitive</i>. You can do a
case insensitive match '
'by prefixing the regular expression with
<tt>(?i)</tt>. Example: '