Module: check_mk
Branch: master
Commit: 7acfb244a5de1c9fe406b20c6dd17215902b91bc
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=7acfb244a5de1c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Nov 24 22:32:02 2010 +0100
Multisite: icon from host to wato, improve wato snapin
---
LIESMICH.wato | 24 ------------------------
web/htdocs/.f12 | 6 +++---
web/htdocs/check_mk.js | 13 +++++++++++++
web/htdocs/images/icon_wato.gif | Bin 0 -> 1506 bytes
web/htdocs/sidebar.js | 12 ++++++------
web/plugins/pages/wato.py | 4 +++-
web/plugins/sidebar/shipped.py | 4 ++--
web/plugins/sidebar/wato.py | 18 ++++++++++++++++++
web/plugins/views/painters.py | 20 ++++++++++++++++++++
9 files changed, 65 insertions(+), 36 deletions(-)
diff --git a/LIESMICH.wato b/LIESMICH.wato
index c728808..1fd6469 100644
--- a/LIESMICH.wato
+++ b/LIESMICH.wato
@@ -1,21 +1,4 @@
* Integration mit Multisite:
- - Bei einem Host muss es einen Kontextknopf zur Konfig-GUI geben, falls
- dieser host per webconf erstellt wurde. Dabei muss ich den Site-Prefix
- benutzen. Problem: in sites muss ich einen neuen Schluessel einführen
- "link_base" oder "url_base" oder "url_prefix". Dieser
ersetzt dann
- nagios_url, etc. und wird einfach vor alles davor gehängt. Dabei muss
- ich auch http:// erlauben.
-
- Der Link erscheint nur, wenn:
- * der Host das Tag 'wato' hat.
- * der Benutzer das Rech 'use_wato' hat.
-
- In den Link wird der wato-Filename eingebaut, so dass man auf der
- richtigen Seite landet.
-
- Problem noch: Dafür brauche ich per Livestatus die Host-Tags.
- Die kann ich über die custom_attributes holen...
-
- Link von Webconf auf den Host in Nagios. Dazu muss ich die lokale
Site wissen (konfigurieren in multisite.mk)
@@ -23,10 +6,3 @@
* Doku
-* Multisite: Das Snapin sollte die Dateien von allen WATO-Sites
-anzeigen. Dazu kann die Liste der Sites durchgehen und für jede
-Site per AJAX einen Webservice abrufen, der die Liste der editierbaren
-Dateien anzeigt.
-
-
-
diff --git a/web/htdocs/.f12 b/web/htdocs/.f12
index 717bd0d..d836a21 100644
--- a/web/htdocs/.f12
+++ b/web/htdocs/.f12
@@ -1,7 +1,7 @@
#!/bin/bash
set -e
-sudo cp -r images *.css *.py /omd/versions/default/share/check_mk/web/htdocs
+sudo cp -r images *.css *.py *.js /omd/versions/default/share/check_mk/web/htdocs
sudo cp ../plugins/pages/*.py /omd/versions/default/share/check_mk/web/plugins/pages/
-sudo cp -v ../plugins/views/*.py /omd/versions/default/share/check_mk/web/plugins/views/
-sudo cp -v ../plugins/sidebar/*.py
/omd/versions/default/share/check_mk/web/plugins/sidebar/
+sudo cp ../plugins/views/*.py /omd/versions/default/share/check_mk/web/plugins/views/
+sudo cp ../plugins/sidebar/*.py
/omd/versions/default/share/check_mk/web/plugins/sidebar/
sudo omd restart wato apache
diff --git a/web/htdocs/check_mk.js b/web/htdocs/check_mk.js
index 99e1dfc..c3ee791 100644
--- a/web/htdocs/check_mk.js
+++ b/web/htdocs/check_mk.js
@@ -59,6 +59,19 @@ function get_url(url, handler, data, errorHandler) {
}
}
+function get_url_sync(url) {
+ if (window.XMLHttpRequest) {
+ var AJAX = new XMLHttpRequest();
+ } else {
+ var AJAX = new ActiveXObject("Microsoft.XMLHTTP");
+ }
+
+ AJAX.open("GET", url, false);
+ AJAX.send(null);
+ return AJAX.responseText;
+}
+
+
// ----------------------------------------------------------------------------
// GUI styling
// ----------------------------------------------------------------------------
diff --git a/web/htdocs/images/icon_wato.gif b/web/htdocs/images/icon_wato.gif
new file mode 100644
index 0000000..5aae7e8
Binary files /dev/null and b/web/htdocs/images/icon_wato.gif differ
diff --git a/web/htdocs/sidebar.js b/web/htdocs/sidebar.js
index a7431eb..9231551 100644
--- a/web/htdocs/sidebar.js
+++ b/web/htdocs/sidebar.js
@@ -623,12 +623,12 @@ function sidebar_scheduler() {
get_url(url, updateContents, "snapin_" + name);
}
}
- // Detect page changes and re-register the mousemove event handler
- // in the content frame. another bad hack ... narf
- if(contentLocation != parent.frames[1].document.location) {
- registerEdgeListeners(parent.frames[1]);
- contentLocation = parent.frames[1].document.location;
- }
+ // Detect page changes and re-register the mousemove event handler
+ // in the content frame. another bad hack ... narf
+ if (contentLocation != parent.frames[1].document.location) {
+ registerEdgeListeners(parent.frames[1]);
+ contentLocation = parent.frames[1].document.location;
+ }
setTimeout(function(){sidebar_scheduler();}, 1000);
}
diff --git a/web/plugins/pages/wato.py b/web/plugins/pages/wato.py
index 2183a40..0be87cd 100644
--- a/web/plugins/pages/wato.py
+++ b/web/plugins/pages/wato.py
@@ -1,5 +1,7 @@
import wato
+import sidebar
pagehandlers.update({
- "wato" : wato.page_index,
+ "wato" : wato.page_index,
+ "ajax_wato_files" : sidebar.ajax_wato_files,
})
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index bd7b9c8..a7f1a01 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -434,10 +434,10 @@ sidebar_snapins["sitestatus"] = {
.snapin table.sitestate td.online a { background-color: #3c0; color: #fff;
border-color: #0f0; }
.snapin table.sitestate td.disabled a { background-color: #666; color: #ccc;
border-color: #888; }
.snapin table.sitestate td.dead a { background-color: #c00; color: #f88;
border-color: #f44; }
-.snapin table.sitestate td.waiting a { background-color: #26c; color: #fff;
border-color: #44f; }
+.snapin table.sitestate td.waiting a { background-color: #666; color: #fff;
border-color: #ccc; }
.snapin table.sitestate td.down a { background-color: #f00; color: #fff;
border-color: #800; }
.snapin table.sitestate td.unreach a { background-color: #f80; color: #fff;
border-color: #840; }
-.snapin table.sitestate td.unknown a { background-color: #62d; color: #fff;
border-color: #8ff; }
+.snapin table.sitestate td.unknown a { background-color: #26c; color: #fff;
border-color: #44f; }
""" % snapin_width
}
diff --git a/web/plugins/sidebar/wato.py b/web/plugins/sidebar/wato.py
index 066cab6..f40a7bb 100644
--- a/web/plugins/sidebar/wato.py
+++ b/web/plugins/sidebar/wato.py
@@ -11,10 +11,28 @@ def render_wato_files():
"in <tt>multisite.mk</tt>.")
else:
+ if config.is_multisite():
+ sitenames = config.sites.keys()
+ sitenames.sort()
+ for sitename in sitenames:
+ site = config.sites[sitename]
+ state = html.site_status[sitename]["state"]
+ if state != "disabled":
+ html.write("<h3>%s</h3>\n" %
site["alias"])
+ ajax_url = site["url_prefix"] +
"check_mk/ajax_wato_files.py"
+
html.javascript("document.write(get_url_sync('%s'));" % ajax_url)
+ else:
+ ajax_wato_files(html)
+
+def ajax_wato_files(h):
+ global html
+ html = h
+ if config.may("use_wato"):
for filename, title, roles in config.config_files:
if config.role in roles:
bulletlink(title, "wato.py?filename=%s" % filename)
+
sidebar_snapins["wato"] = {
"title" : "Check_MK Web Administration Tool",
"description" : "WATO - the Web Administration Tool of Check_MK -
manage hosts to be monitored without access to the command line",
diff --git a/web/plugins/views/painters.py b/web/plugins/views/painters.py
index 4f6c448..7694c6d 100644
--- a/web/plugins/views/painters.py
+++ b/web/plugins/views/painters.py
@@ -75,6 +75,10 @@ icon_columns = [ "acknowledged",
"scheduled_downtime_depth", "downtimes_with_inf
"accept_passive_checks", "action_url_expanded",
"notes_url_expanded", "in_notification_period",
"custom_variable_names", "custom_variable_values" ]
+def wato_link(filename, site, hostname):
+ prefix = config.site(site)["url_prefix"] + "check_mk/"
+ return prefix + "wato.py?filename=%s&host=%s&mode=edithost" %
(htmllib.urlencode(filename), htmllib.urlencode(hostname))
+
def paint_icons(what, row): # what is "host" or "service"
output = ""
if what == "host":
@@ -90,6 +94,12 @@ def paint_icons(what, row): # what is "host" or
"service"
output += link_to_view("<img class=icon title='Detailed host
infos' src='images/icon_detail.gif'>",
newrow, 'host')
+ # Extract host tags
+ if "TAGS" in custom_vars:
+ tags = custom_vars["TAGS"].split()
+ else:
+ tags = []
+
# action_url
if row[prefix + "action_url_expanded"]:
output += "<a href='%s'><img class=icon
src=\"images/icon_action.gif\"></a>" % row[prefix +
"action_url_expanded"]
@@ -142,6 +152,16 @@ def paint_icons(what, row): # what is "host" or
"service"
if not row[prefix + "in_notification_period"]:
output += '<img class=icon title="Out of notification period"
src="images/icon_outofnot.gif">'
+ # Link to WATO
+ if "wato" in tags and what == "host":
+ for tag in tags:
+ if tag.endswith(".mk"):
+ wato_filename = tag
+ output += '<a href="%s"><img class=icon
src="images/icon_wato.gif" ' \
+ 'title="Open this host in WATO - the Check_MK Web
Administration Tool"></a>' % \
+ wato_link(wato_filename, row["site"],
row["host_name"])
+ break
+
return "icons", output
def iconpainter_columns(what):