mirror of https://github.com/Icinga/icinga2.git
commit
55641fc1ea
|
@ -19,6 +19,7 @@
|
||||||
|
|
||||||
#include "checker/checkercomponent.h"
|
#include "checker/checkercomponent.h"
|
||||||
#include "icinga/icingaapplication.h"
|
#include "icinga/icingaapplication.h"
|
||||||
|
#include "icinga/cib.h"
|
||||||
#include "base/dynamictype.h"
|
#include "base/dynamictype.h"
|
||||||
#include "base/objectlock.h"
|
#include "base/objectlock.h"
|
||||||
#include "base/utility.h"
|
#include "base/utility.h"
|
||||||
|
@ -183,7 +184,7 @@ void CheckerComponent::ResultTimerHandler(void)
|
||||||
{
|
{
|
||||||
boost::mutex::scoped_lock lock(m_Mutex);
|
boost::mutex::scoped_lock lock(m_Mutex);
|
||||||
|
|
||||||
msgbuf << "Pending services: " << m_PendingServices.size() << "; Idle services: " << m_IdleServices.size();
|
msgbuf << "Pending services: " << m_PendingServices.size() << "; Idle services: " << m_IdleServices.size() << "; Checks/s: " << CIB::GetActiveChecksStatistics(5) / 5.0;
|
||||||
}
|
}
|
||||||
|
|
||||||
Log(LogInformation, "checker", msgbuf.str());
|
Log(LogInformation, "checker", msgbuf.str());
|
||||||
|
|
|
@ -47,17 +47,7 @@ struct ServiceNextCheckExtractor
|
||||||
*/
|
*/
|
||||||
double operator()(const Service::Ptr& service)
|
double operator()(const Service::Ptr& service)
|
||||||
{
|
{
|
||||||
if (!service->HasAuthority("checker"))
|
return service->GetNextCheck();
|
||||||
return Utility::GetTime() + 60;
|
|
||||||
|
|
||||||
double next = service->GetNextCheck();
|
|
||||||
|
|
||||||
while (next == 0) {
|
|
||||||
service->UpdateNextCheck();
|
|
||||||
next = service->GetNextCheck();
|
|
||||||
}
|
|
||||||
|
|
||||||
return next;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -74,6 +74,9 @@ void DynamicObject::SetAuthority(const String& type, bool value)
|
||||||
if (old_value == value)
|
if (old_value == value)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (GetAuthorityInfo() == NULL)
|
||||||
|
SetAuthorityInfo(make_shared<Dictionary>());
|
||||||
|
|
||||||
GetAuthorityInfo()->Set(type, value);
|
GetAuthorityInfo()->Set(type, value);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,7 +87,7 @@ bool DynamicObject::HasAuthority(const String& type) const
|
||||||
{
|
{
|
||||||
Dictionary::Ptr authorityInfo = GetAuthorityInfo();
|
Dictionary::Ptr authorityInfo = GetAuthorityInfo();
|
||||||
|
|
||||||
if (!authorityInfo->Contains(type))
|
if (!authorityInfo || !authorityInfo->Contains(type))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
return authorityInfo->Get(type);
|
return authorityInfo->Get(type);
|
||||||
|
|
|
@ -10,9 +10,7 @@ abstract class DynamicObject
|
||||||
[config] Array::Ptr domains;
|
[config] Array::Ptr domains;
|
||||||
[config] Array::Ptr authorities;
|
[config] Array::Ptr authorities;
|
||||||
[get_protected] bool active;
|
[get_protected] bool active;
|
||||||
Dictionary::Ptr authority_info {
|
Dictionary::Ptr authority_info;
|
||||||
default {{{ return make_shared<Dictionary>(); }}}
|
|
||||||
};
|
|
||||||
[protected] Dictionary::Ptr extensions;
|
[protected] Dictionary::Ptr extensions;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -174,10 +174,8 @@ cJSON *Value::ToJson(void) const
|
||||||
} else if (IsObjectType<Array>()) {
|
} else if (IsObjectType<Array>()) {
|
||||||
Array::Ptr array = *this;
|
Array::Ptr array = *this;
|
||||||
return array->ToJson();
|
return array->ToJson();
|
||||||
} else if (IsEmpty()) {
|
|
||||||
return cJSON_CreateNull();
|
|
||||||
} else {
|
} else {
|
||||||
BOOST_THROW_EXCEPTION(std::runtime_error("Unknown object type."));
|
return cJSON_CreateNull();
|
||||||
}
|
}
|
||||||
|
|
||||||
case ValueEmpty:
|
case ValueEmpty:
|
||||||
|
|
|
@ -130,7 +130,7 @@ void Notification::SetNextNotification(double time, const String& authority)
|
||||||
{
|
{
|
||||||
SetNextNotificationRaw(time);
|
SetNextNotificationRaw(time);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnNextNotificationChanged), GetSelf(), time, authority));
|
OnNextNotificationChanged(GetSelf(), time, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Notification::UpdateNotificationNumber(void)
|
void Notification::UpdateNotificationNumber(void)
|
||||||
|
|
|
@ -94,7 +94,7 @@ void Service::SetNextCheck(double nextCheck, const String& authority)
|
||||||
{
|
{
|
||||||
SetNextCheckRaw(nextCheck);
|
SetNextCheckRaw(nextCheck);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(Service::OnNextCheckChanged), GetSelf(), nextCheck, authority));
|
OnNextCheckChanged(GetSelf(), nextCheck, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
double Service::GetNextCheck(void)
|
double Service::GetNextCheck(void)
|
||||||
|
@ -150,7 +150,7 @@ void Service::SetEnableActiveChecks(bool enabled, const String& authority)
|
||||||
{
|
{
|
||||||
SetOverrideEnableActiveChecks(enabled);
|
SetOverrideEnableActiveChecks(enabled);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableActiveChecksChanged), GetSelf(), enabled, authority));
|
OnEnableActiveChecksChanged(GetSelf(), enabled, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::GetEnablePassiveChecks(void) const
|
bool Service::GetEnablePassiveChecks(void) const
|
||||||
|
@ -165,7 +165,7 @@ void Service::SetEnablePassiveChecks(bool enabled, const String& authority)
|
||||||
{
|
{
|
||||||
SetOverrideEnablePassiveChecks(enabled);
|
SetOverrideEnablePassiveChecks(enabled);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnablePassiveChecksChanged), GetSelf(), enabled, authority));
|
OnEnablePassiveChecksChanged(GetSelf(), enabled, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::GetForceNextCheck(void) const
|
bool Service::GetForceNextCheck(void) const
|
||||||
|
@ -177,7 +177,7 @@ void Service::SetForceNextCheck(bool forced, const String& authority)
|
||||||
{
|
{
|
||||||
SetForceNextCheckRaw(forced);
|
SetForceNextCheckRaw(forced);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextCheckChanged), GetSelf(), forced, authority));
|
OnForceNextCheckChanged(GetSelf(), forced, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority)
|
void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& authority)
|
||||||
|
@ -367,15 +367,13 @@ void Service::ProcessCheckResult(const CheckResult::Ptr& cr, const String& autho
|
||||||
// " threshold: " + Convert::ToString(GetFlappingThreshold()) +
|
// " threshold: " + Convert::ToString(GetFlappingThreshold()) +
|
||||||
// "% current: " + Convert::ToString(GetFlappingCurrent()) + "%.");
|
// "% current: " + Convert::ToString(GetFlappingCurrent()) + "%.");
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnNewCheckResult), GetSelf(), cr, authority));
|
OnNewCheckResult(GetSelf(), cr, authority);
|
||||||
OnStateChanged(GetSelf());
|
OnStateChanged(GetSelf());
|
||||||
|
|
||||||
if (hardChange) {
|
if (hardChange)
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnStateChange), GetSelf(), cr, StateTypeHard, authority));
|
OnStateChange(GetSelf(), cr, StateTypeHard, authority);
|
||||||
}
|
else if (stateChange)
|
||||||
else if (stateChange) {
|
OnStateChange(GetSelf(), cr, StateTypeSoft, authority);
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnStateChange), GetSelf(), cr, StateTypeSoft, authority));
|
|
||||||
}
|
|
||||||
|
|
||||||
if (call_eventhandler)
|
if (call_eventhandler)
|
||||||
ExecuteEventHandler();
|
ExecuteEventHandler();
|
||||||
|
|
|
@ -79,7 +79,7 @@ String Service::AddComment(CommentType entryType, const String& author,
|
||||||
l_CommentsCache[uid] = GetSelf();
|
l_CommentsCache[uid] = GetSelf();
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnCommentAdded), GetSelf(), comment, authority));
|
OnCommentAdded(GetSelf(), comment, authority);
|
||||||
|
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
@ -126,7 +126,7 @@ void Service::RemoveComment(const String& id, const String& authority)
|
||||||
l_CommentsCache.erase(id);
|
l_CommentsCache.erase(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnCommentRemoved), owner, comment, authority));
|
OnCommentRemoved(owner, comment, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Service::GetCommentIDFromLegacyID(int id)
|
String Service::GetCommentIDFromLegacyID(int id)
|
||||||
|
|
|
@ -99,7 +99,7 @@ String Service::AddDowntime(const String& author, const String& comment,
|
||||||
|
|
||||||
Log(LogWarning, "icinga", "added downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "'.");
|
Log(LogWarning, "icinga", "added downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "'.");
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeAdded), GetSelf(), downtime, authority));
|
OnDowntimeAdded(GetSelf(), downtime, authority);
|
||||||
|
|
||||||
return uid;
|
return uid;
|
||||||
}
|
}
|
||||||
|
@ -132,7 +132,7 @@ void Service::RemoveDowntime(const String& id, bool cancelled, const String& aut
|
||||||
|
|
||||||
Log(LogWarning, "icinga", "removed downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "' from service '" + owner->GetName() + "'.");
|
Log(LogWarning, "icinga", "removed downtime with ID '" + Convert::ToString(downtime->GetLegacyId()) + "' from service '" + owner->GetName() + "'.");
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeRemoved), owner, downtime, authority));
|
OnDowntimeRemoved(owner, downtime, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::TriggerDowntimes(void)
|
void Service::TriggerDowntimes(void)
|
||||||
|
@ -185,7 +185,7 @@ void Service::TriggerDowntime(const String& id)
|
||||||
TriggerDowntime(tid);
|
TriggerDowntime(tid);
|
||||||
}
|
}
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnDowntimeTriggered), owner, downtime));
|
OnDowntimeTriggered(owner, downtime);
|
||||||
}
|
}
|
||||||
|
|
||||||
String Service::GetDowntimeIDFromLegacyID(int id)
|
String Service::GetDowntimeIDFromLegacyID(int id)
|
||||||
|
|
|
@ -50,7 +50,7 @@ void Service::SetEnableFlapping(bool enabled, const String& authority)
|
||||||
SetEnableFlappingRaw(enabled);
|
SetEnableFlappingRaw(enabled);
|
||||||
|
|
||||||
OnFlappingChanged(GetSelf(), enabled ? FlappingEnabled : FlappingDisabled);
|
OnFlappingChanged(GetSelf(), enabled ? FlappingEnabled : FlappingDisabled);
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableFlappingChanged), GetSelf(), enabled, authority));
|
OnEnableFlappingChanged(GetSelf(), enabled, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::UpdateFlappingStatus(bool stateChange)
|
void Service::UpdateFlappingStatus(bool stateChange)
|
||||||
|
|
|
@ -171,7 +171,7 @@ void Service::SetEnableNotifications(bool enabled, const String& authority)
|
||||||
{
|
{
|
||||||
SetEnableNotificationsRaw(enabled);
|
SetEnableNotificationsRaw(enabled);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnEnableNotificationsChanged), GetSelf(), enabled, authority));
|
OnEnableNotificationsChanged(GetSelf(), enabled, authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::GetForceNextNotification(void) const
|
bool Service::GetForceNextNotification(void) const
|
||||||
|
@ -183,5 +183,5 @@ void Service::SetForceNextNotification(bool forced, const String& authority)
|
||||||
{
|
{
|
||||||
SetForceNextNotificationRaw(forced);
|
SetForceNextNotificationRaw(forced);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnForceNextNotificationChanged), GetSelf(), forced, authority));
|
OnForceNextNotificationChanged(GetSelf(), forced, authority);
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,10 @@ void Service::OnConfigLoaded(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Host::Ptr host = GetHost();
|
m_Host = Host::GetByName(GetHostRaw());
|
||||||
if (host)
|
|
||||||
host->AddService(GetSelf());
|
if (m_Host)
|
||||||
|
m_Host->AddService(GetSelf());
|
||||||
|
|
||||||
UpdateSlaveNotifications();
|
UpdateSlaveNotifications();
|
||||||
}
|
}
|
||||||
|
@ -95,7 +96,7 @@ Service::Ptr Service::GetByNamePair(const String& hostName, const String& servic
|
||||||
|
|
||||||
Host::Ptr Service::GetHost(void) const
|
Host::Ptr Service::GetHost(void) const
|
||||||
{
|
{
|
||||||
return Host::GetByName(GetHostRaw());
|
return m_Host;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Service::IsHostCheck(void) const
|
bool Service::IsHostCheck(void) const
|
||||||
|
@ -199,8 +200,7 @@ void Service::AcknowledgeProblem(const String& author, const String& comment, Ac
|
||||||
|
|
||||||
OnNotificationsRequested(GetSelf(), NotificationAcknowledgement, GetLastCheckResult(), author, comment);
|
OnNotificationsRequested(GetSelf(), NotificationAcknowledgement, GetLastCheckResult(), author, comment);
|
||||||
|
|
||||||
boost::function<void (void)> f = boost::bind(boost::ref(Service::OnAcknowledgementSet), GetSelf(), author, comment, type, expiry, authority);
|
OnAcknowledgementSet(GetSelf(), author, comment, type, expiry, authority);
|
||||||
Utility::QueueAsyncCallback(f);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::ClearAcknowledgement(const String& authority)
|
void Service::ClearAcknowledgement(const String& authority)
|
||||||
|
@ -210,7 +210,7 @@ void Service::ClearAcknowledgement(const String& authority)
|
||||||
SetAcknowledgementRaw(AcknowledgementNone);
|
SetAcknowledgementRaw(AcknowledgementNone);
|
||||||
SetAcknowledgementExpiry(0);
|
SetAcknowledgementExpiry(0);
|
||||||
|
|
||||||
Utility::QueueAsyncCallback(boost::bind(boost::ref(OnAcknowledgementCleared), GetSelf(), authority));
|
OnAcknowledgementCleared(GetSelf(), authority);
|
||||||
}
|
}
|
||||||
|
|
||||||
std::set<Host::Ptr> Service::GetParentHosts(void) const
|
std::set<Host::Ptr> Service::GetParentHosts(void) const
|
||||||
|
@ -228,7 +228,7 @@ std::set<Host::Ptr> Service::GetParentHosts(void) const
|
||||||
if (dependencies) {
|
if (dependencies) {
|
||||||
ObjectLock olock(dependencies);
|
ObjectLock olock(dependencies);
|
||||||
|
|
||||||
BOOST_FOREACH(const Value& dependency, dependencies) {
|
BOOST_FOREACH(const String& dependency, dependencies) {
|
||||||
Host::Ptr host = Host::GetByName(dependency);
|
Host::Ptr host = Host::GetByName(dependency);
|
||||||
|
|
||||||
if (!host)
|
if (!host)
|
||||||
|
|
|
@ -255,6 +255,8 @@ protected:
|
||||||
virtual void OnConfigLoaded(void);
|
virtual void OnConfigLoaded(void);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
Host::Ptr m_Host;
|
||||||
|
|
||||||
bool m_CheckRunning;
|
bool m_CheckRunning;
|
||||||
long m_SchedulingOffset;
|
long m_SchedulingOffset;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue