From 1436575095c103514918f7a474677c33d9a7ad70 Mon Sep 17 00:00:00 2001 From: Michael Friedrich Date: Sun, 25 May 2014 12:45:29 +0200 Subject: [PATCH] Fix incorrect host state change logs. Fixes #6290 --- lib/icinga/checkable-check.cpp | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/lib/icinga/checkable-check.cpp b/lib/icinga/checkable-check.cpp index 75fcf29d1..e37050c03 100644 --- a/lib/icinga/checkable-check.cpp +++ b/lib/icinga/checkable-check.cpp @@ -19,6 +19,7 @@ #include "icinga/checkable.h" #include "icinga/service.h" +#include "icinga/host.h" #include "icinga/checkcommand.h" #include "icinga/icingaapplication.h" #include "icinga/cib.h" @@ -401,12 +402,18 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig /* signal status updates to for example db_ido */ OnStateChanged(GetSelf()); + Host::Ptr host; + Service::Ptr service; + tie(host, service) = GetHostService(GetSelf()); + String old_state_str = (service ? Service::StateToString(old_state) : Host::StateToString(Host::CalculateState(old_state))); + String new_state_str = (service ? Service::StateToString(new_state) : Host::StateToString(Host::CalculateState(new_state))); + if (hardChange) { OnStateChange(GetSelf(), cr, StateTypeHard, origin); - Log(LogNotice, "icinga", "State Change: Checkable " + GetName() + " hard state change from " + Service::StateToString(old_state) + " to " + Service::StateToString(new_state) + " detected."); + Log(LogNotice, "icinga", "State Change: Checkable " + GetName() + " hard state change from " + old_state_str + " to " + new_state_str + " detected."); } else if (stateChange) { OnStateChange(GetSelf(), cr, StateTypeSoft, origin); - Log(LogNotice, "icinga", "State Change: Checkable " + GetName() + " soft state change from " + Service::StateToString(old_state) + " to " + Service::StateToString(new_state) + " detected."); + Log(LogNotice, "icinga", "State Change: Checkable " + GetName() + " soft state change from " + old_state_str + " to " + new_state_str + " detected."); } if (GetStateType() == StateTypeSoft || hardChange || recovery)