Module: check_mk
Branch: master
Commit: 337e8d5b61ad41fcc91479e8bd49cb32d169706e
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=337e8d5b61ad41…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Dec 3 17:27:54 2010 +0100
Added javascript code to new active service reschedule feature
---
web/htdocs/check_mk.js | 44 ++++++++++++++++++++++++++++++
web/htdocs/images/icon_reload.gif | Bin 0 -> 1852 bytes
web/htdocs/images/icon_reload_failed.gif | Bin 0 -> 1869 bytes
web/plugins/views/painters.py | 8 +++++
4 files changed, 52 insertions(+), 0 deletions(-)
diff --git a/web/htdocs/check_mk.js b/web/htdocs/check_mk.js
index c3ee791..1186fa8 100644
--- a/web/htdocs/check_mk.js
+++ b/web/htdocs/check_mk.js
@@ -185,3 +185,47 @@ function render_pnp_graphs(container, site, host, service, base_url,
pnp_url) {
get_url(pnp_url + 'index.php/json?&host=' + host + '&srv=' +
service + '&source=0',
pnp_response_handler, data, pnp_error_response_handler);
}
+
+// ----------------------------------------------------------------------------
+// Synchronous action handling
+// ----------------------------------------------------------------------------
+// Protocol is:
+// For regular response:
+// [ 'OK', 'last check', 'exit status plugin', 'output'
]
+// For timeout:
+// [ 'TIMEOUT', 'output' ]
+// For error:
+// [ 'ERROR', 'output' ]
+// Everything else:
+// <undefined> - Unknown format. Simply echo.
+
+function performAction(oLink, action, type, site, name1, name2) {
+ var oImg = oLink.childNodes[0];
+ oImg.src = 'images/icon_reloading.gif';
+
+ var validResponse = true;
+ var response =
get_url_sync('nagios_action.py?action='+action+'&site='+site+'&host='+name1+'&service='+name2);
+
+ try {
+ response = eval(response);
+ } catch(e) {
+ validResponse = false;
+ }
+
+ if(validResponse && response[0] === 'OK') {
+ oImg.src = 'images/icon_reload.gif';
+ window.location.reload();
+ } else if(validResponse && response[0] === 'TIMEOUT') {
+ oImg.src = 'images/icon_reload_failed.gif';
+ } else if(validResponse) {
+ oImg.src = 'images/icon_reload_failed.gif';
+ alert('Problem while processing - Response: ' + response.join('
'));
+ } else {
+ oImg.src = 'images/icon_reload_failed.gif';
+ alert('Invalid response: ' + response);
+ }
+
+ validResponse = null;
+ response = null;
+ oImg = null;
+}
diff --git a/web/htdocs/images/icon_reload.gif b/web/htdocs/images/icon_reload.gif
new file mode 100644
index 0000000..db29279
Binary files /dev/null and b/web/htdocs/images/icon_reload.gif differ
diff --git a/web/htdocs/images/icon_reload_failed.gif
b/web/htdocs/images/icon_reload_failed.gif
new file mode 100644
index 0000000..32e5f0e
Binary files /dev/null and b/web/htdocs/images/icon_reload_failed.gif differ
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 0df84ef..5bf7e00 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -179,6 +179,14 @@ def paint_icons(what, row): # what is "host" or
"service"
if wato_filename:
output += wato_link(wato_filename, row["site"],
row["host_name"], "inventory")
+ if row[prefix + "active_checks_enabled"] == 1 and
config.may('action.reschedule'):
+ name2 = ''
+ if what == 'service':
+ name2 = row['service_description']
+ output += '<a href=\"#\" onclick="performAction(this,
\'reschedule\', \'%s\', \'%s\', \'%s\',
\'%s\');">' \
+ '<img class=icon title="Reschedule a check of this
service" ' \
+ 'src="images/icon_reload.gif"></a>' % (what,
row["site"], row["host_name"], name2)
+
return "icons", output
def iconpainter_columns(what):