Skip to content

Commit c305d1b

Browse files
committed
Introduce Endpoint#messages_received_per_type
1 parent 30067b2 commit c305d1b

File tree

3 files changed

+21
-0
lines changed

3 files changed

+21
-0
lines changed

lib/remote/endpoint.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
/* Icinga 2 | (c) 2012 Icinga GmbH | GPLv2+ */
22

3+
#include "remote/apifunction.hpp"
34
#include "remote/endpoint.hpp"
45
#include "remote/endpoint-ti.cpp"
56
#include "remote/apilistener.hpp"
@@ -136,3 +137,17 @@ double Endpoint::GetBytesReceivedPerSecond() const
136137
{
137138
return m_BytesReceived.CalculateRate(Utility::GetTime(), 60);
138139
}
140+
141+
Dictionary::Ptr Endpoint::GetMessagesReceivedPerType() const
142+
{
143+
DictionaryData result;
144+
145+
{
146+
std::shared_lock sLock (m_MessageCountersMutex);
147+
148+
for (auto& [afunc, cnt] : m_MessageCounters)
149+
result.emplace_back(afunc->GetName(), cnt.load(std::memory_order_relaxed));
150+
}
151+
152+
return new Dictionary(std::move(result));
153+
}

lib/remote/endpoint.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,8 @@ class Endpoint final : public ObjectImpl<Endpoint>
5656
double GetBytesSentPerSecond() const override;
5757
double GetBytesReceivedPerSecond() const override;
5858

59+
Dictionary::Ptr GetMessagesReceivedPerType() const override;
60+
5961
protected:
6062
void OnAllConfigLoaded() override;
6163

lib/remote/endpoint.ti

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,10 @@ class Endpoint : ConfigObject
5454
[no_user_modify, no_storage] double bytes_received_per_second {
5555
get;
5656
};
57+
58+
[no_user_modify, no_storage] Dictionary::Ptr messages_received_per_type {
59+
get;
60+
};
5761
};
5862

5963
}

0 commit comments

Comments
 (0)