From: Alexander A. Klimov Date: Wed, 20 Feb 2019 13:24:09 +0000 (+0100) Subject: JsonRpcConnection: re-add num_json_rpc_work_queue_item_rate X-Git-Tag: v2.11.0-rc1~174^2~29 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a451327b816684dd5a525f22b09f668f7c6a404e;p=icinga2 JsonRpcConnection: re-add num_json_rpc_work_queue_item_rate --- diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index dccb8867f..ebe18358b 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -1466,6 +1466,7 @@ std::pair ApiListener::GetStatus() size_t httpClients = GetHttpClients().size(); size_t syncQueueItems = m_SyncQueue.GetLength(); size_t relayQueueItems = m_RelayQueue.GetLength(); + double workQueueItemRate = JsonRpcConnection::GetWorkQueueRate(); double syncQueueItemRate = m_SyncQueue.GetTaskCount(60) / 60.0; double relayQueueItemRate = m_RelayQueue.GetTaskCount(60) / 60.0; @@ -1483,6 +1484,7 @@ std::pair ApiListener::GetStatus() { "anonymous_clients", jsonRpcAnonymousClients }, { "sync_queue_items", syncQueueItems }, { "relay_queue_items", relayQueueItems }, + { "work_queue_item_rate", workQueueItemRate }, { "sync_queue_item_rate", syncQueueItemRate }, { "relay_queue_item_rate", relayQueueItemRate } }) }, @@ -1502,6 +1504,7 @@ std::pair ApiListener::GetStatus() perfdata->Set("num_json_rpc_sync_queue_items", syncQueueItems); perfdata->Set("num_json_rpc_relay_queue_items", relayQueueItems); + perfdata->Set("num_json_rpc_work_queue_item_rate", workQueueItemRate); perfdata->Set("num_json_rpc_sync_queue_item_rate", syncQueueItemRate); perfdata->Set("num_json_rpc_relay_queue_item_rate", relayQueueItemRate); diff --git a/lib/remote/jsonrpcconnection.cpp b/lib/remote/jsonrpcconnection.cpp index 73fcc6398..d529427f0 100644 --- a/lib/remote/jsonrpcconnection.cpp +++ b/lib/remote/jsonrpcconnection.cpp @@ -25,6 +25,8 @@ using namespace icinga; static Value SetLogPositionHandler(const MessageOrigin::Ptr& origin, const Dictionary::Ptr& params); REGISTER_APIFUNCTION(SetLogPosition, log, &SetLogPositionHandler); +static RingBuffer l_TaskStats (15 * 60); + JsonRpcConnection::JsonRpcConnection(const String& identity, bool authenticated, const std::shared_ptr& stream, ConnectionRole role) : m_Identity(identity), m_Authenticated(authenticated), m_Stream(stream), @@ -84,6 +86,8 @@ void JsonRpcConnection::HandleIncomingMessages(boost::asio::yield_context yc) break; } + + l_TaskStats.InsertValue(Utility::GetTime(), 1); } } @@ -319,3 +323,8 @@ void JsonRpcConnection::CheckLiveness(boost::asio::yield_context yc) } } } + +double JsonRpcConnection::GetWorkQueueRate() +{ + return l_TaskStats.UpdateAndGetValues(Utility::GetTime(), 60) / 60.0; +} diff --git a/lib/remote/jsonrpcconnection.hpp b/lib/remote/jsonrpcconnection.hpp index 13ee5f62d..bc5fa398d 100644 --- a/lib/remote/jsonrpcconnection.hpp +++ b/lib/remote/jsonrpcconnection.hpp @@ -58,6 +58,8 @@ public: static Value HeartbeatAPIHandler(const intrusive_ptr& origin, const Dictionary::Ptr& params); + static double GetWorkQueueRate(); + static void SendCertificateRequest(const JsonRpcConnection::Ptr& aclient, const intrusive_ptr& origin, const String& path); private: