Module: check_mk
Branch: master
Commit: 1722def8205559d367489e942a01db065fa5e8eb
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=1722def8205559…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Mon Mar 25 12:29:59 2013 +0100
FIX: fix rescheduling icon for services with non-ASCII characters
---
ChangeLog | 1 +
web/htdocs/actions.py | 26 +++++++++++++-------------
web/htdocs/js/checkmk.js | 4 ++--
web/htdocs/livestatus.py | 4 ++++
web/plugins/icons/builtin.py | 2 +-
5 files changed, 21 insertions(+), 16 deletions(-)
diff --git a/ChangeLog b/ChangeLog
index 7f073bc..4360157 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -100,6 +100,7 @@
Multisite:
* FIX: Avoid duplicate "Services" button in host detail views
+ * FIX: fix rescheduling icon for services with non-ASCII characters
* New filter for IP address of a host
* Quicksearch: allow searching for complete IP addresses and IP
address prefixes
diff --git a/web/htdocs/actions.py b/web/htdocs/actions.py
index 634a1cc..20e9ebd 100644
--- a/web/htdocs/actions.py
+++ b/web/htdocs/actions.py
@@ -47,16 +47,16 @@ def action_reschedule():
if not host:
raise MKGeneralException("Action reschedule: missing host name")
- service = html.var("service", "")
- wait_svc = html.var("wait_svc", "")
+ service = html.var_utf8("service", "")
+ wait_svc = html.var_utf8("wait_svc", "")
if service:
cmd = "SVC"
what = "service"
- spec = "%s;%s" % (host, service)
+ spec = "%s;%s" % (host, service.encode("utf-8"))
if wait_svc:
- wait_spec = '%s;%s' % (host, wait_svc)
+ wait_spec = u'%s;%s' % (host, wait_svc)
add_filter = "Filter: service_description = %s\n" % wait_svc
else:
wait_spec = spec
@@ -72,15 +72,15 @@ def action_reschedule():
now = int(time.time())
html.live.command("[%d] SCHEDULE_FORCED_%s_CHECK;%s;%d" % (now, cmd,
spec, now), site)
html.live.set_only_sites([site])
- row = html.live.query_row(
- "GET %ss\n"
- "WaitObject: %s\n"
- "WaitCondition: last_check >= %d\n"
- "WaitTimeout: %d\n"
- "WaitTrigger: check\n"
- "Columns: last_check state plugin_output\n"
- "Filter: host_name = %s\n%s"
- % (what, wait_spec, now, config.reschedule_timeout * 1000, host,
add_filter))
+ query = u"GET %ss\n" \
+ "WaitObject: %s\n" \
+ "WaitCondition: last_check >= %d\n" \
+ "WaitTimeout: %d\n" \
+ "WaitTrigger: check\n" \
+ "Columns: last_check state plugin_output\n" \
+ "Filter: host_name = %s\n%s" \
+ % (what, wait_spec, now, config.reschedule_timeout * 1000, host,
add_filter)
+ row = html.live.query_row(query)
html.live.set_only_sites()
last_check = row[0]
if last_check < now:
diff --git a/web/htdocs/js/checkmk.js b/web/htdocs/js/checkmk.js
index c46bf09..46d5cae 100644
--- a/web/htdocs/js/checkmk.js
+++ b/web/htdocs/js/checkmk.js
@@ -599,8 +599,8 @@ function performAction(oLink, action, site, host, service, wait_svc)
{
get_url('nagios_action.py?action=' + action +
'&site=' + escape(site) +
'&host=' + escape(host) +
- '&service=' + escape(service) +
- '&wait_svc=' + escape(wait_svc),
+ '&service=' + service + // Already URL-encoded!
+ '&wait_svc=' + wait_svc,
actionResponseHandler, oImg);
oImg = null;
}
diff --git a/web/htdocs/livestatus.py b/web/htdocs/livestatus.py
index e4a3c12..6823873 100644
--- a/web/htdocs/livestatus.py
+++ b/web/htdocs/livestatus.py
@@ -273,6 +273,10 @@ class BaseConnection:
query += "\n"
try:
+ # socket.send() will implicitely cast to str(), we need ot
+ # convert to UTF-8 in order to avoid exceptions
+ if type(query) == unicode:
+ query = query.encode("utf-8")
self.socket.send(query)
except IOError, e:
if self.persist:
diff --git a/web/plugins/icons/builtin.py b/web/plugins/icons/builtin.py
index a7abd15..80188b8 100644
--- a/web/plugins/icons/builtin.py
+++ b/web/plugins/icons/builtin.py
@@ -109,7 +109,7 @@ def paint_reschedule(what, row, tags, custom_vars):
return '<a href=\"javascript:void(0);\" ' \
'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, txt, icon)
+ (row["site"], row["host_name"],
htmllib.urlencode(servicedesc), htmllib.urlencode(wait_svc), txt, icon)
multisite_icons.append({
'columns': [ 'active_checks_enabled' ],