mirror of https://github.com/Icinga/icinga2.git
IcingaDB#SendStatusUpdate(): add icinga:history:stream:state#previous_soft_state
This commit is contained in:
parent
b6e0abc64c
commit
6c7a9eb651
|
@ -303,6 +303,10 @@ void Checkable::ProcessCheckResult(const CheckResult::Ptr& cr, const MessageOrig
|
||||||
SetLastHardStatesRaw(GetLastHardStatesRaw() / 100u + new_state * 100u);
|
SetLastHardStatesRaw(GetLastHardStatesRaw() / 100u + new_state * 100u);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (stateChange) {
|
||||||
|
SetLastSoftStatesRaw(GetLastSoftStatesRaw() / 100u + new_state * 100u);
|
||||||
|
}
|
||||||
|
|
||||||
if (!IsStateOK(new_state))
|
if (!IsStateOK(new_state))
|
||||||
TriggerDowntimes();
|
TriggerDowntimes();
|
||||||
|
|
||||||
|
|
|
@ -108,6 +108,9 @@ abstract class Checkable : CustomVarObject
|
||||||
[state, no_user_view, no_user_modify] "unsigned short" last_hard_states_raw {
|
[state, no_user_view, no_user_modify] "unsigned short" last_hard_states_raw {
|
||||||
default {{{ return /* current */ 99 * 100 + /* previous */ 99; }}}
|
default {{{ return /* current */ 99 * 100 + /* previous */ 99; }}}
|
||||||
};
|
};
|
||||||
|
[state, no_user_view, no_user_modify] "unsigned short" last_soft_states_raw {
|
||||||
|
default {{{ return /* current */ 99 * 100 + /* previous */ 99; }}}
|
||||||
|
};
|
||||||
[state, enum] StateType last_state_type {
|
[state, enum] StateType last_state_type {
|
||||||
default {{{ return StateTypeSoft; }}}
|
default {{{ return StateTypeSoft; }}}
|
||||||
};
|
};
|
||||||
|
|
|
@ -1129,10 +1129,10 @@ void IcingaDB::SendConfigDelete(const ConfigObject::Ptr& object)
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
static
|
static inline
|
||||||
unsigned short GetPreviousHardState(const Checkable::Ptr& checkable, const Service::Ptr& service)
|
unsigned short GetPreviousState(const Checkable::Ptr& checkable, const Service::Ptr& service, StateType type)
|
||||||
{
|
{
|
||||||
auto phs (checkable->GetLastHardStatesRaw() % 100u);
|
auto phs ((type == StateTypeHard ? checkable->GetLastHardStatesRaw() : checkable->GetLastSoftStatesRaw()) % 100u);
|
||||||
|
|
||||||
if (service) {
|
if (service) {
|
||||||
return phs;
|
return phs;
|
||||||
|
@ -1185,7 +1185,8 @@ void IcingaDB::SendStatusUpdate(const ConfigObject::Ptr& object, const CheckResu
|
||||||
// TODO: last_hard/soft_state should be "previous".
|
// TODO: last_hard/soft_state should be "previous".
|
||||||
"last_soft_state", Convert::ToString(cr ? cr->GetState() : 99),
|
"last_soft_state", Convert::ToString(cr ? cr->GetState() : 99),
|
||||||
"last_hard_state", Convert::ToString(service ? service->GetLastHardState() : host->GetLastHardState()),
|
"last_hard_state", Convert::ToString(service ? service->GetLastHardState() : host->GetLastHardState()),
|
||||||
"previous_hard_state", Convert::ToString(GetPreviousHardState(checkable, service)),
|
"previous_soft_state", Convert::ToString(GetPreviousState(checkable, service, StateTypeSoft)),
|
||||||
|
"previous_hard_state", Convert::ToString(GetPreviousState(checkable, service, StateTypeHard)),
|
||||||
"output", Utility::ValidateUTF8(std::move(output.first)),
|
"output", Utility::ValidateUTF8(std::move(output.first)),
|
||||||
"long_output", Utility::ValidateUTF8(std::move(output.second)),
|
"long_output", Utility::ValidateUTF8(std::move(output.second)),
|
||||||
"check_source", cr->GetCheckSource(),
|
"check_source", cr->GetCheckSource(),
|
||||||
|
@ -1239,7 +1240,7 @@ void IcingaDB::SendSentNotification(
|
||||||
"notification_id", GetObjectIdentifier(notification),
|
"notification_id", GetObjectIdentifier(notification),
|
||||||
"type", Convert::ToString(type),
|
"type", Convert::ToString(type),
|
||||||
"state", Convert::ToString(cr->GetState()),
|
"state", Convert::ToString(cr->GetState()),
|
||||||
"previous_hard_state", Convert::ToString(GetPreviousHardState(checkable, service)),
|
"previous_hard_state", Convert::ToString(GetPreviousState(checkable, service, StateTypeHard)),
|
||||||
"author", Utility::ValidateUTF8(author),
|
"author", Utility::ValidateUTF8(author),
|
||||||
"text", Utility::ValidateUTF8(finalText),
|
"text", Utility::ValidateUTF8(finalText),
|
||||||
"users_notified", Convert::ToString(users),
|
"users_notified", Convert::ToString(users),
|
||||||
|
@ -1574,7 +1575,7 @@ Dictionary::Ptr IcingaDB::SerializeState(const Checkable::Ptr& checkable)
|
||||||
attrs->Set("severity", host->GetSeverity());
|
attrs->Set("severity", host->GetSeverity());
|
||||||
}
|
}
|
||||||
|
|
||||||
attrs->Set("previous_hard_state", GetPreviousHardState(checkable, service));
|
attrs->Set("previous_hard_state", GetPreviousState(checkable, service, StateTypeHard));
|
||||||
attrs->Set("check_attempt", checkable->GetCheckAttempt());
|
attrs->Set("check_attempt", checkable->GetCheckAttempt());
|
||||||
|
|
||||||
attrs->Set("is_active", checkable->IsActive());
|
attrs->Set("is_active", checkable->IsActive());
|
||||||
|
|
Loading…
Reference in New Issue