]> granicus.if.org Git - icinga2/commitdiff
Added init script.
authorGunnar Beutner <gunnar.beutner@netways.de>
Mon, 4 Feb 2013 11:43:16 +0000 (12:43 +0100)
committerGunnar Beutner <gunnar.beutner@netways.de>
Mon, 4 Feb 2013 11:52:39 +0000 (12:52 +0100)
Fixes #3114

13 files changed:
Makefile.am
components/compat/compatcomponent.cpp
configure.ac
etc/Makefile.am [new file with mode: 0644]
etc/icinga2/Makefile.am [moved from icinga-app/config/Makefile.am with 100% similarity]
etc/icinga2/icinga2.conf.dist [new file with mode: 0644]
etc/icinga2/icinga2.conf.win32 [moved from icinga-app/config/icinga2.conf.win32 with 100% similarity]
etc/init.d/Makefile.am [new file with mode: 0644]
etc/init.d/icinga2.in [new file with mode: 0644]
icinga-app/Makefile.am
icinga-app/config/icinga2.conf.dist [deleted file]
itl/service-common.conf
lib/config/configcompiler.cpp

index 645c5ac1e208147030bb526c9a504043eb98a5cd..2c23f0c39018c00d7a04a16d4833c520d7fad6fb 100644 (file)
@@ -9,7 +9,8 @@ SUBDIRS = \
        components \
        icinga-app \
        test \
-       itl
+       itl \
+       etc
 #doc
 icinga2docdir = ${docdir}
 icinga2doc_DATA = \
index 662eeaa3d42f4f88e84ba3c77b78eff9ce28bda7..fa4aa1b2cc673cb054e1c749fbf635d161e11405 100644 (file)
@@ -36,7 +36,7 @@ String CompatComponent::GetStatusPath(void) const
 {
        Value statusPath = GetConfig()->Get("status_path");
        if (statusPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/status.dat";
+               return Application::GetLocalStateDir() + "/cache/status.dat";
        else
                return statusPath;
 }
@@ -50,7 +50,7 @@ String CompatComponent::GetObjectsPath(void) const
 {
        Value objectsPath = GetConfig()->Get("objects_path");
        if (objectsPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/objects.cache";
+               return Application::GetLocalStateDir() + "/cache/objects.cache";
        else
                return objectsPath;
 }
@@ -64,7 +64,7 @@ String CompatComponent::GetCommandPath(void) const
 {
        Value commandPath = GetConfig()->Get("command_path");
        if (commandPath.IsEmpty())
-               return Application::GetLocalStateDir() + "/icinga.cmd";
+               return Application::GetLocalStateDir() + "/run/icinga.cmd";
        else
                return commandPath;
 }
index 283a7e905386435f0388f99c33f78817708976ac..c1cc486cbe431c18489567ed3606b00a7b0a689f 100644 (file)
@@ -99,8 +99,10 @@ components/delegation/Makefile
 components/demo/Makefile
 components/replication/Makefile
 docs/Doxyfile
+etc/Makefile
+etc/icinga2/Makefile
+etc/init.d/Makefile
 icinga-app/Makefile
-icinga-app/config/Makefile
 itl/Makefile
 lib/Makefile
 lib/base/Makefile
@@ -113,7 +115,9 @@ third-party/cJSON/Makefile
 third-party/mmatch/Makefile
 third-party/popen-noshell/Makefile
 ])
-AC_OUTPUT
+AC_OUTPUT([
+etc/init.d/icinga2
+])
 
 if ! test -z "$LTDLDEPS"; then
        ltdl_msg="bundled"
diff --git a/etc/Makefile.am b/etc/Makefile.am
new file mode 100644 (file)
index 0000000..534cbbf
--- /dev/null
@@ -0,0 +1,5 @@
+## Process this file with automake to produce Makefile.in
+
+SUBDIRS = \
+       icinga2 \
+       init.d
diff --git a/etc/icinga2/icinga2.conf.dist b/etc/icinga2/icinga2.conf.dist
new file mode 100644 (file)
index 0000000..2cc96cf
--- /dev/null
@@ -0,0 +1,48 @@
+/**
+ * Icinga 2 configuration file
+ * - this is where you define settings for the Icinga application including
+ * which hosts/services to check.
+ *
+ * The docs/icinga2-config.txt file in the source tarball has a detailed
+ * description of what configuration options are available.
+ */
+
+#include <itl/itl.conf>
+#include <itl/standalone.conf>
+
+/**
+ * Global configuration settings
+ */
+local object IcingaApplication "icinga" {
+ macros = {
+    plugindir = "/usr/local/icinga/libexec"
+  }
+}
+
+/**
+ * The compat component periodically updates the status.dat and objects.cache
+ * files. These are used by the Icinga 1.x CGIs to display the state of
+ * hosts and services.
+ */
+local object Component "compat" { }
+
+/**
+ * And finally we define some host that should be checked.
+ */
+object Host "localhost" {
+  services = {
+    "ping4", "ping6",
+    "http_ip", "ssh",
+    "load", "processes",
+    "users", "disk"
+  },
+  
+  macros = {
+    address = "127.0.0.1",
+    address6 = "::1",
+  },
+  
+  hostchecks = { "ping4", "ping6" },
+
+  check_interval = 1m
+}
diff --git a/etc/init.d/Makefile.am b/etc/init.d/Makefile.am
new file mode 100644 (file)
index 0000000..b6e62c2
--- /dev/null
@@ -0,0 +1,8 @@
+## Process this file with automake to produce Makefile.in
+
+initdir = ${sysconfdir}/init.d
+init_SCRIPTS = \
+       icinga2
+
+EXTRA_DIST = \
+       icinga2.in
diff --git a/etc/init.d/icinga2.in b/etc/init.d/icinga2.in
new file mode 100644 (file)
index 0000000..e2f666e
--- /dev/null
@@ -0,0 +1,122 @@
+#!/bin/bash
+#
+# chkconfig: 35 90 12
+# description: Icinga 2
+#
+### BEGIN INIT INFO
+# Provides:          icinga2
+# Required-Start:    $remote_fs $syslog
+# Required-Stop:     $remote_fs $syslog
+# Default-Start:     2 3 4 5
+# Default-Stop:      0 1 6
+# Short-Description: Start Icinga 2 at boot time
+# Description:       Icinga 2
+### END INIT INFO
+
+prefix=@prefix@
+exec_prefix=@exec_prefix@
+sbindir=@sbindir@
+sysconfdir=@sysconfdir@
+localstatedir=@localstatedir@
+
+DAEMON=$sbindir/icinga2
+ICINGA2_CONFIG_FILE=$sysconfdir/icinga2/icinga2.conf
+ICINGA2_PID_FILE=$localstatedir/run/icinga2.pid
+
+test -x $DAEMON || exit 0
+
+if [ ! -e $ICINGA2_CONFIG_FILE ]; then
+        echo "Config file '$ICINGA2_CONFIG_FILE' does not exist."
+        exit 1
+fi
+
+# Get function from functions library
+if [ -e /etc/init.d/functions ]; then
+        . /etc/init.d/functions
+fi
+
+# Start Icinga 2
+start() {
+        printf "Starting Icinga 2: "
+        $DAEMON -c $ICINGA2_CONFIG_FILE -d
+        echo "Done"
+        echo
+}
+
+# Restart Icinga 2
+stop() {
+        printf "Stopping Icinga 2: "
+        if [ ! -e $ICINGA2_PID_FILE ]; then
+                echo "The PID file '$ICINGA2_PID_FILE' does not exist."
+                exit 1
+        fi
+
+       pid=`cat $ICINGA2_PID_FILE`
+       
+        if kill -TERM $pid >/dev/null 2>&1; then
+               for i in 1 2 3 4 5 6 7 8 9 10; do
+                       if ! kill -CHLD $pid >/dev/null 2&>1; then
+                               break
+                       fi
+               
+                       printf '.'
+                       
+                       sleep 1
+               done
+       fi
+       
+       echo "Done"
+}
+
+# Reload Icinga 2
+reload() {
+        printf "Reloading Icinga 2: "
+        if [ ! -e $ICINGA2_PID_FILE ]; then
+                echo "The PID file '$ICINGA2_PID_FILE' does not exist."
+                exit 1
+        fi
+        
+       pid=`cat $ICINGA2_PID_FILE`
+       
+        if ! kill -HUP $pid >/dev/null 2>&1; then
+               echo "Failed - Icinga 2 is not running."
+       else
+               echo "Done"
+       fi
+}
+
+# Print status for Icinga 2
+status() {
+       printf "Icinga 2 status: "
+
+       pid=`cat $ICINGA2_PID_FILE`
+       if kill -CHLD $pid >/dev/null 2&>1; then
+               echo "Running"
+       else
+               echo "Not running"
+       fi
+}
+
+### main logic ###
+case "$1" in
+  start)
+        start
+        ;;
+  stop)
+        stop
+        ;;
+  status)
+        status FOO
+        ;;
+  restart|condrestart)
+        stop
+        start
+        ;;
+  reload)
+        reload
+        ;;
+  *)
+        echo $"Usage: $0 {start|stop|restart|reload|status}"
+        exit 1
+esac
+exit 0
index 087edcc86e192d5cb46c7ca76547ea4f0911660d..bf8370c2e28f09c9678f6355d77bb0e35399671d 100644 (file)
@@ -1,8 +1,5 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = \
-       config
-
 sbin_PROGRAMS = \
        icinga2
 
diff --git a/icinga-app/config/icinga2.conf.dist b/icinga-app/config/icinga2.conf.dist
deleted file mode 100644 (file)
index 62d6a64..0000000
+++ /dev/null
@@ -1,185 +0,0 @@
-/**
- * Icinga 2 configuration file
- * - this is where you define settings for the Icinga application including
- * which hosts/services to check.
- *
- * The docs/icinga2-config.txt file in the source tarball has a detailed
- * description of what configuration options are available.
- */
-
-/**
- * Global configuration settings
- */
-local object IcingaApplication "icinga" {
-  pid_path = "./var/run/icinga2.pid",
-  state_path = "./var/lib/icinga2/icinga2.state",
-
-  macros = {
-    plugindir = "/usr/local/icinga/libexec"
-  }
-}
-
-/**
- * Advanced logging settings
- */
-local object Logger "my-debug-log" {
-  type = "console",
-  severity = "debug"
-}
-
-/**
- * The checker component takes care of executing service checks.
- */
-local object Component "checker" {
-
-}
-
-/**
- * The delegation component assigns services to checkers. You need to load
- * this component even if your Icinga setup only consists of a single instance.
- */
-local object Component "delegation" {
-
-}
-
-/**
- * The compat component periodically updates the status.dat and objects.cache
- * files. These are used by the Icinga 1.x CGIs to display the state of
- * hosts and services.
- */
-local object Component "compat" {
-  status_path = "./var/cache/icinga2/status.dat",
-  objects_path = "./var/cache/icinga2/objects.cache",
-}
-
-/**
- * The compatido component works as idomod connector to a running ido2db
- * daemon, connected via tcp socket only. It will dump config and status
- * information periodically for now. By default, this remains disabled.
- */
-/*
-local object Component "compatido" {
-  socket_address = "127.0.0.1",
-  socket_port = "5668",
-  instance_name = "i2-default",
-  reconnect_interval = 15,
-}
-*/
-
-/**
- * This template defines some basic parameters for services that use
- * external plugins for their checks.
- */
-abstract object Service "icinga-service" {
-  methods = {
-    check = "native::PluginCheck"
-  }
-}
-
-/**
- * The service templates for checks. In an Icinga 1.x environment
- * this would be defined as a check command.
- */
-
-/**
- * ping
- */
-abstract object Service "ping4" inherits "icinga-service" {
-  check_command = "$plugindir$/check_ping -H $address$ -w $wrta$,$wpl$% -c $crta$,$cpl$%",
-  macros += {
-    wrta = 50,
-    wpl = 5,
-    crta = 100,
-    cpl = 10
-  }
-}
-
-abstract object Service "ping6" inherits "icinga-service" {
-  check_command = "$plugindir$/check_ping -6 -H $address6$ -w $wrta$,$wpl$% -c $crta$,$cpl$%",
-  macros += {
-    wrta = 50,
-    wpl = 5,
-    crta = 100,
-    cpl = 10
-  }
-}
-
-/**
- * http
- */
-abstract object Service "http" inherits "icinga-service" {
-  check_command = "$plugindir$/check_http -H '$address$' -I '$address$'",
-}
-
-/**
- * ssh
- */
-abstract object Service "ssh" inherits "icinga-service" {
-  check_command = "$plugindir$/check_ssh '$address$'",
-}
-
-/**
- * local checks
- */
-abstract object Service "disk space" inherits "icinga-service" {
-  check_command = "$plugindir$/check_disk -w '$wfree$' -c '$cfree$'",
-  macros += {
-    wfree = "20%",
-    cfree = "10%",
-  }
-}
-
-abstract object Service "current users" inherits "icinga-service" {
-  check_command = "$plugindir$/check_users -w '$wgreater$' -c '$cgreater$'",
-  macros += {
-    wgreater = 20,
-    cgreater = 50,
-  }
-}
-
-abstract object Service "total processes" inherits "icinga-service" {
-  check_command = "$plugindir$/check_procs -w '$wgreater$' -c '$cgreater$'",
-  macros += {
-    wgreater = 250,
-    cgreater = 400,
-  }
-}
-
-abstract object Service "current load" inherits "icinga-service" {
-  check_command = "$plugindir$/check_load --warning='$wload1$,$wload5$,$wload15$' --critical='$cload1$,$cload5$,$cload15$'",
-  macros += {
-    wload1 = 5.0,
-    wload5 = 4.0,
-    wload15 = 3.0,
-    cload1 = 10.0,
-    cload5 = 6.0,
-    cload15 = 4.0,
-  }
-}
-
-/**
- * demo check
- */
-abstract object Service "demo" inherits "icinga-service" {
-  check_command = "$plugindir$/check_dummy 1 'strawberry. yummy! | i=2'",
-}
-
-
-/**
- * And finally we define some host that should be checked.
- */
-object Host "localhost" {
-  services = {
-    "ping4", "ping6",
-    "http", "ssh",
-    "current load", "total processes",
-    "current users", "disk space",
-    "demo",
-  },
-  macros = {
-    address = "127.0.0.1",
-    address6 = "::1",
-  },
-  check_interval = 1m
-}
-
index 6a7ff15446ca70a850a1c494fb655a5e032e381d..9f82f8b036f59f66c36921e40d7600bfab5c5bc8 100644 (file)
  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA.             *
  ******************************************************************************/
  
-abstract object Service "ping" inherits "plugin-service" {
-       check_command = "$plugindir$/check_ping -H $address$ -w $wrta$,$wpl$% -c $crta$,$cpl$%a -p $packets$ -t $timeout$",
+abstract object Service "ping4" inherits "plugin-service" {
+       check_command = "$plugindir$/check_ping -4 -H $address$ -w $wrta$,$wpl$% -c $crta$,$cpl$%a -p $packets$ -t $timeout$",
 
        macros = {
                wrta = 100,
                wpl = 5,
-                
+                               
                crta = 200,
                cpl = 15,
-                
+                               
+               packets = 5,
+               timeout = 0
+       }
+}
+
+abstract object Service "ping6" inherits "plugin-service" {
+       check_command = "$plugindir$/check_ping -6 -H $address6$ -w $wrta$,$wpl$% -c $crta$,$cpl$%a -p $packets$ -t $timeout$",
+
+       macros = {
+               wrta = 100,
+               wpl = 5,
+                               
+               crta = 200,
+               cpl = 15,
+                               
                packets = 5,
                timeout = 0
        }
 }
 
 abstract object Service "dummy" inherits "plugin-service" {
-    check_command = "$plugindir$/check_dummy $state$ '$text$'",
-    
-    macros = {
-        state = 0,
-        text = "Check was successful."
-    }
+       check_command = "$plugindir$/check_dummy $state$ '$text$'",
+       
+       macros = {
+               state = 0,
+               text = "Check was successful."
+       }
+}
+
+abstract object Service "http_vhost" inherits "plugin-service" {
+       check_command = "$plugindir$/check_http -H $vhost$"
 }
 
-abstract object Service "check_http_vhost" inherits "plugin-service" {
-    check_command = "$plugindir$/check_http -H $vhost$"
+abstract object Service "http_ip" inherits "plugin-service" {
+       check_command = "$plugindir$/check_http -I $address$"
 }
 
-abstract object Service "check_http_ip" inherits "plugin-service" {
-    check_command = "$plugindir$/check_http -I $address$"
+abstract object Service "ssh" inherits "plugin-service" {
+       check_command = "$plugindir$/check_ssh $address$"
 }
 
+abstract object Service "disk" inherits "plugin-service" {
+       check_command = "$plugindir$/check_disk -w '$wfree$' -c '$cfree$'",
+
+       macros += {
+               wfree = "20%",
+               cfree = "10%",
+       }
+}
+
+abstract object Service "users" inherits "plugin-service" {
+       check_command = "$plugindir$/check_users -w '$wgreater$' -c '$cgreater$'",
+
+       macros += {
+       wgreater = 20,
+       cgreater = 50,
+  }
+}
+
+abstract object Service "processes" inherits "plugin-service" {
+       check_command = "$plugindir$/check_procs -w '$wgreater$' -c '$cgreater$'",
+       
+       macros += {
+               wgreater = 250,
+               cgreater = 400,
+       }
+}
+
+
 abstract object Service "load" inherits "plugin-service" {
-    check_command = "$plugindir$/check_load -w $wload1$,$wload5$,$wload15$ -c $cload1$,$cload5$,$cload15$",
-    
-    macros = {
-        wload1 = 0,
-        wload5 = 0,
-        wload15 = 0,
-        
-        cload1 = 0,
-        cload5 = 0,
-        crload5 = 0
-    }
+       check_command = "$plugindir$/check_load -w $wload1$,$wload5$,$wload15$ -c $cload1$,$cload5$,$cload15$",
+
+       macros = {
+               wload1 = 5.0,
+               wload5 = 4.0,
+               wload15 = 3.0,
+               
+               cload1 = 10.0,
+               cload5 = 6.0,
+               cload15 = 4.0
+       }
 }
index fd9c072989898e30f5e60f8d2fd39e7a4550c2d0..adb0ef08fcde02b59b654d0e0599fc74bf17b660 100644 (file)
@@ -118,7 +118,12 @@ String ConfigCompiler::GetPath(void) const
  */
 void ConfigCompiler::HandleInclude(const String& include, bool search, const DebugInfo& debuginfo)
 {
-       String path = Utility::DirName(GetPath()) + "/" + include;
+       String path;
+
+       if (search)
+               path = include;
+       else
+               path = Utility::DirName(GetPath()) + "/" + include;
 
        vector<ConfigType::Ptr> types;
        m_HandleInclude(path, search, &m_ResultObjects, &types, debuginfo);