REGISTER_STATSFUNCTION(PerfdataWriter, &PerfdataWriter::StatsFunc);
+void PerfdataWriter::OnConfigLoaded()
+{
+ ObjectImpl<PerfdataWriter>::OnConfigLoaded();
+
+ if (!GetEnableHa()) {
+ Log(LogDebug, "PerfdataWriter")
+ << "HA functionality disabled. Won't pause connection: " << GetName();
+
+ SetHAMode(HARunEverywhere);
+ } else {
+ SetHAMode(HARunOnce);
+ }
+}
+
void PerfdataWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&)
{
DictionaryData nodes;
status->Set("perfdatawriter", new Dictionary(std::move(nodes)));
}
-void PerfdataWriter::Start(bool runtimeCreated)
+void PerfdataWriter::Resume()
{
- ObjectImpl<PerfdataWriter>::Start(runtimeCreated);
+ ObjectImpl<PerfdataWriter>::Resume();
Log(LogInformation, "PerfdataWriter")
- << "'" << GetName() << "' started.";
+ << "'" << GetName() << "' resumed.";
Checkable::OnNewCheckResult.connect(std::bind(&PerfdataWriter::CheckResultHandler, this, _1, _2));
RotateFile(m_HostOutputFile, GetHostTempPath(), GetHostPerfdataPath());
}
-void PerfdataWriter::Stop(bool runtimeRemoved)
+void PerfdataWriter::Pause()
{
Log(LogInformation, "PerfdataWriter")
- << "'" << GetName() << "' stopped.";
+ << "'" << GetName() << "' paused.";
- ObjectImpl<PerfdataWriter>::Stop(runtimeRemoved);
+ ObjectImpl<PerfdataWriter>::Pause();
}
Value PerfdataWriter::EscapeMacroMetric(const Value& value)
void PerfdataWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
{
+ if (IsPaused())
+ return;
+
CONTEXT("Writing performance data for object '" + checkable->GetName() + "'");
if (!IcingaApplication::GetInstance()->GetEnablePerfdata() || !checkable->GetEnablePerfdata())
void PerfdataWriter::RotationTimerHandler()
{
+ if (IsPaused())
+ return;
+
RotateFile(m_ServiceOutputFile, GetServiceTempPath(), GetServicePerfdataPath());
RotateFile(m_HostOutputFile, GetHostTempPath(), GetHostPerfdataPath());
}