Module: check_mk
Branch: master
Commit: 05591cd0fed7becb536eb2ff633c12e27cd09fde
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=05591cd0fed7be…
Author: Lars Michelsen <lm(a)mathias-kettner.de>
Date: Fri Nov 8 10:21:59 2013 +0100
FIX Fixed locking issue on host diagnose page
---
.werks/48 | 8 +++++
ChangeLog | 3 +-
web/htdocs/js/wato.js | 2 +-
web/htdocs/wato.py | 86 ++++++++++++++++++++++++++++-----------------
web/plugins/pages/wato.py | 1 +
5 files changed, 65 insertions(+), 35 deletions(-)
diff --git a/.werks/48 b/.werks/48
new file mode 100644
index 0000000..416f020
--- /dev/null
+++ b/.werks/48
@@ -0,0 +1,8 @@
+Title: Fixed locking issue on host diagnose page
+Level: 1
+Component: wato
+Version: 1.2.3i7
+Date: 1383902500
+Class: fix
+
+
diff --git a/ChangeLog b/ChangeLog
index 42fffe9..87f435a 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -17,6 +17,7 @@
WATO:
* 0053 New rule for configuring the display_name of a service...
+ * 0048 FIX: Fixed locking issue on host diagnose page...
Reporting & Availability:
* 0051 Option for showing timeline directly in availability table...
@@ -155,7 +156,7 @@
* Disabled replication type "peer" in site editor.
* Added "permanently ignore" button to inventory services dialog which
links directly to the disabled services view
- * Added dignose page linked from host edit dialog. This can be used to test
+ * Added diagnose page linked from host edit dialog. This can be used to test
connection capabilities of hosts
* The rule "Process inventory" now offers the same configuration options
as its manual check equivalent "State and count of processes"
diff --git a/web/htdocs/js/wato.js b/web/htdocs/js/wato.js
index f4dcdd6..e4ace12 100644
--- a/web/htdocs/js/wato.js
+++ b/web/htdocs/js/wato.js
@@ -748,7 +748,7 @@ function start_host_diag_test(ident, hostname) {
img.src = "images/icon_loading.gif";
log.innerHTML = "...";
- get_url("wato.py?mode=diag_host&host=" + escape(hostname) +
"&_test=" + escape(ident)
+ get_url("wato_ajax_diag_host.py?host=" + escape(hostname) +
"&_test=" + escape(ident)
+ '&_transid=-1' + vars,
handle_host_diag_result, ident);
}
diff --git a/web/htdocs/wato.py b/web/htdocs/wato.py
index 7deb2f0..16501a8 100644
--- a/web/htdocs/wato.py
+++ b/web/htdocs/wato.py
@@ -2187,6 +2187,15 @@ def delete_host_after_confirm(delname):
# | Verify or find out a hosts agent related configuration. |
# '----------------------------------------------------------------------'
+def diag_host_tests():
+ return [
+ ('ping', _('Ping')),
+ ('agent', _('Agent')),
+ ('snmpv1', _('SNMPv1')),
+ ('snmpv2', _('SNMPv2c')),
+ ('snmpv2_nobulk', _('SNMPv2c (without Bulkwalk)'))
+ ]
+
def mode_diag_host(phase):
hostname = html.var("host")
if not hostname:
@@ -2261,14 +2270,6 @@ def mode_diag_host(phase):
]
)
- tests = [
- ('ping', _('Ping')),
- ('agent', _('Agent')),
- ('snmpv1', _('SNMPv1')),
- ('snmpv2', _('SNMPv2c')),
- ('snmpv2_nobulk', _('SNMPv2c (without Bulkwalk)'))
- ]
-
host = g_folder[".hosts"].get(hostname)
if not host:
@@ -2280,30 +2281,7 @@ def mode_diag_host(phase):
if not html.check_transaction():
return
- _test = html.var('_test')
- if _test:
- # Execute a specific test
- try:
- if _test not in dict(tests).keys():
- raise MKGeneralException(_('Invalid test.'))
- args = [
- html.var('ipaddress'),
- html.var('snmp_community'),
- html.var('agent_port'),
- html.var('snmp_timeout'),
- html.var('snmp_retries'),
- html.var('datasource_program'),
- ]
- result = check_mk_automation(host[".siteid"],
"diag-host", [hostname, _test] + args)
- except Exception, e:
- result = (1, _("Exception: %s") % html.attrencode(str(e)))
- # API is defined as follows: Two data fields, separated by space.
- # First is the state: 0 or 1, 0 means success, 1 means failed.
- # Second is treated as text output
- html.write("%s %s" % (result[0], html.attrencode(result[1])))
- return ""
-
- elif html.var('_save'):
+ if html.var('_save'):
# Save the ipaddress and/or community
mark_affected_sites_dirty(g_folder, hostname)
@@ -2358,7 +2336,7 @@ def mode_diag_host(phase):
'connection options you like to try on the right side of the
screen and '
'press the "Test" button. The results will be
displayed here.'))
else:
- for ident, title in tests:
+ for ident, title in diag_host_tests():
html.write('<h3>%s</h3>' % title)
html.write('<table class="data test"><tr
class="data odd0">')
html.write('<td class="icons"><div>')
@@ -2374,6 +2352,48 @@ def mode_diag_host(phase):
html.write('</td></tr></table>')
html.write('</div>')
+def ajax_diag_host():
+ try:
+ if not html.check_transaction():
+ return
+
+ if not config.may('wato.diag_host'):
+ raise MKAuthException(_('You are not permitted to perform this
action.'))
+
+ hostname = html.var("host")
+ if not hostname:
+ raise MKGeneralException(_('The hostname is missing.'))
+
+ host = g_folder[".hosts"].get(hostname)
+
+ if not host:
+ raise MKGeneralException(_('The given host does not exist.'))
+ if ".nodes" in host:
+ raise MKGeneralException(_('This view does not support cluster
hosts.'))
+
+ _test = html.var('_test')
+ if not _test:
+ raise MKGeneralException(_('The test is missing.'))
+
+ # Execute a specific test
+ if _test not in dict(diag_host_tests()).keys():
+ raise MKGeneralException(_('Invalid test.'))
+ args = [
+ html.var('ipaddress'),
+ html.var('snmp_community'),
+ html.var('agent_port'),
+ html.var('snmp_timeout'),
+ html.var('snmp_retries'),
+ html.var('datasource_program'),
+ ]
+ result = check_mk_automation(host[".siteid"], "diag-host",
[hostname, _test] + args)
+ # API is defined as follows: Two data fields, separated by space.
+ # First is the state: 0 or 1, 0 means success, 1 means failed.
+ # Second is treated as text output
+ html.write("%s %s" % (result[0], html.attrencode(result[1])))
+ except Exception, e:
+ html.write("1 %s" % _("Exception: %s") %
html.attrencode(str(e)))
+
#.
# .-Inventory & Services-------------------------------------------------.
# | ____ _ |
diff --git a/web/plugins/pages/wato.py b/web/plugins/pages/wato.py
index 4a41a14..bd2eb18 100644
--- a/web/plugins/pages/wato.py
+++ b/web/plugins/pages/wato.py
@@ -34,4 +34,5 @@ pagehandlers.update({
"automation" : wato.page_automation,
"user_profile" : wato.page_user_profile,
"ajax_set_foldertree" : wato.ajax_set_foldertree,
+ "wato_ajax_diag_host" : wato.ajax_diag_host,
})