mirror of https://github.com/Icinga/icinga2.git
Implement HA functionality for Graphite feature
This commit is contained in:
parent
59389f564c
commit
37ccffc7e5
|
@ -49,6 +49,15 @@ void GraphiteWriter::OnConfigLoaded()
|
||||||
ObjectImpl<GraphiteWriter>::OnConfigLoaded();
|
ObjectImpl<GraphiteWriter>::OnConfigLoaded();
|
||||||
|
|
||||||
m_WorkQueue.SetName("GraphiteWriter, " + GetName());
|
m_WorkQueue.SetName("GraphiteWriter, " + GetName());
|
||||||
|
|
||||||
|
if (!GetEnableHa()) {
|
||||||
|
Log(LogDebug, "GraphiteWriter")
|
||||||
|
<< "HA functionality disabled. Won't pause connection: " << GetName();
|
||||||
|
|
||||||
|
SetHAMode(HARunEverywhere);
|
||||||
|
} else {
|
||||||
|
SetHAMode(HARunOnce);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
void GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perfdata)
|
||||||
|
@ -72,12 +81,12 @@ void GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&
|
||||||
status->Set("graphitewriter", new Dictionary(std::move(nodes)));
|
status->Set("graphitewriter", new Dictionary(std::move(nodes)));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::Start(bool runtimeCreated)
|
void GraphiteWriter::Resume()
|
||||||
{
|
{
|
||||||
ObjectImpl<GraphiteWriter>::Start(runtimeCreated);
|
ObjectImpl<GraphiteWriter>::Resume();
|
||||||
|
|
||||||
Log(LogInformation, "GraphiteWriter")
|
Log(LogInformation, "GraphiteWriter")
|
||||||
<< "'" << GetName() << "' started.";
|
<< "'" << GetName() << "' resumed.";
|
||||||
|
|
||||||
/* Register exception handler for WQ tasks. */
|
/* Register exception handler for WQ tasks. */
|
||||||
m_WorkQueue.SetExceptionCallback(std::bind(&GraphiteWriter::ExceptionHandler, this, _1));
|
m_WorkQueue.SetExceptionCallback(std::bind(&GraphiteWriter::ExceptionHandler, this, _1));
|
||||||
|
@ -93,14 +102,14 @@ void GraphiteWriter::Start(bool runtimeCreated)
|
||||||
Checkable::OnNewCheckResult.connect(std::bind(&GraphiteWriter::CheckResultHandler, this, _1, _2));
|
Checkable::OnNewCheckResult.connect(std::bind(&GraphiteWriter::CheckResultHandler, this, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::Stop(bool runtimeRemoved)
|
void GraphiteWriter::Pause()
|
||||||
{
|
{
|
||||||
Log(LogInformation, "GraphiteWriter")
|
Log(LogInformation, "GraphiteWriter")
|
||||||
<< "'" << GetName() << "' stopped.";
|
<< "'" << GetName() << "' paused.";
|
||||||
|
|
||||||
m_WorkQueue.Join();
|
m_WorkQueue.Join();
|
||||||
|
|
||||||
ObjectImpl<GraphiteWriter>::Stop(runtimeRemoved);
|
ObjectImpl<GraphiteWriter>::Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
void GraphiteWriter::AssertOnWorkQueue()
|
void GraphiteWriter::AssertOnWorkQueue()
|
||||||
|
@ -126,6 +135,11 @@ void GraphiteWriter::Reconnect()
|
||||||
{
|
{
|
||||||
AssertOnWorkQueue();
|
AssertOnWorkQueue();
|
||||||
|
|
||||||
|
if (IsPaused()) {
|
||||||
|
SetConnected(false);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
double startTime = Utility::GetTime();
|
double startTime = Utility::GetTime();
|
||||||
|
|
||||||
CONTEXT("Reconnecting to Graphite '" + GetName() + "'");
|
CONTEXT("Reconnecting to Graphite '" + GetName() + "'");
|
||||||
|
@ -175,6 +189,9 @@ void GraphiteWriter::Disconnect()
|
||||||
|
|
||||||
void GraphiteWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
|
void GraphiteWriter::CheckResultHandler(const Checkable::Ptr& checkable, const CheckResult::Ptr& cr)
|
||||||
{
|
{
|
||||||
|
if (IsPaused())
|
||||||
|
return;
|
||||||
|
|
||||||
m_WorkQueue.Enqueue(std::bind(&GraphiteWriter::CheckResultHandlerInternal, this, checkable, cr));
|
m_WorkQueue.Enqueue(std::bind(&GraphiteWriter::CheckResultHandlerInternal, this, checkable, cr));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -49,8 +49,8 @@ public:
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
void OnConfigLoaded() override;
|
void OnConfigLoaded() override;
|
||||||
void Start(bool runtimeCreated) override;
|
void Resume() override;
|
||||||
void Stop(bool runtimeRemoved) override;
|
void Pause() override;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
Stream::Ptr m_Stream;
|
Stream::Ptr m_Stream;
|
||||||
|
|
|
@ -47,6 +47,9 @@ class GraphiteWriter : ConfigObject
|
||||||
[no_user_modify] bool should_connect {
|
[no_user_modify] bool should_connect {
|
||||||
default {{{ return true; }}}
|
default {{{ return true; }}}
|
||||||
};
|
};
|
||||||
|
[config] bool enable_ha {
|
||||||
|
default {{{ return true; }}}
|
||||||
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue