Skip to content

Commit

Permalink
Introduce Endpoint#seconds_{reading,processing}_messages for the API
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Dec 11, 2024
1 parent b7788d2 commit 20460e6
Show file tree
Hide file tree
Showing 6 changed files with 51 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/base/benchmark.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ class Benchmark
* @return The total accumulated time in seconds
*/
template<class T>
explicit operator T() const noexcept
operator T() const noexcept
{
return std::chrono::duration<T>(Clock::duration(m_Sum.load(std::memory_order_relaxed))).count();
}
Expand Down
11 changes: 10 additions & 1 deletion lib/methods/clusterzonechecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
double messagesReceivedPerSecond = 0;
double bytesSentPerSecond = 0;
double bytesReceivedPerSecond = 0;
double secondsReadingMessages = 0;
double secondsAwaitingSemaphore = 0;
double secondsProcessingMessages = 0;

{
auto endpoints (zone->GetEndpoints());
Expand All @@ -160,6 +163,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
}

if (!connected && endpoints.size() == 1u && *endpoints.begin() == Endpoint::GetLocalEndpoint()) {
Expand Down Expand Up @@ -210,7 +216,10 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond),
new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond),
new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond),
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond)
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond),
new PerfdataValue("sum_seconds_reading_messages", secondsReadingMessages),
new PerfdataValue("sum_seconds_awaiting_semaphore", secondsAwaitingSemaphore),
new PerfdataValue("sum_seconds_processing_messages", secondsProcessingMessages)
}));

checkable->ProcessCheckResult(cr);
Expand Down
9 changes: 9 additions & 0 deletions lib/methods/icingachecktask.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
double messagesReceivedPerSecond = 0;
double bytesSentPerSecond = 0;
double bytesReceivedPerSecond = 0;
double secondsReadingMessages = 0;
double secondsAwaitingSemaphore = 0;
double secondsProcessingMessages = 0;

for (const Endpoint::Ptr& endpoint : endpoints)
{
Expand All @@ -140,6 +143,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
}

perfdata->Add(new PerfdataValue("last_messages_sent", lastMessageSent));
Expand All @@ -148,6 +154,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
perfdata->Add(new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond));
perfdata->Add(new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond));
perfdata->Add(new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond));
perfdata->Add(new PerfdataValue("sum_seconds_reading_messages", secondsReadingMessages));
perfdata->Add(new PerfdataValue("sum_seconds_awaiting_semaphore", secondsAwaitingSemaphore));
perfdata->Add(new PerfdataValue("sum_seconds_processing_messages", secondsProcessingMessages));

cr->SetPerformanceData(perfdata);
ServiceState state = ServiceOK;
Expand Down
15 changes: 15 additions & 0 deletions lib/remote/endpoint.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,3 +136,18 @@ double Endpoint::GetBytesReceivedPerSecond() const
{
return m_BytesReceived.CalculateRate(Utility::GetTime(), 60);
}

double Endpoint::GetSecondsReadingMessages() const
{
return m_InputReadTime;
}

double Endpoint::GetSecondsAwaitingSemaphore() const
{
return m_InputSemaphoreTime;
}

double Endpoint::GetSecondsProcessingMessages() const
{
return m_InputProcessTime;
}
4 changes: 4 additions & 0 deletions lib/remote/endpoint.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,10 @@ class Endpoint final : public ObjectImpl<Endpoint>
double GetBytesSentPerSecond() const override;
double GetBytesReceivedPerSecond() const override;

double GetSecondsReadingMessages() const override;
double GetSecondsAwaitingSemaphore() const override;
double GetSecondsProcessingMessages() const override;

protected:
void OnAllConfigLoaded() override;

Expand Down
12 changes: 12 additions & 0 deletions lib/remote/endpoint.ti
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,18 @@ class Endpoint : ConfigObject
[no_user_modify, no_storage] double bytes_received_per_second {
get;
};

[no_user_modify, no_storage] double seconds_reading_messages {
get;
};

[no_user_modify, no_storage] double seconds_awaiting_semaphore {
get;
};

[no_user_modify, no_storage] double seconds_processing_messages {
get;
};
};

}

0 comments on commit 20460e6

Please sign in to comment.