mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-29 16:44:29 +02:00
parent
61f2b5f0cf
commit
7e31cb639f
@ -30,6 +30,7 @@ void CheckerComponent::Start(void)
|
|||||||
m_Endpoint->RegisterSubscription("checker");
|
m_Endpoint->RegisterSubscription("checker");
|
||||||
|
|
||||||
Service::OnCheckerChanged.connect(bind(&CheckerComponent::CheckerChangedHandler, this, _1));
|
Service::OnCheckerChanged.connect(bind(&CheckerComponent::CheckerChangedHandler, this, _1));
|
||||||
|
Service::OnNextCheckChanged.connect(bind(&CheckerComponent::NextCheckChangedHandler, this, _1));
|
||||||
DynamicObject::OnUnregistered.connect(bind(&CheckerComponent::ObjectRemovedHandler, this, _1));
|
DynamicObject::OnUnregistered.connect(bind(&CheckerComponent::ObjectRemovedHandler, this, _1));
|
||||||
|
|
||||||
m_CheckTimer = boost::make_shared<Timer>();
|
m_CheckTimer = boost::make_shared<Timer>();
|
||||||
@ -144,6 +145,20 @@ void CheckerComponent::CheckerChangedHandler(const Service::Ptr& service)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CheckerComponent::NextCheckChangedHandler(const Service::Ptr& service)
|
||||||
|
{
|
||||||
|
/* remove and re-insert the service from the set in order to force an index update */
|
||||||
|
typedef nth_index<ServiceSet, 0>::type ServiceView;
|
||||||
|
ServiceView& idx = boost::get<0>(m_IdleServices);
|
||||||
|
|
||||||
|
ServiceView::iterator it = idx.find(service);
|
||||||
|
if (it == idx.end())
|
||||||
|
return;
|
||||||
|
|
||||||
|
idx.erase(it);
|
||||||
|
idx.insert(service);
|
||||||
|
}
|
||||||
|
|
||||||
void CheckerComponent::ObjectRemovedHandler(const DynamicObject::Ptr& object)
|
void CheckerComponent::ObjectRemovedHandler(const DynamicObject::Ptr& object)
|
||||||
{
|
{
|
||||||
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
Service::Ptr service = dynamic_pointer_cast<Service>(object);
|
||||||
|
@ -74,6 +74,7 @@ private:
|
|||||||
void AdjustCheckTimer(void);
|
void AdjustCheckTimer(void);
|
||||||
|
|
||||||
void CheckerChangedHandler(const Service::Ptr& service);
|
void CheckerChangedHandler(const Service::Ptr& service);
|
||||||
|
void NextCheckChangedHandler(const Service::Ptr& service);
|
||||||
void ObjectRemovedHandler(const DynamicObject::Ptr& object);
|
void ObjectRemovedHandler(const DynamicObject::Ptr& object);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -53,6 +53,7 @@ const int Service::CheckIntervalDivisor = 5;
|
|||||||
|
|
||||||
boost::signal<void (const Service::Ptr&, const CheckResultMessage&)> Service::OnCheckResultReceived;
|
boost::signal<void (const Service::Ptr&, const CheckResultMessage&)> Service::OnCheckResultReceived;
|
||||||
boost::signal<void (const Service::Ptr&, const String&)> Service::OnCheckerChanged;
|
boost::signal<void (const Service::Ptr&, const String&)> Service::OnCheckerChanged;
|
||||||
|
boost::signal<void (const Service::Ptr&, const Value&)> Service::OnNextCheckChanged;
|
||||||
|
|
||||||
Service::Service(const Dictionary::Ptr& serializedObject)
|
Service::Service(const Dictionary::Ptr& serializedObject)
|
||||||
: DynamicObject(serializedObject)
|
: DynamicObject(serializedObject)
|
||||||
@ -479,6 +480,8 @@ void Service::OnAttributeChanged(const String& name, const Value& oldValue)
|
|||||||
{
|
{
|
||||||
if (name == "checker")
|
if (name == "checker")
|
||||||
OnCheckerChanged(GetSelf(), oldValue);
|
OnCheckerChanged(GetSelf(), oldValue);
|
||||||
|
else if (name == "next_check")
|
||||||
|
OnNextCheckChanged(GetSelf(), oldValue);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Service::BeginExecuteCheck(const function<void (void)>& callback)
|
void Service::BeginExecuteCheck(const function<void (void)>& callback)
|
||||||
|
@ -131,6 +131,7 @@ public:
|
|||||||
|
|
||||||
static boost::signal<void (const Service::Ptr& service, const CheckResultMessage&)> OnCheckResultReceived;
|
static boost::signal<void (const Service::Ptr& service, const CheckResultMessage&)> OnCheckResultReceived;
|
||||||
static boost::signal<void (const Service::Ptr&, const String&)> OnCheckerChanged;
|
static boost::signal<void (const Service::Ptr&, const String&)> OnCheckerChanged;
|
||||||
|
static boost::signal<void (const Service::Ptr&, const Value&)> OnNextCheckChanged;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
virtual void OnAttributeChanged(const String& name, const Value& oldValue);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user