mirror of https://github.com/Icinga/icinga2.git
parent
4775bd8498
commit
ca51fe8c56
|
@ -1602,7 +1602,6 @@ Attributes:
|
|||
----------------|----------------
|
||||
host |**Required.** The hostname/IP address of the remote Icinga 2 instance.
|
||||
port |**Optional.** The service name/port of the remote Icinga 2 instance. Defaults to `5665`.
|
||||
keep_alive |**Optional.** Keep-alive duration for connections. Defaults to `5m`.
|
||||
log_duration |**Optional.** Duration for keeping replay logs on connection loss. Defaults to `1d`.
|
||||
|
||||
|
||||
|
|
|
@ -26,14 +26,9 @@
|
|||
#include "base/utility.hpp"
|
||||
#include "base/logger_fwd.hpp"
|
||||
#include "base/exception.hpp"
|
||||
#include "base/initialize.hpp"
|
||||
|
||||
using namespace icinga;
|
||||
|
||||
Timer::Ptr ApiClient::m_KeepAliveTimer;
|
||||
|
||||
INITIALIZE_ONCE(&ApiClient::StaticInitialize);
|
||||
|
||||
static Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params);
|
||||
REGISTER_APIFUNCTION(SetLogPosition, log, &SetLogPositionHandler);
|
||||
|
||||
|
@ -43,14 +38,6 @@ ApiClient::ApiClient(const String& identity, const Stream::Ptr& stream, Connecti
|
|||
m_Endpoint = Endpoint::GetByName(identity);
|
||||
}
|
||||
|
||||
void ApiClient::StaticInitialize(void)
|
||||
{
|
||||
m_KeepAliveTimer = make_shared<Timer>();
|
||||
m_KeepAliveTimer->OnTimerExpired.connect(boost::bind(&ApiClient::KeepAliveTimerHandler));
|
||||
m_KeepAliveTimer->SetInterval(5);
|
||||
m_KeepAliveTimer->Start();
|
||||
}
|
||||
|
||||
void ApiClient::Start(void)
|
||||
{
|
||||
boost::thread thread(boost::bind(&ApiClient::MessageThreadProc, static_cast<ApiClient::Ptr>(GetSelf())));
|
||||
|
@ -178,43 +165,6 @@ void ApiClient::MessageThreadProc(void)
|
|||
}
|
||||
}
|
||||
|
||||
void ApiClient::KeepAliveTimerHandler(void)
|
||||
{
|
||||
double now = Utility::GetTime();
|
||||
|
||||
BOOST_FOREACH(const Endpoint::Ptr& endpoint, DynamicType::GetObjects<Endpoint>()) {
|
||||
if (endpoint->GetZone() == Zone::GetLocalZone())
|
||||
continue;
|
||||
|
||||
if (endpoint->GetSyncing() || endpoint->GetKeepAlive() <= 0)
|
||||
continue;
|
||||
|
||||
double timeout = now - endpoint->GetKeepAlive();
|
||||
|
||||
BOOST_FOREACH(const ApiClient::Ptr& client, endpoint->GetClients()) {
|
||||
if (client->m_Seen < timeout) {
|
||||
Log(LogNotice, "remote", "Closing connection with inactive endpoint '" + endpoint->GetName() + "'");
|
||||
client->Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
ApiListener::Ptr listener = ApiListener::GetInstance();
|
||||
|
||||
if (listener) {
|
||||
double timeout = now - 60;
|
||||
|
||||
BOOST_FOREACH(const ApiClient::Ptr& client, listener->GetAnonymousClients()) {
|
||||
if (client->m_Seen < timeout) {
|
||||
Log(LogNotice, "remote", "Closing connection with inactive anonymous endpoint '" + client->GetIdentity() + "'");
|
||||
client->Disconnect();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Value SetLogPositionHandler(const MessageOrigin& origin, const Dictionary::Ptr& params)
|
||||
{
|
||||
if (!params)
|
||||
|
|
|
@ -46,8 +46,6 @@ public:
|
|||
|
||||
ApiClient(const String& identity, const Stream::Ptr& stream, ConnectionRole role);
|
||||
|
||||
static void StaticInitialize(void);
|
||||
|
||||
void Start(void);
|
||||
|
||||
String GetIdentity(void) const;
|
||||
|
@ -68,9 +66,6 @@ private:
|
|||
|
||||
bool ProcessMessage(void);
|
||||
void MessageThreadProc(void);
|
||||
|
||||
static Timer::Ptr m_KeepAliveTimer;
|
||||
static void KeepAliveTimerHandler(void);
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -9,9 +9,6 @@ class Endpoint : DynamicObject
|
|||
[config] String port {
|
||||
default {{{ return "5665"; }}}
|
||||
};
|
||||
[config] double keep_alive {
|
||||
default {{{ return 300; }}}
|
||||
};
|
||||
[config] double log_duration {
|
||||
default {{{ return 86400; }}}
|
||||
};
|
||||
|
|
|
@ -39,7 +39,6 @@
|
|||
%attribute %string "host",
|
||||
%attribute %string "port",
|
||||
|
||||
%attribute %number "keep_alive",
|
||||
%attribute %number "log_duration"
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue