From: Gunnar Beutner Date: Fri, 22 Aug 2014 13:39:34 +0000 (+0200) Subject: Add more log messages for API connections X-Git-Tag: v2.1.0~27 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=29db3f097278a0d38ef4154c6af5b06e5e79581c;p=icinga2 Add more log messages for API connections refs #6066 --- diff --git a/lib/remote/apiclient.cpp b/lib/remote/apiclient.cpp index 303087fb8..0c0b17279 100644 --- a/lib/remote/apiclient.cpp +++ b/lib/remote/apiclient.cpp @@ -175,11 +175,11 @@ void ApiClient::MessageThreadProc(void) try { while (ProcessMessage()) ; /* empty loop body */ - - Disconnect(); } catch (const std::exception& ex) { Log(LogWarning, "ApiClient", "Error while reading JSON-RPC message for identity '" + m_Identity + "': " + DiagnosticInformation(ex)); } + + Disconnect(); } Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params) diff --git a/lib/remote/apilistener.cpp b/lib/remote/apilistener.cpp index 3c7c11403..17a514b37 100644 --- a/lib/remote/apilistener.cpp +++ b/lib/remote/apilistener.cpp @@ -231,6 +231,8 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint) String host = endpoint->GetHost(); String port = endpoint->GetPort(); + Log(LogWarning, "ApiClient", "Reconnecting to API endpoint '" + endpoint->GetName() + "' via host '" + host + "' and port " + port); + TcpSocket::Ptr client = make_shared(); try { diff --git a/lib/remote/endpoint.cpp b/lib/remote/endpoint.cpp index b34740f8f..fa05bb9cc 100644 --- a/lib/remote/endpoint.cpp +++ b/lib/remote/endpoint.cpp @@ -24,6 +24,7 @@ #include "base/dynamictype.hpp" #include "base/utility.hpp" #include "base/exception.hpp" +#include "base/convert.hpp" #include using namespace icinga; @@ -79,6 +80,8 @@ void Endpoint::RemoveClient(const ApiClient::Ptr& client) { boost::mutex::scoped_lock lock(m_ClientsLock); m_Clients.erase(client); + + Log(LogWarning, "ApiListener", "Removing API client for endpoint '" + GetName() + "'. " + Convert::ToString(m_Clients.size()) + " API clients left."); } bool is_master = ApiListener::GetInstance()->IsMaster();