Module: check_mk
Branch: master
Commit: 46d91ee843abf1a643ea1cf2d4ea74154825afd2
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=46d91ee843abf1…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Tue Mar 8 12:05:36 2016 +0100
3267 New availability option for reclassifying host state "unreachable"
The host state UNREACH can now be reclassified as UP or DOWN.
---
.werks/3267 | 10 ++++++++
ChangeLog | 1 +
web/htdocs/availability.py | 61 ++++++++++++++++++++++++++++++++++----------
3 files changed, 59 insertions(+), 13 deletions(-)
diff --git a/.werks/3267 b/.werks/3267
new file mode 100644
index 0000000..fb0fe95
--- /dev/null
+++ b/.werks/3267
@@ -0,0 +1,10 @@
+Title: New availability option for reclassifying host state "unreachable"
+Level: 1
+Component: reporting
+Class: feature
+Compatible: compat
+State: unknown
+Version: 1.2.9i1
+Date: 1457435081
+
+The host state UNREACH can now be reclassified as UP or DOWN.
diff --git a/ChangeLog b/ChangeLog
index 2e50386..1f7d894 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -112,6 +112,7 @@
* 3232 FIX: BI: Only querying site of host for specific host status info...
Reporting & Availability:
+ * 3267 New availability option for reclassifying host state
"unreachable"...
* 3249 FIX: Fix missing filter for non-OK services when report is called via context
button
Event Console:
diff --git a/web/htdocs/availability.py b/web/htdocs/availability.py
index 8495a16..e73ca4f 100644
--- a/web/htdocs/availability.py
+++ b/web/htdocs/availability.py
@@ -126,6 +126,9 @@ def get_avoption_entries(what):
( "service_groups", _("By Service group") ),
]
+ def aligned_label(text):
+ return "<div style=\"width: 196px; display:
inline-block;\">%s:</div>" % text
+
return [
# Time range selection
( "rangespec",
@@ -208,17 +211,16 @@ def get_avoption_entries(what):
),
),
- # Optionally group some states together
( "state_grouping",
"double",
True,
Dictionary(
- title = _("Status Grouping"),
+ title = _("Service Status Grouping"),
columns = 2,
elements = [
( "warn",
DropdownChoice(
- label = _("Treat Warning as: "),
+ label = aligned_label(_("Treat Warning as")),
choices = [
( "ok", _("OK") ),
( "warn", _("WARN") ),
@@ -230,7 +232,7 @@ def get_avoption_entries(what):
),
( "unknown",
DropdownChoice(
- label = _("Treat Unknown as: "),
+ label = aligned_label(_("Treat Unknown/Unreachable as")),
choices = [
( "ok", _("OK") ),
( "warn", _("WARN") ),
@@ -242,7 +244,7 @@ def get_avoption_entries(what):
),
( "host_down",
DropdownChoice(
- label = _("Treat Host Down as: "),
+ label = aligned_label(_("Treat Host Down as")),
choices = [
( "ok", _("OK") ),
( "warn", _("WARN") ),
@@ -325,6 +327,31 @@ def get_avoption_entries(what):
)
),
+ # Optionally group some states together
+ ( "host_state_grouping",
+ "single",
+ True,
+ Dictionary(
+ title = _("Host Status Grouping"),
+ columns = 2,
+ elements = [
+ ( "unreach",
+ DropdownChoice(
+ label = aligned_label(_("Treat Unreachable as")),
+ choices = [
+ ( "up", _("UP") ),
+ ( "down", _("DOWN") ),
+ ( "unreach", _("UNREACH") ),
+ ],
+ default_value = "unreach",
+ ),
+ ),
+ ],
+ optional_keys = False,
+ ),
+ ),
+
+
# Omit all non-OK columns
( "av_mode",
"single",
@@ -499,6 +526,10 @@ def get_default_avoptions():
"unmonitored" : True,
},
+ "host_state_grouping" : {
+ "unreach" : "unreach",
+ },
+
"state_grouping" : {
"warn" : "warn",
"unknown" : "unknown",
@@ -670,12 +701,13 @@ def compute_availability(what, av_rawdata, avoptions):
s = { 0: "ok", 1:"warn", 2:"crit",
3:"unknown" }.get(state, "unmonitored")
else:
s = { 0: "up", 1:"down",
2:"unreach" }.get(state, "unmonitored")
- if s == "warn":
- s = avoptions["state_grouping"]["warn"]
- elif s == "unknown":
- s = avoptions["state_grouping"]["unknown"]
- elif s == "host_down":
- s = avoptions["state_grouping"]["host_down"]
+
+ # Reclassification due to state grouping
+ if s in avoptions["state_grouping"]:
+ s = avoptions["state_grouping"][s]
+
+ elif s in avoptions["host_state_grouping"]:
+ s = avoptions["host_state_grouping"][s]
total_duration += span["duration"]
if consider:
@@ -1455,9 +1487,10 @@ def compute_tree_state(tree, status):
# to CRIT because of state grouping, then the WARN column should not be
# displayed.
def cell_active(sid, avoptions):
+ #html.debug((sid, "aktiv?"))
# Some columns might be unneeded due to state treatment options
sg = avoptions["state_grouping"]
- state_groups = [ sg["warn"], sg["unknown"],
sg["host_down"] ]
+ hsg = avoptions["host_state_grouping"]
if sid not in [ "up", "ok" ] and avoptions["av_mode"]:
return False
@@ -1473,7 +1506,9 @@ def cell_active(sid, avoptions):
return False
elif sid == "host_down" and not
avoptions["consider"]["host_down"]:
return False
- elif sid in [ "warn", "unknown", "host_down" ] and sid
not in state_groups:
+ elif sid in sg and sid not in sg.values():
+ return False
+ elif sid in hsg and sid not in hsg.values():
return False
else:
return True