]> granicus.if.org Git - icinga2/commitdiff
Add more log messages for API connections
authorGunnar Beutner <gunnar.beutner@netways.de>
Fri, 22 Aug 2014 13:39:34 +0000 (15:39 +0200)
committerGunnar Beutner <gunnar.beutner@netways.de>
Fri, 22 Aug 2014 13:39:34 +0000 (15:39 +0200)
refs #6066

lib/remote/apiclient.cpp
lib/remote/apilistener.cpp
lib/remote/endpoint.cpp

index 303087fb849d4b5a3779bb1db5aee39e6e805122..0c0b17279675d5893082a202e0dc9f5b7ce614b9 100644 (file)
@@ -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)
index 3c7c11403e1ee1cacf069da22b5d88135ffa993d..17a514b370304c77f3ddc5202e25ace9d2d93fcd 100644 (file)
@@ -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<TcpSocket>();
 
        try {
index b34740f8fff6df62769af3e8995348850b822b3f..fa05bb9cc09255a69a22005f1d8f383cd032bf63 100644 (file)
@@ -24,6 +24,7 @@
 #include "base/dynamictype.hpp"
 #include "base/utility.hpp"
 #include "base/exception.hpp"
+#include "base/convert.hpp"
 #include <boost/foreach.hpp>
 
 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();