mirror of https://github.com/Icinga/icinga2.git
compatido: add config options: socket_{address, port}, instance_name
fixes #3158
This commit is contained in:
parent
eaf74cad8f
commit
550a7959d7
|
@ -21,6 +21,50 @@
|
||||||
|
|
||||||
using namespace icinga;
|
using namespace icinga;
|
||||||
|
|
||||||
|
const String DefaultSocketAddress = "127.0.0.1";
|
||||||
|
const String DefaultSocketPort = "5668";
|
||||||
|
const String DefaultInstanceName = "i2-default";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the socket address from the config
|
||||||
|
* @returns address The config option, or static default
|
||||||
|
*/
|
||||||
|
String CompatIdoComponent::GetSocketAddress(void) const
|
||||||
|
{
|
||||||
|
Value address = GetConfig()->Get("socket_address");
|
||||||
|
if(address.IsEmpty())
|
||||||
|
return DefaultSocketAddress;
|
||||||
|
else
|
||||||
|
return address;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the socket port from the config
|
||||||
|
* @returns port The config option, or static default
|
||||||
|
*/
|
||||||
|
String CompatIdoComponent::GetSocketPort(void) const
|
||||||
|
{
|
||||||
|
Value port = GetConfig()->Get("socket_port");
|
||||||
|
if(port.IsEmpty())
|
||||||
|
return DefaultSocketPort;
|
||||||
|
else
|
||||||
|
return port;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads the instance name from the config
|
||||||
|
* @returns instance The config option, or static default
|
||||||
|
*/
|
||||||
|
String CompatIdoComponent::GetInstanceName(void) const
|
||||||
|
{
|
||||||
|
Value instance = GetConfig()->Get("instance_name");
|
||||||
|
if(instance.IsEmpty())
|
||||||
|
return DefaultInstanceName;
|
||||||
|
else
|
||||||
|
return instance;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Starts the component.
|
* Starts the component.
|
||||||
*/
|
*/
|
||||||
|
@ -34,7 +78,6 @@ void CompatIdoComponent::Start(void)
|
||||||
* - only tcp sockets
|
* - only tcp sockets
|
||||||
* - only icinga idoutils 1.8
|
* - only icinga idoutils 1.8
|
||||||
* - only "retained" config
|
* - only "retained" config
|
||||||
* - instance_name is i2-default
|
|
||||||
*/
|
*/
|
||||||
m_StatusTimer = boost::make_shared<Timer>();
|
m_StatusTimer = boost::make_shared<Timer>();
|
||||||
m_StatusTimer->SetInterval(StatusTimerInterval);
|
m_StatusTimer->SetInterval(StatusTimerInterval);
|
||||||
|
@ -57,8 +100,8 @@ void CompatIdoComponent::Start(void)
|
||||||
/*
|
/*
|
||||||
* open ido socket once
|
* open ido socket once
|
||||||
*/
|
*/
|
||||||
OpenSink("127.0.0.1", "5668");
|
OpenSink(GetSocketAddress(), GetSocketPort());
|
||||||
SendHello("i2-default");
|
SendHello(GetInstanceName());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -38,6 +38,10 @@ private:
|
||||||
Timer::Ptr m_ProgramStatusTimer;
|
Timer::Ptr m_ProgramStatusTimer;
|
||||||
IdoSocket::Ptr m_IdoSocket;
|
IdoSocket::Ptr m_IdoSocket;
|
||||||
|
|
||||||
|
String GetSocketAddress(void) const;
|
||||||
|
String GetSocketPort(void) const;
|
||||||
|
String GetInstanceName(void) const;
|
||||||
|
|
||||||
void ConfigTimerHandler(void);
|
void ConfigTimerHandler(void);
|
||||||
void StatusTimerHandler(void);
|
void StatusTimerHandler(void);
|
||||||
void ProgramStatusTimerHandler(void);
|
void ProgramStatusTimerHandler(void);
|
||||||
|
|
|
@ -47,7 +47,9 @@ local object Component "compat" {
|
||||||
*/
|
*/
|
||||||
/*
|
/*
|
||||||
local object Component "compatido" {
|
local object Component "compatido" {
|
||||||
|
socket_address = "127.0.0.1",
|
||||||
|
socket_port = "5668",
|
||||||
|
instance_name = "i2-default",
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue