[icinga-checkins] icinga.org: icinga2/master: Fixed soft service recoveries.

git at icinga.org git at icinga.org
Sun Feb 10 15:07:43 CET 2013


Module: icinga2
Branch: master
Commit: 0d1cad864c4d5f3da6b90c94fc98cd053d162020
URL:    https://git.icinga.org/?p=icinga2.git;a=commit;h=0d1cad864c4d5f3da6b90c94fc98cd053d162020

Author: Gunnar Beutner <gunnar.beutner at netways.de>
Date:   Sun Feb 10 15:07:32 2013 +0100

Fixed soft service recoveries.

---

 lib/icinga/service-check.cpp |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/lib/icinga/service-check.cpp b/lib/icinga/service-check.cpp
index 41653fa..5838bb9 100644
--- a/lib/icinga/service-check.cpp
+++ b/lib/icinga/service-check.cpp
@@ -287,11 +287,15 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
 {
 	ServiceState old_state = GetState();
 	ServiceStateType old_stateType = GetStateType();
+	bool hardChange = false;
 
 	long attempt = GetCurrentCheckAttempt();
 
 	if (cr->Get("state") == StateOK) {
-		if (GetState() == StateOK)
+		if (old_state != StateOK && old_stateType == StateTypeHard)
+			hardChange = true; // hard recovery
+
+		if (old_state == StateOK)
 			SetStateType(StateTypeHard);
 
 		attempt = 1;
@@ -299,6 +303,7 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
 		if (attempt >= GetMaxCheckAttempts()) {
 			SetStateType(StateTypeHard);
 			attempt = 1;
+			hardChange = true;
 		} else if (GetStateType() == StateTypeSoft || GetState() == StateOK) {
 			SetStateType(StateTypeSoft);
 			attempt++;
@@ -341,7 +346,7 @@ void Service::ApplyCheckResult(const Dictionary::Ptr& cr)
 	if (GetState() != StateOK)
 		TriggerDowntimes();
 
-	if (GetStateType() == StateTypeHard && (old_state != GetState() || old_stateType == StateTypeSoft)) {
+	if (hardChange) {
 		SetLastHardStateChange(now);
 
 		/* Make sure the notification component sees the updated





More information about the icinga-checkins mailing list