mirror of https://github.com/Icinga/icinga2.git
parent
ad6c8eaf7e
commit
c5fe42e0b0
|
@ -74,13 +74,15 @@ void StatusDataWriter::Start(void)
|
|||
{
|
||||
ObjectImpl<StatusDataWriter>::Start();
|
||||
|
||||
m_ObjectsCacheOutdated = true;
|
||||
|
||||
m_StatusTimer = new Timer();
|
||||
m_StatusTimer->SetInterval(GetUpdateInterval());
|
||||
m_StatusTimer->OnTimerExpired.connect(boost::bind(&StatusDataWriter::StatusTimerHandler, this));
|
||||
m_StatusTimer->Start();
|
||||
m_StatusTimer->Reschedule(0);
|
||||
|
||||
Utility::QueueAsyncCallback(boost::bind(&StatusDataWriter::UpdateObjectsCache, this));
|
||||
ConfigObject::OnVersionChanged.connect(boost::bind(&StatusDataWriter::VersionChangedHandler, this));
|
||||
}
|
||||
|
||||
void StatusDataWriter::DumpComments(std::ostream& fp, const Checkable::Ptr& checkable)
|
||||
|
@ -784,6 +786,11 @@ void StatusDataWriter::UpdateObjectsCache(void)
|
|||
*/
|
||||
void StatusDataWriter::StatusTimerHandler(void)
|
||||
{
|
||||
if (m_ObjectsCacheOutdated) {
|
||||
UpdateObjectsCache();
|
||||
m_ObjectsCacheOutdated = false;
|
||||
}
|
||||
|
||||
double start = Utility::GetTime();
|
||||
|
||||
String statuspath = GetStatusPath();
|
||||
|
@ -859,3 +866,8 @@ void StatusDataWriter::StatusTimerHandler(void)
|
|||
Log(LogNotice, "StatusDataWriter")
|
||||
<< "Writing status.dat file took " << Utility::FormatDuration(Utility::GetTime() - start);
|
||||
}
|
||||
|
||||
void StatusDataWriter::VersionChangedHandler(void)
|
||||
{
|
||||
m_ObjectsCacheOutdated = true;
|
||||
}
|
||||
|
|
|
@ -51,6 +51,7 @@ protected:
|
|||
|
||||
private:
|
||||
Timer::Ptr m_StatusTimer;
|
||||
bool m_ObjectsCacheOutdated;
|
||||
|
||||
void DumpCommand(std::ostream& fp, const Command::Ptr& command);
|
||||
void DumpTimePeriod(std::ostream& fp, const TimePeriod::Ptr& tp);
|
||||
|
@ -99,6 +100,7 @@ private:
|
|||
|
||||
void UpdateObjectsCache(void);
|
||||
void StatusTimerHandler(void);
|
||||
void VersionChangedHandler(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue