diff --git a/components/compatido/compatidocomponent.cpp b/components/compatido/compatidocomponent.cpp index 0d870054b..7a5358e48 100644 --- a/components/compatido/compatidocomponent.cpp +++ b/components/compatido/compatidocomponent.cpp @@ -21,6 +21,50 @@ 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. */ @@ -34,7 +78,6 @@ void CompatIdoComponent::Start(void) * - only tcp sockets * - only icinga idoutils 1.8 * - only "retained" config - * - instance_name is i2-default */ m_StatusTimer = boost::make_shared(); m_StatusTimer->SetInterval(StatusTimerInterval); @@ -57,8 +100,8 @@ void CompatIdoComponent::Start(void) /* * open ido socket once */ - OpenSink("127.0.0.1", "5668"); - SendHello("i2-default"); + OpenSink(GetSocketAddress(), GetSocketPort()); + SendHello(GetInstanceName()); } /** diff --git a/components/compatido/compatidocomponent.h b/components/compatido/compatidocomponent.h index 2077a3220..f12ae3bb8 100644 --- a/components/compatido/compatidocomponent.h +++ b/components/compatido/compatidocomponent.h @@ -38,6 +38,10 @@ private: Timer::Ptr m_ProgramStatusTimer; IdoSocket::Ptr m_IdoSocket; + String GetSocketAddress(void) const; + String GetSocketPort(void) const; + String GetInstanceName(void) const; + void ConfigTimerHandler(void); void StatusTimerHandler(void); void ProgramStatusTimerHandler(void); diff --git a/icinga-app/config/icinga2.conf.dist b/icinga-app/config/icinga2.conf.dist index 462c58066..dda39f2a1 100644 --- a/icinga-app/config/icinga2.conf.dist +++ b/icinga-app/config/icinga2.conf.dist @@ -47,7 +47,9 @@ local object Component "compat" { */ /* local object Component "compatido" { - + socket_address = "127.0.0.1", + socket_port = "5668", + instance_name = "i2-default", } */