Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions lib/perfdata/gelfwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,12 @@ void GelfWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr& perf
for (const GelfWriter::Ptr& gelfwriter : ConfigType::GetObjectsByType<GelfWriter>()) {
size_t workQueueItems = gelfwriter->m_WorkQueue.GetLength();
double workQueueItemRate = gelfwriter->m_WorkQueue.GetTaskCount(60) / 60.0;
auto connection = gelfwriter->m_LockedConnection.load();

nodes.emplace_back(gelfwriter->GetName(), new Dictionary({
{ "work_queue_items", workQueueItems },
{ "work_queue_item_rate", workQueueItemRate },
{ "connected", gelfwriter->m_Connection->IsConnected() },
{ "connected", connection && connection->IsConnected() },
{ "source", gelfwriter->GetSource() }
}));

Expand Down Expand Up @@ -90,7 +91,8 @@ void GelfWriter::Resume()
/* Register exception handler for WQ tasks. */
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

m_Connection = new PerfdataWriterConnection{this, GetHost(), GetPort(), m_SslContext, !GetInsecureNoverify()};
m_LockedConnection.store(new PerfdataWriterConnection{this, GetHost(), GetPort(), m_SslContext, !GetInsecureNoverify()});
m_Connection = m_LockedConnection.load();

/* Register event handlers. */
m_HandleCheckResults = Checkable::OnNewCheckResult.connect([this](const Checkable::Ptr& checkable,
Expand Down
1 change: 1 addition & 0 deletions lib/perfdata/gelfwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ class GelfWriter final : public ObjectImpl<GelfWriter>

private:
PerfdataWriterConnection::Ptr m_Connection;
Locked<PerfdataWriterConnection::Ptr> m_LockedConnection;
WorkQueue m_WorkQueue{10000000, 1};
Shared<boost::asio::ssl::context>::Ptr m_SslContext;

Expand Down
6 changes: 4 additions & 2 deletions lib/perfdata/graphitewriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,12 @@ void GraphiteWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&
for (const GraphiteWriter::Ptr& graphitewriter : ConfigType::GetObjectsByType<GraphiteWriter>()) {
size_t workQueueItems = graphitewriter->m_WorkQueue.GetLength();
double workQueueItemRate = graphitewriter->m_WorkQueue.GetTaskCount(60) / 60.0;
auto connection = graphitewriter->m_LockedConnection.load();

nodes.emplace_back(graphitewriter->GetName(), new Dictionary({
{ "work_queue_items", workQueueItems },
{ "work_queue_item_rate", workQueueItemRate },
{ "connected", graphitewriter->m_Connection->IsConnected() }
{ "connected", connection && connection->IsConnected() }
}));

perfdata->Add(new PerfdataValue("graphitewriter_" + graphitewriter->GetName() + "_work_queue_items", workQueueItems));
Expand All @@ -85,7 +86,8 @@ void GraphiteWriter::Resume()
/* Register exception handler for WQ tasks. */
m_WorkQueue.SetExceptionCallback([this](boost::exception_ptr exp) { ExceptionHandler(std::move(exp)); });

m_Connection = new PerfdataWriterConnection{this, GetHost(), GetPort()};
m_LockedConnection.store(new PerfdataWriterConnection{this, GetHost(), GetPort()});
m_Connection = m_LockedConnection.load();

/* Register event handlers. */
m_HandleCheckResults = Checkable::OnNewCheckResult.connect([this](const Checkable::Ptr& checkable,
Expand Down
1 change: 1 addition & 0 deletions lib/perfdata/graphitewriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ class GraphiteWriter final : public ObjectImpl<GraphiteWriter>

private:
PerfdataWriterConnection::Ptr m_Connection;
Locked<PerfdataWriterConnection::Ptr> m_LockedConnection;
WorkQueue m_WorkQueue{10000000, 1};

boost::signals2::connection m_HandleCheckResults;
Expand Down
6 changes: 4 additions & 2 deletions lib/perfdata/opentsdbwriter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -55,11 +55,12 @@ void OpenTsdbWriter::StatsFunc(const Dictionary::Ptr& status, const Array::Ptr&
for (const OpenTsdbWriter::Ptr& opentsdbwriter : ConfigType::GetObjectsByType<OpenTsdbWriter>()) {
size_t workQueueItems = opentsdbwriter->m_WorkQueue.GetLength();
double workQueueItemRate = opentsdbwriter->m_WorkQueue.GetTaskCount(60) / 60.0;
auto connection = opentsdbwriter->m_LockedConnection.load();

nodes.emplace_back(
opentsdbwriter->GetName(),
new Dictionary({
{ "connected", opentsdbwriter->m_Connection->IsConnected() },
{ "connected", connection && connection->IsConnected() },
{"work_queue_items", workQueueItems},
{"work_queue_item_rate", workQueueItemRate}
}
Expand Down Expand Up @@ -90,7 +91,8 @@ void OpenTsdbWriter::Resume()

ReadConfigTemplate();

m_Connection = new PerfdataWriterConnection{this, GetHost(), GetPort()};
m_LockedConnection.store(new PerfdataWriterConnection{this, GetHost(), GetPort()});
m_Connection = m_LockedConnection.load();

m_HandleCheckResults = Service::OnNewCheckResult.connect([this](const Checkable::Ptr& checkable, const CheckResult::Ptr& cr, const MessageOrigin::Ptr&) {
CheckResultHandler(checkable, cr);
Expand Down
1 change: 1 addition & 0 deletions lib/perfdata/opentsdbwriter.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ class OpenTsdbWriter final : public ObjectImpl<OpenTsdbWriter>
WorkQueue m_WorkQueue{10000000, 1};
std::string m_MsgBuf;
PerfdataWriterConnection::Ptr m_Connection;
Locked<PerfdataWriterConnection::Ptr> m_LockedConnection;

boost::signals2::connection m_HandleCheckResults;

Expand Down
Loading