Module: check_mk
Branch: master
Commit: d8395acef820fd50fd80d4d52518470cfb0f1ed0
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=d8395acef820fd…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu May 28 14:30:42 2015 +0200
#2301 Availability now allows just showing rows with outage times above certain levels
In the availability options you can now define percentage levels for WARN,
CRIT and non-OK. Only objects that exceed these levels will be displayed
then. This allows you to make a report of just those object that had some
problem during the queried time range.
---
.werks/2301 | 12 +++++++++++
ChangeLog | 1 +
web/htdocs/availability.py | 47 +++++++++++++++++++++++++++++++++++++++++++-
3 files changed, 59 insertions(+), 1 deletion(-)
diff --git a/.werks/2301 b/.werks/2301
new file mode 100644
index 0000000..699dd03
--- /dev/null
+++ b/.werks/2301
@@ -0,0 +1,12 @@
+Title: Availability now allows just showing rows with outage times above certain levels
+Level: 2
+Component: reporting
+Compatible: compat
+Version: 1.2.7i1
+Date: 1432816134
+Class: feature
+
+In the availability options you can now define percentage levels for WARN,
+CRIT and non-OK. Only objects that exceed these levels will be displayed
+then. This allows you to make a report of just those object that had some
+problem during the queried time range.
diff --git a/ChangeLog b/ChangeLog
index d20d8fa..4c4938d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -555,6 +555,7 @@
* 2073 FIX: BI aggregation: fixed exception when showing clusters in BI boxes
Reporting & Availability:
+ * 2301 Availability now allows just showing rows with outage times above certain
levels...
* 1990 FIX: Fix two exceptions in PDF exports of host group views
* 2189 FIX: Allow changing graph number from 1 to "all" when editing PNP
graph in report...
* 2206 FIX: Add missing option "Show timeline of each object directly in
table" for reports...
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index fb0d34e..72b9ef0 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -258,6 +258,22 @@ avoption_entries = [
)
),
+ # Filter rows according to actual availability
+ ( "av_filter_outages",
+ "double",
+ True,
+ Dictionary(
+ title = _("Only show objects with outages"),
+ columns = 2,
+ elements = [
+ ( "warn", Percentage(title = _("Show only rows with WARN of
at least"), default_value = 0.0)),
+ ( "crit", Percentage(title = _("Show only rows with CRIT of
at least"), default_value = 0.0)),
+ ( "non-ok", Percentage(title = _("Show only rows with non-OK of
at least"), default_value = 0.0)),
+ ],
+ optional_keys = False,
+ )
+ ),
+
# Show colummns for min, max, avg duration and count
( "outage_statistics",
@@ -462,6 +478,7 @@ def get_default_avoptions():
"host_down" : "host_down",
},
"av_levels" : None,
+ "av_filter_outages" : { "warn" : 0.0, "crit" : 0.0,
"non-ok" : 0.0 },
"outage_statistics" : ([],[]),
"av_mode" : False,
"service_period" : "honor",
@@ -693,7 +710,35 @@ def compute_availability(what, av_rawdata, avoptions):
availability_table.append(availability_entry)
availability_table.sort(cmp = cmp_av_entry)
- return availability_table
+
+ # Apply filters
+ filtered_table = []
+ for row in availability_table:
+ if pass_availability_filter(row, avoptions):
+ filtered_table.append(row)
+ return filtered_table
+
+
+def pass_availability_filter(row, avoptions):
+ for key, level in avoptions["av_filter_outages"].items():
+ if level == 0.0:
+ continue
+ if key == "warn":
+ ref_value = row["states"].get("warn", 0)
+ elif key == "crit":
+ ref_value = row["states"].get("crit",
row["states"].get("down", 0))
+ elif key == "non-ok":
+ ref_value = 0.0
+ for key, value in row["states"].items():
+ if key not in [ "ok", "up", "unmonitored"
]:
+ ref_value += value
+ else:
+ continue # undefined key. Should never happen
+ percentage = 100.0 * ref_value / row["considered_duration"]
+ if percentage < level:
+ return False
+
+ return True
# Compute a list of availability tables - one for each group.
# Each entry is a pair of group_name and availability_table.