Skip to content

Commit 20460e6

Browse files
committed
Introduce Endpoint#seconds_{reading,processing}_messages for the API
1 parent b7788d2 commit 20460e6

File tree

6 files changed

+51
-2
lines changed

6 files changed

+51
-2
lines changed

lib/base/benchmark.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class Benchmark
2525
* @return The total accumulated time in seconds
2626
*/
2727
template<class T>
28-
explicit operator T() const noexcept
28+
operator T() const noexcept
2929
{
3030
return std::chrono::duration<T>(Clock::duration(m_Sum.load(std::memory_order_relaxed))).count();
3131
}

lib/methods/clusterzonechecktask.cpp

+10-1
Original file line numberDiff line numberDiff line change
@@ -137,6 +137,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
137137
double messagesReceivedPerSecond = 0;
138138
double bytesSentPerSecond = 0;
139139
double bytesReceivedPerSecond = 0;
140+
double secondsReadingMessages = 0;
141+
double secondsAwaitingSemaphore = 0;
142+
double secondsProcessingMessages = 0;
140143

141144
{
142145
auto endpoints (zone->GetEndpoints());
@@ -160,6 +163,9 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
160163
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
161164
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
162165
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
166+
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
167+
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
168+
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
163169
}
164170

165171
if (!connected && endpoints.size() == 1u && *endpoints.begin() == Endpoint::GetLocalEndpoint()) {
@@ -210,7 +216,10 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
210216
new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond),
211217
new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond),
212218
new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond),
213-
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond)
219+
new PerfdataValue("sum_bytes_received_per_second", bytesReceivedPerSecond),
220+
new PerfdataValue("sum_seconds_reading_messages", secondsReadingMessages),
221+
new PerfdataValue("sum_seconds_awaiting_semaphore", secondsAwaitingSemaphore),
222+
new PerfdataValue("sum_seconds_processing_messages", secondsProcessingMessages)
214223
}));
215224

216225
checkable->ProcessCheckResult(cr);

lib/methods/icingachecktask.cpp

+9
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
127127
double messagesReceivedPerSecond = 0;
128128
double bytesSentPerSecond = 0;
129129
double bytesReceivedPerSecond = 0;
130+
double secondsReadingMessages = 0;
131+
double secondsAwaitingSemaphore = 0;
132+
double secondsProcessingMessages = 0;
130133

131134
for (const Endpoint::Ptr& endpoint : endpoints)
132135
{
@@ -140,6 +143,9 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
140143
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
141144
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
142145
bytesReceivedPerSecond += endpoint->GetBytesReceivedPerSecond();
146+
secondsReadingMessages += endpoint->GetSecondsReadingMessages();
147+
secondsAwaitingSemaphore += endpoint->GetSecondsAwaitingSemaphore();
148+
secondsProcessingMessages += endpoint->GetSecondsProcessingMessages();
143149
}
144150

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

152161
cr->SetPerformanceData(perfdata);
153162
ServiceState state = ServiceOK;

lib/remote/endpoint.cpp

+15
Original file line numberDiff line numberDiff line change
@@ -136,3 +136,18 @@ double Endpoint::GetBytesReceivedPerSecond() const
136136
{
137137
return m_BytesReceived.CalculateRate(Utility::GetTime(), 60);
138138
}
139+
140+
double Endpoint::GetSecondsReadingMessages() const
141+
{
142+
return m_InputReadTime;
143+
}
144+
145+
double Endpoint::GetSecondsAwaitingSemaphore() const
146+
{
147+
return m_InputSemaphoreTime;
148+
}
149+
150+
double Endpoint::GetSecondsProcessingMessages() const
151+
{
152+
return m_InputProcessTime;
153+
}

lib/remote/endpoint.hpp

+4
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ class Endpoint final : public ObjectImpl<Endpoint>
5858
double GetBytesSentPerSecond() const override;
5959
double GetBytesReceivedPerSecond() const override;
6060

61+
double GetSecondsReadingMessages() const override;
62+
double GetSecondsAwaitingSemaphore() const override;
63+
double GetSecondsProcessingMessages() const override;
64+
6165
protected:
6266
void OnAllConfigLoaded() override;
6367

lib/remote/endpoint.ti

+12
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,18 @@ class Endpoint : ConfigObject
5454
[no_user_modify, no_storage] double bytes_received_per_second {
5555
get;
5656
};
57+
58+
[no_user_modify, no_storage] double seconds_reading_messages {
59+
get;
60+
};
61+
62+
[no_user_modify, no_storage] double seconds_awaiting_semaphore {
63+
get;
64+
};
65+
66+
[no_user_modify, no_storage] double seconds_processing_messages {
67+
get;
68+
};
5769
};
5870

5971
}

0 commit comments

Comments
 (0)