"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lib/icinga/checkable.cpp" between
icinga2-2.11.5.tar.gz and icinga2-2.12.0.tar.gz

About: Icinga 2 is an enterprise grade monitoring system which keeps watch over networks and any conceivable network resource.

checkable.cpp  (icinga2-2.11.5):checkable.cpp  (icinga2-2.12.0)
skipping to change at line 18 skipping to change at line 18
#include "base/utility.hpp" #include "base/utility.hpp"
#include "base/exception.hpp" #include "base/exception.hpp"
#include "base/timer.hpp" #include "base/timer.hpp"
#include <boost/thread/once.hpp> #include <boost/thread/once.hpp>
using namespace icinga; using namespace icinga;
REGISTER_TYPE_WITH_PROTOTYPE(Checkable, Checkable::GetPrototype()); REGISTER_TYPE_WITH_PROTOTYPE(Checkable, Checkable::GetPrototype());
INITIALIZE_ONCE(&Checkable::StaticInitialize); INITIALIZE_ONCE(&Checkable::StaticInitialize);
boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String boost::signals2::signal<void (const Checkable::Ptr&, const String&, const String
&, AcknowledgementType, bool, bool, double, const MessageOrigin::Ptr&)> Checkabl &, AcknowledgementType, bool, bool, double, double, const MessageOrigin::Ptr&)>
e::OnAcknowledgementSet; Checkable::OnAcknowledgementSet;
boost::signals2::signal<void (const Checkable::Ptr&, const MessageOrigin::Ptr&)> boost::signals2::signal<void (const Checkable::Ptr&, const String&, double, cons
Checkable::OnAcknowledgementCleared; t MessageOrigin::Ptr&)> Checkable::OnAcknowledgementCleared;
boost::signals2::signal<void (const Checkable::Ptr&, double)> Checkable::OnFlapp
ingChange;
static Timer::Ptr l_CheckablesFireSuppressedNotifications; static Timer::Ptr l_CheckablesFireSuppressedNotifications;
void Checkable::StaticInitialize() void Checkable::StaticInitialize()
{ {
/* fixed downtime start */ /* fixed downtime start */
Downtime::OnDowntimeStarted.connect(std::bind(&Checkable::NotifyFixedDown timeStart, _1)); Downtime::OnDowntimeStarted.connect(std::bind(&Checkable::NotifyFixedDown timeStart, _1));
/* flexible downtime start */ /* flexible downtime start */
Downtime::OnDowntimeTriggered.connect(std::bind(&Checkable::NotifyFlexibl eDowntimeStart, _1)); Downtime::OnDowntimeTriggered.connect(std::bind(&Checkable::NotifyFlexibl eDowntimeStart, _1));
/* fixed/flexible downtime end */ /* fixed/flexible downtime end */
skipping to change at line 65 skipping to change at line 66
BOOST_THROW_EXCEPTION(ValidationError(this, { "command_en dpoint" }, BOOST_THROW_EXCEPTION(ValidationError(this, { "command_en dpoint" },
"Checkable with command endpoint requires a zone. Please check the troubleshooting documentation.")); "Checkable with command endpoint requires a zone. Please check the troubleshooting documentation."));
} }
} }
} }
void Checkable::Start(bool runtimeCreated) void Checkable::Start(bool runtimeCreated)
{ {
double now = Utility::GetTime(); double now = Utility::GetTime();
{
auto cr (GetLastCheckResult());
if (GetLastCheckStarted() > (cr ? cr->GetExecutionEnd() : 0.0)) {
SetNextCheck(GetLastCheckStarted());
}
}
if (GetNextCheck() < now + 60) { if (GetNextCheck() < now + 60) {
double delta = std::min(GetCheckInterval(), 60.0); double delta = std::min(GetCheckInterval(), 60.0);
delta *= (double)std::rand() / RAND_MAX; delta *= (double)std::rand() / RAND_MAX;
SetNextCheck(now + delta); SetNextCheck(now + delta);
} }
ObjectImpl<Checkable>::Start(runtimeCreated); ObjectImpl<Checkable>::Start(runtimeCreated);
static boost::once_flag once = BOOST_ONCE_INIT; static boost::once_flag once = BOOST_ONCE_INIT;
skipping to change at line 113 skipping to change at line 122
AcknowledgementType Checkable::GetAcknowledgement() AcknowledgementType Checkable::GetAcknowledgement()
{ {
auto avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw()); auto avalue = static_cast<AcknowledgementType>(GetAcknowledgementRaw());
if (avalue != AcknowledgementNone) { if (avalue != AcknowledgementNone) {
double expiry = GetAcknowledgementExpiry(); double expiry = GetAcknowledgementExpiry();
if (expiry != 0 && expiry < Utility::GetTime()) { if (expiry != 0 && expiry < Utility::GetTime()) {
avalue = AcknowledgementNone; avalue = AcknowledgementNone;
ClearAcknowledgement(); ClearAcknowledgement("");
} }
} }
return avalue; return avalue;
} }
bool Checkable::IsAcknowledged() const bool Checkable::IsAcknowledged() const
{ {
return const_cast<Checkable *>(this)->GetAcknowledgement() != Acknowledge mentNone; return const_cast<Checkable *>(this)->GetAcknowledgement() != Acknowledge mentNone;
} }
void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, bool persistent, double expiry, const Mes sageOrigin::Ptr& origin) void Checkable::AcknowledgeProblem(const String& author, const String& comment, AcknowledgementType type, bool notify, bool persistent, double changeTime, doubl e expiry, const MessageOrigin::Ptr& origin)
{ {
SetAcknowledgementRaw(type); SetAcknowledgementRaw(type);
SetAcknowledgementExpiry(expiry); SetAcknowledgementExpiry(expiry);
if (notify && !IsPaused()) if (notify && !IsPaused())
OnNotificationsRequested(this, NotificationAcknowledgement, GetLa stCheckResult(), author, comment, nullptr); OnNotificationsRequested(this, NotificationAcknowledgement, GetLa stCheckResult(), author, comment, nullptr);
Log(LogInformation, "Checkable") Log(LogInformation, "Checkable")
<< "Acknowledgement set for checkable '" << GetName() << "'."; << "Acknowledgement set for checkable '" << GetName() << "'.";
OnAcknowledgementSet(this, author, comment, type, notify, persistent, exp OnAcknowledgementSet(this, author, comment, type, notify, persistent, cha
iry, origin); ngeTime, expiry, origin);
SetAcknowledgementLastChange(changeTime);
} }
void Checkable::ClearAcknowledgement(const MessageOrigin::Ptr& origin) void Checkable::ClearAcknowledgement(const String& removedBy, double changeTime, const MessageOrigin::Ptr& origin)
{ {
ObjectLock oLock (this);
bool wasAcked = GetAcknowledgementRaw() != AcknowledgementNone;
SetAcknowledgementRaw(AcknowledgementNone); SetAcknowledgementRaw(AcknowledgementNone);
SetAcknowledgementExpiry(0); SetAcknowledgementExpiry(0);
Log(LogInformation, "Checkable") Log(LogInformation, "Checkable")
<< "Acknowledgement cleared for checkable '" << GetName() << "'." ; << "Acknowledgement cleared for checkable '" << GetName() << "'." ;
OnAcknowledgementCleared(this, origin); if (wasAcked) {
OnAcknowledgementCleared(this, removedBy, changeTime, origin);
SetAcknowledgementLastChange(changeTime);
}
} }
Endpoint::Ptr Checkable::GetCommandEndpoint() const Endpoint::Ptr Checkable::GetCommandEndpoint() const
{ {
return Endpoint::GetByName(GetCommandEndpointRaw()); return Endpoint::GetByName(GetCommandEndpointRaw());
} }
int Checkable::GetSeverity() const int Checkable::GetSeverity() const
{ {
/* overridden in Host/Service class. */ /* overridden in Host/Service class. */
return 0; return 0;
} }
bool Checkable::GetProblem() const bool Checkable::GetProblem() const
{ {
return !IsStateOK(GetStateRaw()); auto cr (GetLastCheckResult());
return cr && !IsStateOK(cr->GetState());
} }
bool Checkable::GetHandled() const bool Checkable::GetHandled() const
{ {
return GetProblem() && (IsInDowntime() || IsAcknowledged()); return GetProblem() && (IsInDowntime() || IsAcknowledged());
} }
Timestamp Checkable::GetNextUpdate() const
{
auto cr (GetLastCheckResult());
double interval, latency;
// TODO: Document this behavior.
if (cr) {
interval = GetEnableActiveChecks() && GetProblem() && GetStateTyp
e() == StateTypeSoft ? GetRetryInterval() : GetCheckInterval();
latency = cr->GetExecutionEnd() - cr->GetScheduleStart();
} else {
interval = GetCheckInterval();
latency = 0.0;
}
return (GetEnableActiveChecks() ? GetNextCheck() : (cr ? cr->GetExecution
End() : Application::GetStartTime()) + interval) + interval + 2 * latency;
}
void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime) void Checkable::NotifyFixedDowntimeStart(const Downtime::Ptr& downtime)
{ {
if (!downtime->GetFixed()) if (!downtime->GetFixed())
return; return;
NotifyDowntimeInternal(downtime); NotifyDowntimeInternal(downtime);
} }
void Checkable::NotifyFlexibleDowntimeStart(const Downtime::Ptr& downtime) void Checkable::NotifyFlexibleDowntimeStart(const Downtime::Ptr& downtime)
{ {
 End of changes. 10 change blocks. 
12 lines changed or deleted 53 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)