Module: check_mk
Branch: master
Commit: fa028ced83302927629dfb9c6a79ebbba147764e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=fa028ced833029…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Mon Apr 13 14:02:56 2015 +0200
#2176 One custom icon or action can be configured per process/service
It is now possible to configure a custom icon or action per process or
windows service. This is some sort of shortcut. In case of process
inventory, you had to configure two rules:
a) a process discovery rule
b) a rule to assign an icon to this service
With this new feature you can configure the icon to be used for the
found process right in the value of a process discovery rule.
---
.werks/2176 | 17 ++++++++++++++
ChangeLog | 1 +
modules/check_mk.py | 12 ++++++++--
web/htdocs/wato.py | 26 +++++++++++++++++++++
web/plugins/wato/check_mk_configuration.py | 35 ++++------------------------
web/plugins/wato/check_parameters.py | 22 +++++++++++++++--
6 files changed, 78 insertions(+), 35 deletions(-)
diff --git a/.werks/2176 b/.werks/2176
new file mode 100644
index 0000000..a2f5fe1
--- /dev/null
+++ b/.werks/2176
@@ -0,0 +1,17 @@
+Title: One custom icon or action can be configured per process/service
+Level: 1
+Component: wato
+Compatible: compat
+Version: 1.2.7i1
+Date: 1428926372
+Class: feature
+
+It is now possible to configure a custom icon or action per process or
+windows service. This is some sort of shortcut. In case of process
+inventory, you had to configure two rules:
+
+a) a process discovery rule
+b) a rule to assign an icon to this service
+
+With this new feature you can configure the icon to be used for the
+found process right in the value of a process discovery rule.
diff --git a/ChangeLog b/ChangeLog
index 1e9e373..d3ad27e 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -397,6 +397,7 @@
* 1950 ibm_svc_mdisk / disk checks: now able to configure the return state for state
and mode of disk...
* 1951 check_http: now able to configure warning and critical limit for certificate
age...
* 2136 Unify headers of Host/Service rules, EC rules and notification rules...
+ * 2176 One custom icon or action can be configured per process/service...
* 1761 FIX: Ruleset search is now consistent for host & serviceparameters and
manual checks
* 1765 FIX: Fixed bug when generating nagvis backends while having sites with
livestatus proxy configured...
* 1789 FIX: Fix preview of passive checks in WATO list of services
diff --git a/modules/check_mk.py b/modules/check_mk.py
index 137b7d0..9a11d12 100755
--- a/modules/check_mk.py
+++ b/modules/check_mk.py
@@ -1522,12 +1522,20 @@ def host_check_command(hostname, ip, is_clust):
value, hostname))
-def icons_and_actions_of(what, hostname, svcdesc = None):
+def icons_and_actions_of(what, hostname, svcdesc = None, checkname = None, params =
None):
if what == 'host':
return list(set(host_extra_conf(hostname, host_icons_and_actions)))
else:
actions = set(service_extra_conf(hostname, svcdesc, service_icons_and_actions))
+ # Some WATO rules might register icons on their own
+ checkgroup = checkgroup_of.get(checkname, checkname)
+ if checkgroup in [ 'ps', 'services' ]:
+ icon = params.get('icon')
+ if icon:
+ actions.add(icon)
+ print checkname, checkgroup
+
return list(actions)
@@ -2247,7 +2255,7 @@ define servicedependency {
check_interval = value
# Add custom user icons and actions
- actions = icons_and_actions_of('service', hostname, description)
+ actions = icons_and_actions_of('service', hostname, description,
checkname, params)
action_cfg = actions and ' _ACTIONS\t\t\t%s\n' %
','.join(actions) or ''
outfile.write("""define service {
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 0db0141..a631f72 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -18701,6 +18701,32 @@ def rule_option_elements(disabling=True):
]
return elements
+class UserIconOrAction(DropdownChoice):
+ def __init__(self, **kwargs):
+ empty_text = _("In order to be able to choose actions here, you need to
"
+ "<a href=\"%s\">define your own
actions</a>.") % \
+
"wato.py?mode=edit_configvar&varname=user_icons_and_actions"
+
+ kwargs.update({
+ 'choices' : self.list_user_icons_and_actions,
+ 'allow_empty' : False,
+ 'empty_text' : empty_text,
+ 'help' : kwargs.get('help', '') + '
'+empty_text,
+ })
+ DropdownChoice.__init__(self, **kwargs)
+
+ def list_user_icons_and_actions(self):
+ choices = []
+ for key, action in config.user_icons_and_actions.items():
+ label = key
+ if 'title' in action:
+ label += ' - '+action['title']
+ if 'url' in action:
+ label += ' ('+action['url']+')'
+
+ choices.append((key, label))
+ return sorted(choices, key = lambda x: x[1])
+
#.
# .--Plugins-------------------------------------------------------------.
# | ____ _ _ |
diff --git a/web/plugins/wato/check_mk_configuration.py
b/web/plugins/wato/check_mk_configuration.py
index 5e7b432..74d89db 100644
--- a/web/plugins/wato/check_mk_configuration.py
+++ b/web/plugins/wato/check_mk_configuration.py
@@ -2219,47 +2219,20 @@ register_rule(group,
),
itemtype = "service")
-
-def list_user_icons_and_actions():
- choices = []
- for key, action in config.user_icons_and_actions.items():
- label = key
- if 'title' in action:
- label += ' - '+action['title']
- if 'url' in action:
- label += ' ('+action['url']+')'
-
- choices.append((key, label))
- return sorted(choices, key = lambda x: x[1])
-
-icon_upload_link_txt = \
- _("In order to be able to choose actions here, you need to "
- "<a href=\"%s\">define your own actions</a>.") % \
- "wato.py?mode=edit_configvar&varname=user_icons_and_actions"
-
register_rule(group,
"host_icons_and_actions",
- DropdownChoice(
+ UserIconOrAction(
title = _("Custom icons or actions for hosts in status GUI"),
- help = _("You can assign icons or actions to hosts for the status
GUI.") \
- + " " + icon_upload_link_txt,
- choices = list_user_icons_and_actions,
- allow_empty = False,
- empty_text = icon_upload_link_txt,
+ help = _("You can assign icons or actions to hosts for the status
GUI.")
),
match = "all",
)
-
register_rule(group,
"service_icons_and_actions",
- DropdownChoice(
+ UserIconOrAction(
title = _("Custom icons or actions for services in status GUI"),
- help = _("You can assign icons or actions to services for the status
GUI.") \
- + " " + icon_upload_link_txt,
- choices = list_user_icons_and_actions,
- allow_empty = False,
- empty_text = icon_upload_link_txt,
+ help = _("You can assign icons or actions to services for the status
GUI."),
),
match = "all",
itemtype = "service",
diff --git a/web/plugins/wato/check_parameters.py b/web/plugins/wato/check_parameters.py
index e255858..606f2c8 100644
--- a/web/plugins/wato/check_parameters.py
+++ b/web/plugins/wato/check_parameters.py
@@ -748,6 +748,10 @@ register_rule(group + '/' + subgroup_inventory,
'create duplicate services with the same description
otherwise.</p><p>Windows users are specified by the namespace followed by
'
'the actual user name. For example "\\\\NT
AUTHORITY\NETWORK SERVICE" or
"\\\\CHKMKTEST\Administrator".</p>'),
)),
+ ('icon', UserIconOrAction(
+ title = _("Add custom icon or action"),
+ help = _("You can assign icons or actions to the found services
in the status GUI."),
+ )),
('default_params',
Dictionary(
title = _("Default parameters for detected services"),
@@ -5881,7 +5885,12 @@ register_check_parameters(
title = _("State if no entry matches"),
default_value = 2,
),
- ),]
+ ),
+ ('icon', UserIconOrAction(
+ title = _("Add custom icon or action"),
+ help = _("You can assign icons or actions to the found services in the
status GUI."),
+ ))
+ ]
),
TextAscii(
title = _("Name of the service"),
@@ -7676,7 +7685,12 @@ register_check_parameters(
_("State and count of processes"),
Transform(
Dictionary(
- elements = process_level_elements,
+ elements = process_level_elements + [
+ ('icon', UserIconOrAction(
+ title = _("Add custom icon or action"),
+ help = _("You can assign icons or actions to the found services
in the status GUI."),
+ ))
+ ]
),
forth = ps_convert_from_singlekeys,
),
@@ -7745,6 +7759,10 @@ register_check_parameters(
match = lambda x: (not x and 2) or (x[0] == '~' and 1 or 0)
)),
+ ('icon', UserIconOrAction(
+ title = _("Add custom icon or action"),
+ help = _("You can assign icons or actions to the found services
in the status GUI."),
+ )),
] + process_level_elements,
# required_keys = [ "process" ],
),