Module: check_mk
Branch: master
Commit: ec43ac35281a5e3df326d90e8596ba63c368dc71
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=ec43ac35281a5e…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Dec 5 12:04:56 2013 +0100
New option for displaying a legend for the colors used in the timeline
The availability has now a new labelling option <i>Display legend for
timeline</i>. If this is
enabled and a timeline is being displayed, then at the end of the page a small legend is
shown,
which explains all of the possible colors in the timeline.
---
.werks/18 | 10 ++++++++++
ChangeLog | 1 +
web/htdocs/views.css | 31 +++++++++++++++++-----------
web/plugins/views/availability.py | 40 ++++++++++++++++++++++++++++++-------
4 files changed, 63 insertions(+), 19 deletions(-)
diff --git a/.werks/18 b/.werks/18
new file mode 100644
index 0000000..9a478fe
--- /dev/null
+++ b/.werks/18
@@ -0,0 +1,10 @@
+Title: New option for displaying a legend for the colors used in the timeline
+Level: 1
+Component: reporting
+Version: 1.2.3i7
+Date: 1386241423
+Class: feature
+
+The availability has now a new labelling option <i>Display legend for
timeline</i>. If this is
+enabled and a timeline is being displayed, then at the end of the page a small legend is
shown,
+which explains all of the possible colors in the timeline.
diff --git a/ChangeLog b/ChangeLog
index 3cd8047..d116059 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -111,6 +111,7 @@
* 0055 Allow grouping by host, host group or service group...
* 0056 New concept of service periods in availability reporting...
* 0002 You can now annotate events in the availability reporting...
+ * 0018 New option for displaying a legend for the colors used in the timeline...
* 0014 FIX: Fix styling of tables: always use complete width...
* 0015 FIX: Fixed summary computation in availability when grouping is used...
diff --git a/web/htdocs/views.css b/web/htdocs/views.css
index 473e2a5..1b2e0a0 100644
--- a/web/htdocs/views.css
+++ b/web/htdocs/views.css
@@ -505,24 +505,24 @@ table.data.availability tr.summary td {
padding-top: 1px;
}
-table.data td.flapping, table.timeline td.flapping {
+table.data td.flapping, table.timeline td.flapping, div.avlegend.timeline
div.state.flapping {
/* background-image: url("images/bg_flapping.png");
background-repeat: repeat; */
background-color: #f0f;
}
-table.data td.downtime, table.timeline td.downtime {
+table.data td.downtime, table.timeline td.downtime, div.avlegend.timeline
div.state.downtime {
background-color: #0af;
}
-table.data td.hostdown, table.timeline td.hostdown {
+table.data td.hostdown, table.timeline td.hostdown, div.avlegend.timeline
div.state.hostdown {
background-color: #048;
color: white;
}
-table.data td.unmonitored, table.timeline td.unmonitored {
+table.data td.unmonitored, table.timeline td.unmonitored, div.avlegend.timeline
div.state.unmonitored {
background-color: #cacaca;
color: #888;
}
-table.timeline td.ooservice {
+table.timeline td.ooservice, div.avlegend.timeline div.state.ooservice {
background-color: #cacaca;
background-image: url("images/ooservice.png");
background-repeat: repeat;
@@ -635,7 +635,7 @@ table.data.timewarp {
margin-bottom: 20px;
}
-div.av_levels_legend {
+div.avlegend {
background-image: url("images/white_20percent.png");
background-repeat: repeat;
padding: 5px 15px;
@@ -643,26 +643,33 @@ div.av_levels_legend {
margin-top: 10px;
text-align: right;
}
-div.av_levels_legend h3 {
+div.avlegend h3 {
margin-top: 0px;
font-size: 13px;
color: black;
}
-div.av_levels_legend div {
+div.avlegend div {
display: inline-block;
width: 50px;
white-space: nowrap;
margin-right: 5px;
}
-div.av_levels_legend div.state {
+div.avlegend div.state {
text-align: center;
padding: 2px 0px;
font-size: 12px;
}
-div.av_levels_legend div.level {
+div.avlegend div:last-child {
+ margin-right: 0px;
+}
+div.avlegend.levels div.level {
margin-right: 15px;
color: black;
}
-div.av_levels_legend div:last-child {
- margin-right: 0px;
+
+div.avlegend.timeline div.state {
+ width: 75px;
+}
+div.avlegend.timeline div.state.ooservice {
+ color: black;
}
diff --git a/web/plugins/views/availability.py b/web/plugins/views/availability.py
index 1c0fb97..ba300b7 100644
--- a/web/plugins/views/availability.py
+++ b/web/plugins/views/availability.py
@@ -134,9 +134,10 @@ avoption_entries = [
ListChoice(
title = _("Labelling Options"),
choices = [
- ( "omit_host", _("Do not display the host
name")),
- ( "use_display_name", _("Use alternative display name for
services")),
- ( "omit_buttons", _("Do not display icons for history and
timeline")),
+ ( "omit_host", _("Do not display the host
name")),
+ ( "use_display_name", _("Use alternative display name
for services")),
+ ( "omit_buttons", _("Do not display icons for
history and timeline")),
+ ( "display_timeline_legend", _("Display legend for
timeline")),
]
)
),
@@ -789,7 +790,7 @@ def do_render_availability(rows, what, avoptions, timeline,
timewarpcode):
if timeline:
render_timeline(timeline_rows, from_time, until_time, total_duration,
- timeline, range_title, render_number, what, timewarpcode,
style="standalone")
+ timeline, range_title, render_number, what, timewarpcode,
avoptions, style="standalone")
else:
render_availability_table(availability, from_time, until_time, range_title, what,
avoptions, render_number)
@@ -798,7 +799,7 @@ def do_render_availability(rows, what, avoptions, timeline,
timewarpcode):
# style is either inline (just the timeline bar) or "standalone" (the complete
page)
def render_timeline(timeline_rows, from_time, until_time, considered_duration,
- timeline, range_title, render_number, what, timewarpcode, style):
+ timeline, range_title, render_number, what, timewarpcode, avoptions,
style):
if not timeline_rows:
html.write('<div class=info>%s</div>' % _("No
information available"))
return
@@ -879,6 +880,11 @@ def render_timeline(timeline_rows, from_time, until_time,
considered_duration,
table.end()
+ # Legend for timeline
+ if "display_timeline_legend" in avoptions["labelling"]:
+ render_timeline_legend(what)
+
+
def render_timeline_choords(from_time, until_time, width):
duration = until_time - from_time
def render_choord(t, title):
@@ -1071,13 +1077,33 @@ def render_availability_table(availability, from_time, until_time,
range_title,
av_levels = avoptions["av_levels"]
if av_levels:
warn, crit = av_levels
- html.write('<div class="av_levels_legend">')
+ html.write('<div class="avlegend levels">')
html.write('<h3>%s</h3>' % _("Availability
levels"))
html.write('<div class="state state0">%s</div><div
class=level>≥ %.3f%%</div>' % (_("OK"), warn))
html.write('<div class="state state1">%s</div><div
class=level>≥ %.3f%%</div>' % (_("WARN"), crit))
html.write('<div class="state state2">%s</div><div
class=level>< %.3f%%</div>' % (_("CRIT"), crit))
html.write('</div>')
+ # Legend for timeline
+ if "display_timeline_legend" in avoptions["labelling"] and
avoptions["show_timeline"]:
+ render_timeline_legend(what)
+
+
+def render_timeline_legend(what):
+ html.write('<div class="avlegend timeline">')
+ html.write('<h3>%s</h3>' % _('Timeline colors'))
+ html.write('<div class="state state0">%s</div>' % (what
== "host" and _("UP") or _("OK")))
+ if what != "host":
+ html.write('<div class="state state1">%s</div>'
% _("WARN"))
+ html.write('<div class="state state2">%s</div>' % (what
== "host" and _("DOWN") or _("CRIT")))
+ html.write('<div class="state state3">%s</div>' % (what
== "host" and _("UNREACH") or _("UNKNOWN")))
+ html.write('<div class="state flapping">%s</div>' %
_("Flapping"))
+ if what != "host":
+ html.write('<div class="state hostdown">%s</div>' %
_("H.Down"))
+ html.write('<div class="state downtime">%s</div>' %
_("Downtime"))
+ html.write('<div class="state ooservice">%s</div>' %
_("OO/Service"))
+ html.write('<div class="state unmonitored">%s</div>' %
_("unmonitored"))
+ html.write('</div>')
def get_av_groups(availability, grouping):
@@ -1176,7 +1202,7 @@ def render_availability_group(group_title, range_title, group_id,
availability,
if show_timeline:
table.cell(_("Timeline"), css="timeline")
html.write('<a href="%s">' % timeline_url)
- render_timeline(timeline_rows, from_time, until_time, total_duration, (site,
host, service), range_title, render_number, what, "", style="inline")
+ render_timeline(timeline_rows, from_time, until_time, total_duration, (site,
host, service), range_title, render_number, what, "", avoptions,
style="inline")
html.write('</a>')
for sid, css, sname, help in availability_columns: