Introduce Endpoint#seconds_{reading_messages,awaiting_semaphore,processing_messages} for the API

This commit is contained in:
Alexander A. Klimov 2024-12-10 16:19:10 +01:00 committed by Alvar Penning
parent 9f783baeb1
commit 01d4626d29
No known key found for this signature in database
6 changed files with 51 additions and 2 deletions

View File

@ -25,7 +25,7 @@ public:
* @return The total accumulated time in seconds * @return The total accumulated time in seconds
*/ */
template<class T> 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(); return std::chrono::duration<T>(Clock::duration(m_Sum.load(std::memory_order_relaxed))).count();
} }

View File

@ -137,6 +137,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
double messagesReceivedPerSecond = 0; double messagesReceivedPerSecond = 0;
double bytesSentPerSecond = 0; double bytesSentPerSecond = 0;
double bytesReceivedPerSecond = 0; double bytesReceivedPerSecond = 0;
double secondsReadingMessages = 0;
double secondsAwaitingSemaphore = 0;
double secondsProcessingMessages = 0;
{ {
auto endpoints (zone->GetEndpoints()); auto endpoints (zone->GetEndpoints());
@ -160,6 +163,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond(); messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
bytesSentPerSecond += endpoint->GetBytesSentPerSecond(); bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond(); bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
} }
if (!connected && endpoints.size() == 1u && *endpoints.begin() == Endpoint::GetLocalEndpoint()) { if (!connected && endpoints.size() == 1u && *endpoints.begin() == Endpoint::GetLocalEndpoint()) {
@ -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_sent_per_second", messagesSentPerSecond),
new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond), new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond),
new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond), 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); checkable->ProcessCheckResult(cr);

View File

@ -127,6 +127,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
double messagesReceivedPerSecond = 0; double messagesReceivedPerSecond = 0;
double bytesSentPerSecond = 0; double bytesSentPerSecond = 0;
double bytesReceivedPerSecond = 0; double bytesReceivedPerSecond = 0;
double secondsReadingMessages = 0;
double secondsAwaitingSemaphore = 0;
double secondsProcessingMessages = 0;
for (const Endpoint::Ptr& endpoint : endpoints) for (const Endpoint::Ptr& endpoint : endpoints)
{ {
@ -140,6 +143,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond(); messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
bytesSentPerSecond += endpoint->GetBytesSentPerSecond(); bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond(); bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
} }
perfdata->Add(new PerfdataValue("last_messages_sent", lastMessageSent)); perfdata->Add(new PerfdataValue("last_messages_sent", lastMessageSent));
@ -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_messages_received_per_second", messagesReceivedPerSecond));
perfdata->Add(new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond)); 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_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); cr->SetPerformanceData(perfdata);
ServiceState state = ServiceOK; ServiceState state = ServiceOK;

View File

@ -136,3 +136,18 @@ double Endpoint::GetBytesReceivedPerSecond() const
{ {
return m_BytesReceived.CalculateRate(Utility::GetTime(), 60); 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;
}

View File

@ -58,6 +58,10 @@ public:
double GetBytesSentPerSecond() const override; double GetBytesSentPerSecond() const override;
double GetBytesReceivedPerSecond() const override; double GetBytesReceivedPerSecond() const override;
double GetSecondsReadingMessages() const override;
double GetSecondsAwaitingSemaphore() const override;
double GetSecondsProcessingMessages() const override;
protected: protected:
void OnAllConfigLoaded() override; void OnAllConfigLoaded() override;

View File

@ -54,6 +54,18 @@ class Endpoint : ConfigObject
[no_user_modify, no_storage] double bytes_received_per_second { [no_user_modify, no_storage] double bytes_received_per_second {
get; 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;
};
}; };
} }