Skip to content

Commit 731d321

Browse files
committed
Introduce Endpoint#pending_outgoing_messages for the API
1 parent 2495a9e commit 731d321

File tree

5 files changed

+23
-0
lines changed

5 files changed

+23
-0
lines changed

lib/methods/clusterzonechecktask.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
133133

134134
double lastMessageSent = 0;
135135
double lastMessageReceived = 0;
136+
uint_fast64_t pendingOutgoingMessages = 0;
136137
double messagesSentPerSecond = 0;
137138
double messagesReceivedPerSecond = 0;
138139
double bytesSentPerSecond = 0;
@@ -156,6 +157,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
156157
if (endpoint->GetLastMessageReceived() > lastMessageReceived)
157158
lastMessageReceived = endpoint->GetLastMessageReceived();
158159

160+
pendingOutgoingMessages += endpoint->GetPendingOutgoingMessages();
159161
messagesSentPerSecond += endpoint->GetMessagesSentPerSecond();
160162
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
161163
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
@@ -207,6 +209,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
207209
new PerfdataValue("slave_lag", zoneLag, false, "s", lagWarning, lagCritical),
208210
new PerfdataValue("last_messages_sent", lastMessageSent),
209211
new PerfdataValue("last_messages_received", lastMessageReceived),
212+
new PerfdataValue("sum_pending_outgoing_messages", pendingOutgoingMessages),
210213
new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond),
211214
new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond),
212215
new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond),

lib/methods/icingachecktask.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
123123

124124
double lastMessageSent = 0;
125125
double lastMessageReceived = 0;
126+
uint_fast64_t pendingOutgoingMessages = 0;
126127
double messagesSentPerSecond = 0;
127128
double messagesReceivedPerSecond = 0;
128129
double bytesSentPerSecond = 0;
@@ -136,6 +137,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
136137
if (endpoint->GetLastMessageReceived() > lastMessageReceived)
137138
lastMessageReceived = endpoint->GetLastMessageReceived();
138139

140+
pendingOutgoingMessages += endpoint->GetPendingOutgoingMessages();
139141
messagesSentPerSecond += endpoint->GetMessagesSentPerSecond();
140142
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
141143
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
@@ -144,6 +146,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
144146

145147
perfdata->Add(new PerfdataValue("last_messages_sent", lastMessageSent));
146148
perfdata->Add(new PerfdataValue("last_messages_received", lastMessageReceived));
149+
perfdata->Add(new PerfdataValue("sum_pending_outgoing_messages", pendingOutgoingMessages));
147150
perfdata->Add(new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond));
148151
perfdata->Add(new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond));
149152
perfdata->Add(new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond));

lib/remote/endpoint.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,18 @@ Endpoint::Ptr Endpoint::GetLocalEndpoint()
101101
return listener->GetLocalEndpoint();
102102
}
103103

104+
uint_fast64_t Endpoint::GetPendingOutgoingMessages() const
105+
{
106+
uint_fast64_t pending = 0;
107+
std::unique_lock lock (m_ClientsLock);
108+
109+
for (auto& client : m_Clients) {
110+
pending += client->GetPendingOutgoingMessages();
111+
}
112+
113+
return pending;
114+
}
115+
104116
void Endpoint::AddMessageSent(int bytes)
105117
{
106118
double time = Utility::GetTime();

lib/remote/endpoint.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ class Endpoint final : public ObjectImpl<Endpoint>
3939
static Endpoint::Ptr GetLocalEndpoint();
4040

4141
void SetCachedZone(const intrusive_ptr<Zone>& zone);
42+
uint_fast64_t GetPendingOutgoingMessages() const override;
4243

4344
void AddMessageSent(int bytes);
4445
void AddMessageReceived(int bytes);

lib/remote/endpoint.ti

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,10 @@ class Endpoint : ConfigObject
3939
Timestamp last_message_sent;
4040
Timestamp last_message_received;
4141

42+
[no_user_modify, no_storage] uint_fast64_t pending_outgoing_messages {
43+
get;
44+
};
45+
4246
[no_user_modify, no_storage] double messages_sent_per_second {
4347
get;
4448
};

0 commit comments

Comments
 (0)