Fix initial check schedule.

Fixes #5240
This commit is contained in:
Gunnar Beutner 2013-11-28 20:56:21 +01:00
parent 48569b6205
commit cac4167e79
5 changed files with 14 additions and 19 deletions

View File

@ -31,15 +31,18 @@ using namespace icinga;
REGISTER_TYPE(CheckerComponent);
void CheckerComponent::Start(void)
void CheckerComponent::OnConfigLoaded(void)
{
DynamicObject::Start();
DynamicObject::OnStarted.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
DynamicObject::OnStopped.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
DynamicObject::OnAuthorityChanged.connect(bind(&CheckerComponent::ObjectHandler, this, _1));
Service::OnNextCheckChanged.connect(bind(&CheckerComponent::NextCheckChangedHandler, this, _1));
}
void CheckerComponent::Start(void)
{
DynamicObject::Start();
m_Stopped = false;
@ -49,10 +52,6 @@ void CheckerComponent::Start(void)
m_ResultTimer->SetInterval(5);
m_ResultTimer->OnTimerExpired.connect(boost::bind(&CheckerComponent::ResultTimerHandler, this));
m_ResultTimer->Start();
BOOST_FOREACH(const Service::Ptr& service, DynamicType::GetObjects<Service>()) {
ObjectHandler(service);
}
}
void CheckerComponent::Stop(void)

View File

@ -67,6 +67,7 @@ public:
>
> ServiceSet;
virtual void OnConfigLoaded(void);
virtual void Start(void);
virtual void Stop(void);

View File

@ -45,11 +45,6 @@ boost::signals2::signal<void (const DynamicObject::Ptr&)> DynamicObject::OnState
boost::signals2::signal<void (const DynamicObject::Ptr&, const String&, bool)> DynamicObject::OnAuthorityChanged;
DynamicObject::DynamicObject(void)
{
SetActive(false);
}
DynamicObject::~DynamicObject(void)
{ }
DynamicType::Ptr DynamicObject::GetType(void) const

View File

@ -52,8 +52,6 @@ class I2_BASE_API DynamicObject : public ObjectImpl<DynamicObject>
public:
DECLARE_PTR_TYPEDEFS(DynamicObject);
~DynamicObject(void);
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStarted;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStopped;
static boost::signals2::signal<void (const DynamicObject::Ptr&)> OnStateChanged;

View File

@ -44,14 +44,19 @@ Service::Service(void)
void Service::Start(void)
{
DynamicObject::Start();
VERIFY(GetHost());
AddDowntimesToCache();
AddCommentsToCache();
StartDowntimesExpiredTimer();
double now = Utility::GetTime();
if (GetNextCheck() < now + 300)
SetNextCheck(now + Utility::Random() % 300);
DynamicObject::Start();
}
void Service::OnConfigLoaded(void)
@ -77,9 +82,6 @@ void Service::OnConfigLoaded(void)
UpdateSlaveNotifications();
SetSchedulingOffset(Utility::Random());
if (GetNextCheck() < Utility::GetTime() + 300)
SetNextCheck(Utility::GetTime() + Utility::Random() % 300);
}
Service::Ptr Service::GetByNamePair(const String& hostName, const String& serviceName)