Module: check_mk
Branch: master
Commit: 100bee7558d4c65a7c7188dd0b1417bfbcc93b17
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=100bee7558d4c6…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Wed Apr 20 13:31:07 2016 +0200
Added new treasure for creating customized Tactical Overview snapins
---
doc/treasures/sidebar_tactical_overview.py | 29 ++++++++++++++++++++++
web/plugins/sidebar/shipped.py | 37 ++++++++++++++++------------
2 files changed, 50 insertions(+), 16 deletions(-)
diff --git a/doc/treasures/sidebar_tactical_overview.py
b/doc/treasures/sidebar_tactical_overview.py
new file mode 100644
index 0000000..dcaeb7d
--- /dev/null
+++ b/doc/treasures/sidebar_tactical_overview.py
@@ -0,0 +1,29 @@
+#!/usr/bin/python
+# -*- encoding: utf-8; py-indent-offset: 4 -*-
+
+# Put this into local/share/check_mk/web/plugins/sidebar. And you will get
+# additional versions of "Tactical Overview" for hosts having a certain
+# tag.
+
+def create_tactical_overview_snapin(title, tag_group, tag_name):
+ def create_render_function(tag_group, tag_name):
+ return lambda: render_tactical_overview(
+ extra_filter_headers = "Filter: host_custom_variables ~ TAGS (^|[
])%s($|[ ])\n" % tag_name,
+ extra_url_variables = [
+ ( "host_tag_0_grp", tag_group ),
+ ( "host_tag_0_op", "is" ),
+ ( "host_tag_0_val", tag_name ),
+ ])
+
+ sidebar_snapins["tactical_overview_" + tag_name] = {
+ "title" : title,
+ "description" : _("Tactical overview of all hosts with the tag
%s") % tag_name,
+ "refresh" : True,
+ "render" : create_render_function(tag_group, tag_name),
+ "allowed" : [ "user", "admin", "guest"
],
+ "styles" : snapin_tactical_overview_styles,
+ }
+
+# Here you declare which copies of the snapin you wnat:
+create_tactical_overview_snapin(u"München", "stadt",
"muc")
+create_tactical_overview_snapin(u"Göttingen", "stadt",
"got")
diff --git a/web/plugins/sidebar/shipped.py b/web/plugins/sidebar/shipped.py
index 941c599..9dbe220 100644
--- a/web/plugins/sidebar/shipped.py
+++ b/web/plugins/sidebar/shipped.py
@@ -549,7 +549,7 @@ table.sitestate td.state {
# | |
# '----------------------------------------------------------------------'
-def render_tactical_overview():
+def render_tactical_overview(extra_filter_headers="", extra_url_variables=[]):
host_query = \
"GET hosts\n" \
"Stats: state >= 0\n" \
@@ -560,7 +560,8 @@ def render_tactical_overview():
"Stats: scheduled_downtime_depth = 0\n" \
"Stats: acknowledged = 0\n" \
"StatsAnd: 3\n" \
- "Filter: custom_variable_names < _REALNAME\n"
+ "Filter: custom_variable_names < _REALNAME\n" + \
+ extra_filter_headers
service_query = \
"GET services\n" \
@@ -576,9 +577,8 @@ def render_tactical_overview():
"Stats: acknowledged = 0\n" \
"Stats: host_state = 0\n" \
"StatsAnd: 5\n" \
- "Filter: host_custom_variable_names < _REALNAME\n"
-
- # ACHTUNG: Stats-Filter so anpassen, dass jeder Host gezaehlt wird.
+ "Filter: host_custom_variable_names < _REALNAME\n" + \
+ extra_filter_headers
try:
hstdata = sites.live().query_summed_stats(host_query)
@@ -594,25 +594,21 @@ def render_tactical_overview():
html.write("<tr><th>%s</th><th>%s</th><th>%s</th></tr>\n"
% (title, _('Problems'), _('Unhandled')))
html.write("<tr>")
- html.write('<td class=total><a target="main"
href="view.py?view_name=all%ss">%d</a></td>' % (what,
data[0]))
+ url = html.makeuri_contextless([("view_name", "all" + what +
"s")] + extra_url_variables, filename="view.py")
+ html.write('<td class=total><a target="main"
href="%s">%d</a></td>' % (url, data[0]))
unhandled = False
for value in data[1:]:
- href = "view.py?view_name=" + view
+ url = html.makeuri_contextless([("view_name", view)] +
extra_url_variables, filename="view.py")
if unhandled:
- href += "&is_%s_acknowledged=0" % what
- text = link(str(value), href)
+ url += "&is_%s_acknowledged=0" % what
+ text = link(str(value), url)
html.write('<td class="%s">%s</td>' % (value ==
0 and " " or "states prob", text))
unhandled = True
html.write("</tr>\n")
html.write("</table>\n")
-sidebar_snapins["tactical_overview"] = {
- "title" : _("Tactical Overview"),
- "description" : _("The total number of hosts and service with and
without problems"),
- "refresh" : True,
- "render" : render_tactical_overview,
- "allowed" : [ "user", "admin", "guest" ],
- "styles" : """
+
+snapin_tactical_overview_styles = """
table.tacticaloverview {
border-collapse: separate;
/**
@@ -647,6 +643,15 @@ table.tacticaloverview td.prob {
}
table.tacticaloverview a { display: block; margin-right: 2px; }
""" % snapin_width
+
+
+sidebar_snapins["tactical_overview"] = {
+ "title" : _("Tactical Overview"),
+ "description" : _("The total number of hosts and service with and
without problems"),
+ "refresh" : True,
+ "render" : render_tactical_overview,
+ "allowed" : [ "user", "admin", "guest" ],
+ "styles" : snapin_tactical_overview_styles,
}
#.