Module: check_mk
Branch: master
Commit: a036c511b5d54c76cf1bbfeb1f3941f000e41ca6
URL:
http://git.mathias-kettner.de/git/?p=check_mk.git;a=commit;h=a036c511b5d54c…
Author: Mathias Kettner <mk(a)mathias-kettner.de>
Date: Thu Nov 20 15:09:17 2014 +0100
#1514 FIX Try harder to detect previous hard state in notification when using Nagios as
core
In the case where you have more than one check attempt then now the previous
hard state is assumed to be the previous soft state when the new state is
OK or UP. This avoids some cases where the previous state had been set to
<tt>?</tt> in previous versions. The CMC does not have these problems anyway.
---
.werks/1514 | 12 ++++++++++++
ChangeLog | 1 +
modules/notify.py | 10 +++++++---
3 files changed, 20 insertions(+), 3 deletions(-)
diff --git a/.werks/1514 b/.werks/1514
new file mode 100644
index 0000000..2cb0041
--- /dev/null
+++ b/.werks/1514
@@ -0,0 +1,12 @@
+Title: Try harder to detect previous hard state in notification when using Nagios as
core
+Level: 1
+Component: notifications
+Compatible: compat
+Version: 1.2.5i7
+Date: 1416492466
+Class: fix
+
+In the case where you have more than one check attempt then now the previous
+hard state is assumed to be the previous soft state when the new state is
+OK or UP. This avoids some cases where the previous state had been set to
+<tt>?</tt> in previous versions. The CMC does not have these problems
anyway.
diff --git a/ChangeLog b/ChangeLog
index 1552b86..40ccb50 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -78,6 +78,7 @@
Notifications:
* 1512 Bulk notification can now be grouped according to custom macro values...
* 1168 FIX: HTML mails can now be configured to display graphs among each other...
+ * 1514 FIX: Try harder to detect previous hard state in notification when using
Nagios as core...
BI:
* 1435 FIX: Saving BI aggregations: No longer reports 'Request-URI Too
Large'...
diff --git a/modules/notify.py b/modules/notify.py
index 89ac7a8..87e94c9 100644
--- a/modules/notify.py
+++ b/modules/notify.py
@@ -1733,8 +1733,11 @@ def complete_raw_context(raw_context):
# Here We do not know. The transition might be OK -> WARN -> CRIT and
# the initial OK is completely lost. We use the artificial state
"?"
# here, which matches all states and makes sure that when in doubt a
- # notification is being sent out.
- prev_state = "?"
+ # notification is being sent out. But when the new state is UP, then
+ # we know that the previous state was a hard state (otherwise there
+ # would not have been any notification)
+ if raw_context["HOSTSTATE"] != "UP":
+ prev_state = "?"
notify_log("Previous host hard state not known. Allowing all
states.")
raw_context["PREVIOUSHOSTHARDSTATE"] = prev_state
@@ -1745,7 +1748,8 @@ def complete_raw_context(raw_context):
prev_state = "OK"
elif "SERVICEATTEMPT" not in raw_context or \
("SERVICEATTEMPT" in raw_context and
raw_context["SERVICEATTEMPT"] != "1"):
- prev_state = "?"
+ if raw_context["SERVICESTATE"] != "OK":
+ prev_state = "?"
notify_log("Previous service hard state not known. Allowing all
states.")
raw_context["PREVIOUSSERVICEHARDSTATE"] = prev_state