mirror of
https://github.com/Icinga/icinga2.git
synced 2026-03-21 10:00:35 -04:00
Merge 731d3211ab into 6592eae21d
This commit is contained in:
commit
2e5b8659e7
7 changed files with 32 additions and 0 deletions
|
|
@ -134,6 +134,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
|||
|
||||
double lastMessageSent = 0;
|
||||
double lastMessageReceived = 0;
|
||||
uint_fast64_t pendingOutgoingMessages = 0;
|
||||
double messagesSentPerSecond = 0;
|
||||
double messagesReceivedPerSecond = 0;
|
||||
double bytesSentPerSecond = 0;
|
||||
|
|
@ -157,6 +158,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
|||
if (endpoint->GetLastMessageReceived() > lastMessageReceived)
|
||||
lastMessageReceived = endpoint->GetLastMessageReceived();
|
||||
|
||||
pendingOutgoingMessages += endpoint->GetPendingOutgoingMessages();
|
||||
messagesSentPerSecond += endpoint->GetMessagesSentPerSecond();
|
||||
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
|
||||
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
|
||||
|
|
@ -208,6 +210,7 @@ void ClusterZoneCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const Che
|
|||
new PerfdataValue("slave_lag", zoneLag, false, "s", lagWarning, lagCritical),
|
||||
new PerfdataValue("last_messages_sent", lastMessageSent),
|
||||
new PerfdataValue("last_messages_received", lastMessageReceived),
|
||||
new PerfdataValue("sum_pending_outgoing_messages", pendingOutgoingMessages),
|
||||
new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond),
|
||||
new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond),
|
||||
new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond),
|
||||
|
|
|
|||
|
|
@ -124,6 +124,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
|||
|
||||
double lastMessageSent = 0;
|
||||
double lastMessageReceived = 0;
|
||||
uint_fast64_t pendingOutgoingMessages = 0;
|
||||
double messagesSentPerSecond = 0;
|
||||
double messagesReceivedPerSecond = 0;
|
||||
double bytesSentPerSecond = 0;
|
||||
|
|
@ -137,6 +138,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
|||
if (endpoint->GetLastMessageReceived() > lastMessageReceived)
|
||||
lastMessageReceived = endpoint->GetLastMessageReceived();
|
||||
|
||||
pendingOutgoingMessages += endpoint->GetPendingOutgoingMessages();
|
||||
messagesSentPerSecond += endpoint->GetMessagesSentPerSecond();
|
||||
messagesReceivedPerSecond += endpoint->GetMessagesReceivedPerSecond();
|
||||
bytesSentPerSecond += endpoint->GetBytesSentPerSecond();
|
||||
|
|
@ -145,6 +147,7 @@ void IcingaCheckTask::ScriptFunc(const Checkable::Ptr& checkable, const CheckRes
|
|||
|
||||
perfdata->Add(new PerfdataValue("last_messages_sent", lastMessageSent));
|
||||
perfdata->Add(new PerfdataValue("last_messages_received", lastMessageReceived));
|
||||
perfdata->Add(new PerfdataValue("sum_pending_outgoing_messages", pendingOutgoingMessages));
|
||||
perfdata->Add(new PerfdataValue("sum_messages_sent_per_second", messagesSentPerSecond));
|
||||
perfdata->Add(new PerfdataValue("sum_messages_received_per_second", messagesReceivedPerSecond));
|
||||
perfdata->Add(new PerfdataValue("sum_bytes_sent_per_second", bytesSentPerSecond));
|
||||
|
|
|
|||
|
|
@ -110,6 +110,18 @@ Endpoint::Ptr Endpoint::GetLocalEndpoint()
|
|||
return listener->GetLocalEndpoint();
|
||||
}
|
||||
|
||||
uint_fast64_t Endpoint::GetPendingOutgoingMessages() const
|
||||
{
|
||||
uint_fast64_t pending = 0;
|
||||
std::unique_lock lock (m_ClientsLock);
|
||||
|
||||
for (auto& client : m_Clients) {
|
||||
pending += client->GetPendingOutgoingMessages();
|
||||
}
|
||||
|
||||
return pending;
|
||||
}
|
||||
|
||||
void Endpoint::AddMessageSent(int bytes)
|
||||
{
|
||||
double time = Utility::GetTime();
|
||||
|
|
|
|||
|
|
@ -46,6 +46,7 @@ public:
|
|||
static Endpoint::Ptr GetLocalEndpoint();
|
||||
|
||||
void SetCachedZone(const intrusive_ptr<Zone>& zone);
|
||||
uint_fast64_t GetPendingOutgoingMessages() const override;
|
||||
|
||||
void AddMessageSent(int bytes);
|
||||
void AddMessageReceived(int bytes);
|
||||
|
|
|
|||
|
|
@ -40,6 +40,10 @@ class Endpoint : ConfigObject
|
|||
Timestamp last_message_sent;
|
||||
Timestamp last_message_received;
|
||||
|
||||
[no_user_modify, no_storage] uint_fast64_t pending_outgoing_messages {
|
||||
get;
|
||||
};
|
||||
|
||||
[no_user_modify, no_storage] double messages_sent_per_second {
|
||||
get;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -158,6 +158,7 @@ void JsonRpcConnection::WriteOutgoingMessages(boost::asio::yield_context yc)
|
|||
}
|
||||
|
||||
size_t bytesSent = JsonRpc::SendRawMessage(m_Stream, message, yc);
|
||||
m_PendingOutgoingMessages.fetch_sub(1, std::memory_order_relaxed);
|
||||
|
||||
if (m_Endpoint) {
|
||||
m_Endpoint->AddMessageSent(bytesSent);
|
||||
|
|
@ -234,6 +235,7 @@ void JsonRpcConnection::SendRawMessage(const String& message)
|
|||
|
||||
m_OutgoingMessagesQueue.emplace_back(message);
|
||||
m_OutgoingMessagesQueued.Set();
|
||||
m_PendingOutgoingMessages.fetch_add(1, std::memory_order_relaxed);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
@ -245,6 +247,7 @@ void JsonRpcConnection::SendMessageInternal(const Dictionary::Ptr& message)
|
|||
|
||||
m_OutgoingMessagesQueue.emplace_back(JsonEncode(message));
|
||||
m_OutgoingMessagesQueued.Set();
|
||||
m_PendingOutgoingMessages.fetch_add(1, std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void JsonRpcConnection::Disconnect()
|
||||
|
|
|
|||
|
|
@ -57,6 +57,11 @@ public:
|
|||
Shared<AsioTlsStream>::Ptr GetStream() const;
|
||||
ConnectionRole GetRole() const;
|
||||
|
||||
auto GetPendingOutgoingMessages() const noexcept
|
||||
{
|
||||
return m_PendingOutgoingMessages.load(std::memory_order_relaxed);
|
||||
}
|
||||
|
||||
void Disconnect();
|
||||
|
||||
void SendMessage(const Dictionary::Ptr& request);
|
||||
|
|
@ -79,6 +84,7 @@ private:
|
|||
boost::asio::io_context::strand m_IoStrand;
|
||||
std::vector<String> m_OutgoingMessagesQueue;
|
||||
AsioEvent m_OutgoingMessagesQueued;
|
||||
Atomic<decltype(m_OutgoingMessagesQueue)::size_type> m_PendingOutgoingMessages {0};
|
||||
AsioEvent m_WriterDone;
|
||||
Atomic<bool> m_ShuttingDown;
|
||||
WaitGroup::Ptr m_WaitGroup;
|
||||
|
|
|
|||
Loading…
Reference in a new issue