]> granicus.if.org Git - icinga2/commitdiff
compatido: add config options: socket_{address, port}, instance_name
authorMichael Friedrich <michael.friedrich@gmail.com>
Fri, 28 Sep 2012 10:13:50 +0000 (12:13 +0200)
committerMichael Friedrich <michael.friedrich@gmail.com>
Fri, 28 Sep 2012 10:13:50 +0000 (12:13 +0200)
fixes #3158

components/compatido/compatidocomponent.cpp
components/compatido/compatidocomponent.h
icinga-app/config/icinga2.conf.dist

index 0d870054bc2d546d296a23fbcd9d87c5218d6541..7a5358e485e9d20de286624d5c05327e18b6c594 100644 (file)
 
 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<Timer>();
        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());
 }
 
 /**
index 2077a3220baec72680b078dcb350b0608085613c..f12ae3bb88bd1b2685b232fba13b3ee816648bcd 100644 (file)
@@ -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);
index 462c58066557083166682720ec996c7741993f2e..dda39f2a1978ab52e4cbd09908b179c5921de0a1 100644 (file)
@@ -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",
 }
 */