mirror of
https://github.com/Icinga/icinga2.git
synced 2025-07-05 21:04:28 +02:00
InfluxdbWriter: Ensure to flush buffers after emptying the metrics queue on Pause/Shutdown/Reload
Patch taken from @al2klimov but moved into Pause()
This commit is contained in:
parent
d79390083d
commit
d4bdebc795
@ -130,13 +130,30 @@ void InfluxdbWriter::Resume()
|
|||||||
Checkable::OnNewCheckResult.connect(std::bind(&InfluxdbWriter::CheckResultHandler, this, _1, _2));
|
Checkable::OnNewCheckResult.connect(std::bind(&InfluxdbWriter::CheckResultHandler, this, _1, _2));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Pause is equivalent to Stop, but with HA capabilities to resume at runtime. */
|
||||||
void InfluxdbWriter::Pause()
|
void InfluxdbWriter::Pause()
|
||||||
{
|
{
|
||||||
Log(LogInformation, "InfluxdbWriter")
|
/* Force a flush. */
|
||||||
<< "'" << GetName() << "' paused.";
|
Log(LogDebug, "InfluxdbWriter")
|
||||||
|
<< "Flushing pending data buffers.";
|
||||||
|
|
||||||
|
Flush();
|
||||||
|
|
||||||
|
/* Work on the missing tasks. TODO: Find a way to cache them on disk. */
|
||||||
|
Log(LogDebug, "InfluxdbWriter")
|
||||||
|
<< "Joining existing WQ tasks.";
|
||||||
|
|
||||||
m_WorkQueue.Join();
|
m_WorkQueue.Join();
|
||||||
|
|
||||||
|
/* Flush again after the WQ tasks have filled the data buffer. */
|
||||||
|
Log(LogDebug, "InfluxdbWriter")
|
||||||
|
<< "Flushing data buffers from WQ tasks.";
|
||||||
|
|
||||||
|
Flush();
|
||||||
|
|
||||||
|
Log(LogInformation, "InfluxdbWriter")
|
||||||
|
<< "'" << GetName() << "' paused.";
|
||||||
|
|
||||||
ObjectImpl<InfluxdbWriter>::Pause();
|
ObjectImpl<InfluxdbWriter>::Pause();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -428,6 +445,9 @@ void InfluxdbWriter::FlushTimeoutWQ()
|
|||||||
|
|
||||||
void InfluxdbWriter::Flush()
|
void InfluxdbWriter::Flush()
|
||||||
{
|
{
|
||||||
|
Log(LogDebug, "InfluxdbWriter")
|
||||||
|
<< "Flushing data buffer to InfluxDB.";
|
||||||
|
|
||||||
String body = boost::algorithm::join(m_DataBuffer, "\n");
|
String body = boost::algorithm::join(m_DataBuffer, "\n");
|
||||||
m_DataBuffer.clear();
|
m_DataBuffer.clear();
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user