Add more log messages for API connections

refs #6066
This commit is contained in:
Gunnar Beutner 2014-08-22 15:39:34 +02:00
parent 913e35da9e
commit 29db3f0972
3 changed files with 7 additions and 2 deletions

View File

@ -175,11 +175,11 @@ void ApiClient::MessageThreadProc(void)
try { try {
while (ProcessMessage()) while (ProcessMessage())
; /* empty loop body */ ; /* empty loop body */
Disconnect();
} catch (const std::exception& ex) { } catch (const std::exception& ex) {
Log(LogWarning, "ApiClient", "Error while reading JSON-RPC message for identity '" + m_Identity + "': " + DiagnosticInformation(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) Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)

View File

@ -231,6 +231,8 @@ void ApiListener::AddConnection(const Endpoint::Ptr& endpoint)
String host = endpoint->GetHost(); String host = endpoint->GetHost();
String port = endpoint->GetPort(); 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>(); TcpSocket::Ptr client = make_shared<TcpSocket>();
try { try {

View File

@ -24,6 +24,7 @@
#include "base/dynamictype.hpp" #include "base/dynamictype.hpp"
#include "base/utility.hpp" #include "base/utility.hpp"
#include "base/exception.hpp" #include "base/exception.hpp"
#include "base/convert.hpp"
#include <boost/foreach.hpp> #include <boost/foreach.hpp>
using namespace icinga; using namespace icinga;
@ -79,6 +80,8 @@ void Endpoint::RemoveClient(const ApiClient::Ptr& client)
{ {
boost::mutex::scoped_lock lock(m_ClientsLock); boost::mutex::scoped_lock lock(m_ClientsLock);
m_Clients.erase(client); 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(); bool is_master = ApiListener::GetInstance()->IsMaster();