Module: check_mk
Branch: master
Commit: bf7a1ae11b9601f7631a2827f85a87d4177f19f1
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=bf7a1ae11b9601…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 23 14:01:38 2011 +0100
Adding reschedule icon to all Check_MK based services. Clicks on these
icons will simply trigger a reschedule of the Check_MK service
---
ChangeLog | 2 ++
web/htdocs/actions.py | 12 ++++++++++--
web/htdocs/images/icon_reload_cmk.gif | Bin 0 -> 1800 bytes
web/htdocs/js/check_mk.js | 15 ++++++++++-----
web/plugins/icons/builtin.py | 22 +++++++++++++++++-----
5 files changed, 39 insertions(+), 12 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 9539d76..c4b9d86 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -10,6 +10,8 @@
Multisite:
* Several cleanups to prevent css/js warning messages in e.g. Firefox
* Made texts in selectable rows selectable again
+ * Adding reschedule icon to all Check_MK based services. Clicks on these
+ icons will simply trigger a reschedule of the Check_MK service
* FIX: ship missing CSS files for mobile GUI
WATO:
diff --git a/web/htdocs/actions.py b/web/htdocs/actions.py
index 45228d1..3d26902 100644
--- a/web/htdocs/actions.py
+++ b/web/htdocs/actions.py
@@ -46,15 +46,23 @@ def action_reschedule():
host = html.var("host", "")
if not host:
raise MKGeneralException("Action reschedule: missing host name")
- service = html.var("service", "")
+
+ service = html.var("service", "")
+ wait_svc = html.var("wait_svc", "")
+
if service:
what = "service"
spec = "%s;%s" % (host, service)
+ if wait_svc:
+ wait_spec = '%s;%s' % (host, wait_svc)
+ else:
+ wait_spec = spec
cmd = "SVC"
add_filter = "Filter: service_description = %s\n" % service
else:
what = "host"
spec = host
+ wait_spec = spec
cmd = "HOST"
add_filter = ""
@@ -70,7 +78,7 @@ def action_reschedule():
"WaitTrigger: check\n"
"Columns: last_check state plugin_output\n"
"Filter: host_name = %s\n%s"
- % (what, spec, now, config.reschedule_timeout * 1000, host, add_filter))
+ % (what, wait_spec, now, config.reschedule_timeout * 1000, host,
add_filter))
html.live.set_only_sites()
last_check = row[0]
if last_check < now:
diff --git a/web/htdocs/images/icon_reload_cmk.gif
b/web/htdocs/images/icon_reload_cmk.gif
new file mode 100644
index 0000000..eae1235
Binary files /dev/null and b/web/htdocs/images/icon_reload_cmk.gif differ
diff --git a/web/htdocs/js/check_mk.js b/web/htdocs/js/check_mk.js
index caa8e14..a8737b8 100644
--- a/web/htdocs/js/check_mk.js
+++ b/web/htdocs/js/check_mk.js
@@ -441,16 +441,21 @@ function actionResponseHandler(oImg, code) {
oImg = null;
}
-function performAction(oLink, action, site, host, service) {
+function performAction(oLink, action, site, host, service, wait_svc) {
var oImg = oLink.childNodes[0];
- oImg.src = 'images/icon_reloading.gif';
+
+ if(wait_svc != service)
+ oImg.src = 'images/icon_reloading_cmk.gif';
+ else
+ oImg.src = 'images/icon_reloading.gif';
// Chrome and IE are not animating the gif during sync ajax request
// So better use the async request here
get_url('nagios_action.py?action=' + action +
- '&site=' + escape(site) +
- '&host=' + escape(host) +
- '&service=' + escape(service),
+ '&site=' + escape(site) +
+ '&host=' + escape(host) +
+ '&service=' + escape(service) +
+ '&wait_svc=' + escape(wait_svc),
actionResponseHandler, oImg);
oImg = null;
}
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index 60b4b03..9ae167b 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -416,16 +416,28 @@ multisite_icons.append({
def paint_reschedule(what, row, tags, custom_vars):
# Reschedule button
- if row[what + "_active_checks_enabled"] == 1 \
+ if (row[what + "_active_checks_enabled"] == 1
+ or row[what + '_check_command'].startswith('check_mk-')) \
and config.may('action.reschedule'):
+
servicedesc = ''
+ wait_svc = ''
+ icon = 'icon_reload'
+
if what == 'service':
servicedesc = row['service_description']
+ wait_svc = servicedesc
+
+ # Use Check_MK service for cmk based services
+ if row[what + '_check_command'].startswith('check_mk-'):
+ servicedesc = 'Check_MK'
+ icon = 'icon_reload_cmk'
+
return '<a href=\"javascript:void(0);\" ' \
- 'onclick="performAction(this, \'reschedule\',
\'%s\', \'%s\', \'%s\');">' \
- '<img class=icon title="%s"
src="images/icon_reload.gif" /></a>' % \
- (row["site"], row["host_name"], servicedesc,
- (_('Reschedule an immediate check of this %s') % _(what)))
+ 'onclick="performAction(this, \'reschedule\',
\'%s\', \'%s\', \'%s\', \'%s\');">' \
+ '<img class=icon title="%s" src="images/%s.gif"
/></a>' % \
+ (row["site"], row["host_name"], servicedesc,
wait_svc,
+ (_('Reschedule an immediate check of this %s') % _(what)), icon)
multisite_icons.append({
'columns': [ 'active_checks_enabled' ],