From 74708766d171f74e5600faca5090eac19ec95480 Mon Sep 17 00:00:00 2001 From: Gunnar Beutner Date: Fri, 27 Sep 2013 10:44:24 +0200 Subject: [PATCH] Implement mods-available/mods-enabled. Refs #4573 --- configure.ac | 3 + doc/2.0-getting-started.md | 7 + ...tarted.md => 2.1.1-setting-up-icinga-2.md} | 131 +----------------- doc/2.1.2-setting-up-icinga-classic-ui.md | 71 ++++++++++ doc/2.1.3-setting-up-check-plugins.md | 22 +++ doc/2.1.4-configuring-ido.md | 3 + doc/2.2-running-icinga.md | 3 + doc/2.3-monitoring-basics.md | 38 +++++ doc/3.1-configuration-syntax.md | 2 +- doc/4-advanced-topics.md | 13 ++ etc/icinga2/Makefile.am | 29 +++- etc/icinga2/conf.d/Makefile.am | 16 +++ etc/icinga2/conf.d/localhost.conf | 43 ++++++ etc/icinga2/conf.d/macros.conf | 7 + etc/icinga2/icinga2.conf | 27 ++++ etc/icinga2/icinga2.conf.dist | 72 ---------- etc/icinga2/mods-available/Makefile.am | 17 +++ etc/icinga2/mods-available/compat.conf | 12 ++ etc/icinga2/mods-available/compat.load | 2 + lib/config/config_lexer.cc | 8 +- tools/Makefile.am | 10 +- 21 files changed, 326 insertions(+), 210 deletions(-) create mode 100644 doc/2.0-getting-started.md rename doc/{2-getting-started.md => 2.1.1-setting-up-icinga-2.md} (57%) create mode 100644 doc/2.1.2-setting-up-icinga-classic-ui.md create mode 100644 doc/2.1.3-setting-up-check-plugins.md create mode 100644 doc/2.1.4-configuring-ido.md create mode 100644 doc/2.2-running-icinga.md create mode 100644 doc/2.3-monitoring-basics.md create mode 100644 doc/4-advanced-topics.md create mode 100644 etc/icinga2/conf.d/Makefile.am create mode 100644 etc/icinga2/conf.d/localhost.conf create mode 100644 etc/icinga2/conf.d/macros.conf create mode 100644 etc/icinga2/icinga2.conf delete mode 100644 etc/icinga2/icinga2.conf.dist create mode 100644 etc/icinga2/mods-available/Makefile.am create mode 100644 etc/icinga2/mods-available/compat.conf create mode 100644 etc/icinga2/mods-available/compat.load diff --git a/configure.ac b/configure.ac index 68871ced1..39d53aa1e 100644 --- a/configure.ac +++ b/configure.ac @@ -138,6 +138,8 @@ docs/Doxyfile docs/Makefile etc/Makefile etc/icinga2/Makefile +etc/icinga2/conf.d/Makefile +etc/icinga2/mods-available/Makefile etc/init.d/Makefile icinga-app/Makefile itl/Makefile @@ -153,6 +155,7 @@ third-party/cJSON/Makefile third-party/execvpe/Makefile third-party/mmatch/Makefile tools/Makefile +tools/i2modconf tools/mkembedconfig/Makefile ]) AC_OUTPUT([ diff --git a/doc/2.0-getting-started.md b/doc/2.0-getting-started.md new file mode 100644 index 000000000..a705768b2 --- /dev/null +++ b/doc/2.0-getting-started.md @@ -0,0 +1,7 @@ +# Getting Started + +## Installation + +This tutorial is a step-by-step introduction to installing Icinga 2 and +the standalone version of the Icinga 1.x classic web interface. It assumes +that you are familiar with the system you're installing Icinga 2 on. diff --git a/doc/2-getting-started.md b/doc/2.1.1-setting-up-icinga-2.md similarity index 57% rename from doc/2-getting-started.md rename to doc/2.1.1-setting-up-icinga-2.md index 15b5f8730..b100cefc2 100644 --- a/doc/2-getting-started.md +++ b/doc/2.1.1-setting-up-icinga-2.md @@ -1,11 +1,3 @@ -# Getting Started - -## Installation - -This tutorial is a step-by-step introduction to installing Icinga 2 and -the standalone version of the Icinga 1.x classic web interface. It assumes -that you are familiar with the system you're installing Icinga 2 on. - ### Setting up Icinga 2 In order to get started with Icinga 2 you will have to install it. The @@ -24,8 +16,9 @@ available. Please check http://packages.icinga.org/ to see if packages are available for your favorite distribution. In case you're running a distribution for which Icinga 2 packages are -not yet available you will have to check out the Icinga 2 Git repository -from git://git.icinga.org/icinga2 and read the *INSTALL* file. +not yet available you will have to use the release tarball which you +can download from the [Icinga website](https://www.icinga.org/). The +release tarballs contain an *INSTALL* file with further information. #### Installation Paths @@ -153,121 +146,3 @@ we enabled earlier by including the itl/itl.conf configuration file. The *macros* attribute can be used to define macros that are available for all services which belong to this host. Most of the templates in the Icinga Template Library require an *address* macro. - -### Setting up Icinga Classic UI - -Icinga 2 can write *status.dat* and *objects.cache* files in the format that -is supported by the Icinga 1.x Classic UI. External commands (a.k.a. the -"command pipe") are also supported. It also supports writing Icinga 1.x -log files which are required for the reporting functionality in the Classic UI. - -These features are implemented as part of the *compat* library and are enabled -by default in the example configuration file. - -You should be able to find the *status.dat* and *objects.cache* files in -*/var/cache/icinga2*. The log files can be found in */var/log/icinga2/compat*. -The command pipe can be found in */var/run/icinga2*. - -#### Installing Icinga Classic UI - -You can install Icinga 1.x Classic UI in standalone mode using the -following commands: - - $ wget http://downloads.sourceforge.net/project/icinga/icinga/1.9.3/icinga-1.9.3.tar.gz - $ tar xzf icinga-1.9.3.tar.gz ; cd icinga-1.9.3 - $ ./configure --enable-classicui-standalone --prefix=/usr/local/icinga2-classicui - $ make classicui-standalone - $ sudo make install classicui-standalone install-webconf-auth - $ sudo service apache2 restart - -> **Note** -> -> A detailed guide on installing Icinga 1.x Classic UI Standalone can be -> found on the Icinga Wiki here: -> [https://wiki.icinga.org/display/howtos/Setting+up+Icinga+Classic+UI+Standalone](https://wiki.icinga.org/display/howtos/Setting+up+Icinga+Classic+UI+Standalone) - -#### Configuring the Classic UI - -After installing the Classic UI you will need to update the following -settings in your *cgi.cfg* configuration file in the *STANDALONE (ICINGA 2) -OPTIONS* section: - - Configuration Setting |Value - ------------------------------------|------------------------------------ - object\_cache\_file |/var/cache/icinga2/objects.cache - status\_file |/var/cache/icinga2/status.dat - resource\_file |- - command\_file |/var/run/icinga2/icinga2.cmd - check\_external\_commands |1 - interval\_length |60 - status\_update\_interval |10 - log\_file |/var/log/icinga2/compat/icinga.log - log\_rotation\_method |h - log\_archive\_path |/var/log/icinga2/compat/archives - date\_format |us - ------------------------------------ ------------------------------------ - -> **Note** -> -> Depending on how you installed Icinga 2 some of those paths and options -> might be different. - -In order for commands to work you will need to grant the web server -write permissions for the command pipe: - - # chgrp www-data /var/run/icinga2/icinga2.cmd - # chmod 660 /var/run/icinga2/icinga2.cmd - -> **Note** -> -> Change "www-data" to the group the Apache HTTP daemon is running as. - -Verify that your Icinga 1.x Classic UI works by browsing to your Classic -UI installation URL, e.g. -[http://localhost/icinga](http://localhost/icinga) - -### Configuring IDO - -TODO - -## Running Icinga - -TODO - -## Monitoring Basics - -### Hosts - -TODO - -### Services - -TODO - -### Check Commands - -TODO - -### Macros - -TODO - -## Using Templates - -TODO - -## Groups - -TODO - -## Host/Service Dependencies - -TODO - -## Time Periods - -TODO - -## Notifications - -TODO diff --git a/doc/2.1.2-setting-up-icinga-classic-ui.md b/doc/2.1.2-setting-up-icinga-classic-ui.md new file mode 100644 index 000000000..2e8cd7065 --- /dev/null +++ b/doc/2.1.2-setting-up-icinga-classic-ui.md @@ -0,0 +1,71 @@ +### Setting up Icinga Classic UI + +Icinga 2 can write *status.dat* and *objects.cache* files in the format that +is supported by the Icinga 1.x Classic UI. External commands (a.k.a. the +"command pipe") are also supported. It also supports writing Icinga 1.x +log files which are required for the reporting functionality in the Classic UI. + +These features are implemented as part of the *compat* library and are enabled +by default in the example configuration file. + +You should be able to find the *status.dat* and *objects.cache* files in +*/var/cache/icinga2*. The log files can be found in */var/log/icinga2/compat*. +The command pipe can be found in */var/run/icinga2*. + +#### Installing Icinga Classic UI + +You can install Icinga 1.x Classic UI in standalone mode using the +following commands: + + $ wget http://downloads.sourceforge.net/project/icinga/icinga/1.9.3/icinga-1.9.3.tar.gz + $ tar xzf icinga-1.9.3.tar.gz ; cd icinga-1.9.3 + $ ./configure --enable-classicui-standalone --prefix=/usr/local/icinga2-classicui + $ make classicui-standalone + $ sudo make install classicui-standalone install-webconf-auth + $ sudo service apache2 restart + +> **Note** +> +> A detailed guide on installing Icinga 1.x Classic UI Standalone can be +> found on the Icinga Wiki here: +> [https://wiki.icinga.org/display/howtos/Setting+up+Icinga+Classic+UI+Standalone](https://wiki.icinga.org/display/howtos/Setting+up+Icinga+Classic+UI+Standalone) + +#### Configuring the Classic UI + +After installing the Classic UI you will need to update the following +settings in your *cgi.cfg* configuration file in the *STANDALONE (ICINGA 2) +OPTIONS* section: + + Configuration Setting |Value + ------------------------------------|------------------------------------ + object\_cache\_file |/var/cache/icinga2/objects.cache + status\_file |/var/cache/icinga2/status.dat + resource\_file |- + command\_file |/var/run/icinga2/icinga2.cmd + check\_external\_commands |1 + interval\_length |60 + status\_update\_interval |10 + log\_file |/var/log/icinga2/compat/icinga.log + log\_rotation\_method |h + log\_archive\_path |/var/log/icinga2/compat/archives + date\_format |us + ------------------------------------ ------------------------------------ + +> **Note** +> +> Depending on how you installed Icinga 2 some of those paths and options +> might be different. + +In order for commands to work you will need to grant the web server +write permissions for the command pipe: + + # chgrp www-data /var/run/icinga2/icinga2.cmd + # chmod 660 /var/run/icinga2/icinga2.cmd + +> **Note** +> +> Change "www-data" to the group the Apache HTTP daemon is running as. + +Verify that your Icinga 1.x Classic UI works by browsing to your Classic +UI installation URL, e.g. +[http://localhost/icinga](http://localhost/icinga) diff --git a/doc/2.1.3-setting-up-check-plugins.md b/doc/2.1.3-setting-up-check-plugins.md new file mode 100644 index 000000000..3736c232b --- /dev/null +++ b/doc/2.1.3-setting-up-check-plugins.md @@ -0,0 +1,22 @@ +### Setting up Check Plugins + +On its own Icinga 2 does not know how to check external services. The +[Nagios Plugins Project](https://www.nagios-plugins.org/) provides an extensive +set of *plugins* which can be used by Icinga 2 to check whether services are +working properly. + +The recommended way of installing these standard plugins is to use your +distribution's package manager. For your convenience here is a list of package +names for some of the more popular operating systems/distributions: + +OS/Distribution | Package Name | Installation Path +----------------|----------------|--------------------------- +RHEL/CentOS | nagios-plugins | /usr/lib/nagios/plugins +Debian | nagios-plugins | /usr/lib/nagios/plugins +FreeBSD | nagios-plugins | /usr/local/libexec/nagios +OS X (MacPorts) | nagios-plugins | /opt/local/libexec + +Depending on which directory your plugins are installed into you may need to +update the *plugindir* macro in your Icinga 2 configuration. This macro is used +by the service templates contained in the Icinga Template Library to determine +where to find the plugin binaries. \ No newline at end of file diff --git a/doc/2.1.4-configuring-ido.md b/doc/2.1.4-configuring-ido.md new file mode 100644 index 000000000..678bf3763 --- /dev/null +++ b/doc/2.1.4-configuring-ido.md @@ -0,0 +1,3 @@ +### Configuring IDO + +TODO diff --git a/doc/2.2-running-icinga.md b/doc/2.2-running-icinga.md new file mode 100644 index 000000000..988c0e854 --- /dev/null +++ b/doc/2.2-running-icinga.md @@ -0,0 +1,3 @@ +## Running Icinga + +TODO diff --git a/doc/2.3-monitoring-basics.md b/doc/2.3-monitoring-basics.md new file mode 100644 index 000000000..be56ae06f --- /dev/null +++ b/doc/2.3-monitoring-basics.md @@ -0,0 +1,38 @@ +## Monitoring Basics + +### Hosts + +TODO + +### Services + +TODO + +### Check Commands + +TODO + +### Macros + +TODO + +## Using Templates + +TODO + +## Groups + +TODO + +## Host/Service Dependencies + +TODO + +## Time Periods + +TODO + +## Notifications + +TODO + diff --git a/doc/3.1-configuration-syntax.md b/doc/3.1-configuration-syntax.md index 01fa7ac78..1bd229cd3 100644 --- a/doc/3.1-configuration-syntax.md +++ b/doc/3.1-configuration-syntax.md @@ -306,7 +306,7 @@ Global variables may be used in constant expressions. > Constant expressions are evaluated as soon as they're encountered in > the configuration file. -### Comments +### Comments The Icinga 2 configuration format supports C/C++-style comments. diff --git a/doc/4-advanced-topics.md b/doc/4-advanced-topics.md new file mode 100644 index 000000000..e8ad2bf27 --- /dev/null +++ b/doc/4-advanced-topics.md @@ -0,0 +1,13 @@ +# Advanced Topics + +## External Commands + +TODO + +## Event Handlers + +TODO + +## Cluster + +TODO diff --git a/etc/icinga2/Makefile.am b/etc/icinga2/Makefile.am index 452e13451..300707076 100644 --- a/etc/icinga2/Makefile.am +++ b/etc/icinga2/Makefile.am @@ -1,5 +1,26 @@ -icinga2confdir = $(sysconfdir)/icinga2 -icinga2conf_DATA = \ - icinga2.conf.dist +## Process this file with automake to produce Makefile.in -EXTRA_DIST = $(icinga2conf_DATA) +SUBDIRS = \ + conf.d \ + mods-available + +icinga2confdir = $(sysconfdir)/icinga2 + +CONFIG_FILES = \ + icinga2.conf + +install-data-local: + @for file in $(CONFIG_FILES); do \ + if [ ! -e $(icinga2confdir)/$$file ]; then \ + $(INSTALL_DATA) $$file $(icinga2confdir)/$$file; \ + fi; \ + done + +EXTRA_DIST = $(CONFIG_FILES) + +install-exec-hook: + @cd $(icinga2confdir) && \ + if [ ! -e mods-enabled ]; then \ + $(MKDIR_P) mods-enabled && \ + $(LN_S) ../mods-available/compat.conf mods-enabled/; \ + fi diff --git a/etc/icinga2/conf.d/Makefile.am b/etc/icinga2/conf.d/Makefile.am new file mode 100644 index 000000000..46a37b0b2 --- /dev/null +++ b/etc/icinga2/conf.d/Makefile.am @@ -0,0 +1,16 @@ +## Process this file with automake to produce Makefile.in + +icinga2confdir = $(sysconfdir)/icinga2/conf.d + +CONFIG_FILES = \ + localhost.conf \ + macros.conf + +install-data-local: + @for file in $(CONFIG_FILES); do \ + if [ ! -e $(icinga2confdir)/$$file ]; then \ + $(INSTALL_DATA) $$file $(icinga2confdir)/$$file; \ + fi; \ + done + +EXTRA_DIST = $(CONFIG_FILES) diff --git a/etc/icinga2/conf.d/localhost.conf b/etc/icinga2/conf.d/localhost.conf new file mode 100644 index 000000000..191bffa09 --- /dev/null +++ b/etc/icinga2/conf.d/localhost.conf @@ -0,0 +1,43 @@ +/** + * And finally we define some host that should be checked. + */ +object Host "localhost" { + services["ping4"] = { + templates = [ "ping4" ] + }, + + services["ping6"] = { + templates = [ "ping6" ] + }, + + services["http"] = { + templates = [ "http_ip" ] + }, + + services["ssh"] = { + templates = [ "ssh" ] + }, + + services["load"] = { + templates = [ "load" ] + }, + + services["processes"] = { + templates = [ "processes" ] + }, + + services["users"] = { + templates = [ "users" ] + }, + + services["disk"] = { + templates = [ "disk" ] + }, + + macros = { + address = "127.0.0.1", + address6 = "::1", + }, + + check = "ping4", +} diff --git a/etc/icinga2/conf.d/macros.conf b/etc/icinga2/conf.d/macros.conf new file mode 100644 index 000000000..fc270e231 --- /dev/null +++ b/etc/icinga2/conf.d/macros.conf @@ -0,0 +1,7 @@ +/** + * Global macros + */ +set IcingaMacros = { + plugindir = "/usr/lib/nagios/plugins" +} + diff --git a/etc/icinga2/icinga2.conf b/etc/icinga2/icinga2.conf new file mode 100644 index 000000000..2be576a69 --- /dev/null +++ b/etc/icinga2/icinga2.conf @@ -0,0 +1,27 @@ +/** + * Icinga 2 configuration file + * - this is where you define settings for the Icinga application including + * which hosts/services to check. + * + * For an overview of all available configuration options please refer + * to the documentation that is distributed as part of Icinga 2. + */ + +include +include + +/** + * The mods-available directory contains a number of configuration + * files for features which can be enabled and disabled using the + * i2enmod / i2dismod tools. These two tools work by creating + * and removing symbolic links in the mods-enabled directory. + */ +include "mods-enabled/*.conf" + +/** + * Although in theory you could define all your objects in this file + * the preferred way is to create separate files in the conf.d + * directory. + */ +include "conf.d/*.conf" + diff --git a/etc/icinga2/icinga2.conf.dist b/etc/icinga2/icinga2.conf.dist deleted file mode 100644 index d0a52ebd2..000000000 --- a/etc/icinga2/icinga2.conf.dist +++ /dev/null @@ -1,72 +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.adoc file in the source tarball has a detailed - * description of what configuration options are available. - */ - -include -include - -/** - * Global macros - */ -set IcingaMacros = { - plugindir = "/usr/local/icinga/libexec" -} - -/** - * The compat library 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. CompatLog writeis the Icinga 1.x icinga.log and archives. - */ -library "compat" -object StatusDataWriter "status" { } -object ExternalCommandListener "command" { } -object CompatLogger "compat-log" { } - -/** - * And finally we define some host that should be checked. - */ -object Host "localhost" { - services["ping4"] = { - templates = [ "ping4" ] - }, - - services["ping6"] = { - templates = [ "ping6" ] - }, - - services["http"] = { - templates = [ "http_ip" ] - }, - - services["ssh"] = { - templates = [ "ssh" ] - }, - - services["load"] = { - templates = [ "load" ] - }, - - services["processes"] = { - templates = [ "processes" ] - }, - - services["users"] = { - templates = [ "users" ] - }, - - services["disk"] = { - templates = [ "disk" ] - }, - - macros = { - address = "127.0.0.1", - address6 = "::1", - }, - - check = "ping4", -} diff --git a/etc/icinga2/mods-available/Makefile.am b/etc/icinga2/mods-available/Makefile.am new file mode 100644 index 000000000..7051316dd --- /dev/null +++ b/etc/icinga2/mods-available/Makefile.am @@ -0,0 +1,17 @@ +## Process this file with automake to produce Makefile.in + +icinga2confdir = $(sysconfdir)/icinga2/mods-available +icinga2conf_DATA = \ + compat.load + +CONFIG_FILES = \ + compat.conf + +install-data-local: + @for file in $(CONFIG_FILES); do \ + if [ ! -e $(icinga2confdir)/$$file ]; then \ + $(INSTALL_DATA) $$file $(icinga2confdir)/$$file; \ + fi; \ + done + +EXTRA_DIST = $(CONFIG_FILES) $(icinga2conf_DATA) diff --git a/etc/icinga2/mods-available/compat.conf b/etc/icinga2/mods-available/compat.conf new file mode 100644 index 000000000..2c636f33f --- /dev/null +++ b/etc/icinga2/mods-available/compat.conf @@ -0,0 +1,12 @@ +/** + * The compat library 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. CompatLog writeis the Icinga 1.x icinga.log and archives. + */ + +include "compat.load" + +object StatusDataWriter "status" { } +object ExternalCommandListener "command" { } +object CompatLogger "compat-log" { } + diff --git a/etc/icinga2/mods-available/compat.load b/etc/icinga2/mods-available/compat.load new file mode 100644 index 000000000..f99df2fea --- /dev/null +++ b/etc/icinga2/mods-available/compat.load @@ -0,0 +1,2 @@ +library "compat" + diff --git a/lib/config/config_lexer.cc b/lib/config/config_lexer.cc index db6346726..a765a78e4 100644 --- a/lib/config/config_lexer.cc +++ b/lib/config/config_lexer.cc @@ -1,5 +1,5 @@ -#line 3 "config_lexer.cc" +#line 3 "../../../lib/config/config_lexer.cc" #define YY_INT_ALIGNED short int @@ -676,7 +676,7 @@ static char *lb_steal(lex_buf *lb) -#line 680 "config_lexer.cc" +#line 680 "../../../lib/config/config_lexer.cc" #define INITIAL 0 #define C_COMMENT 1 @@ -933,7 +933,7 @@ YY_DECL lex_buf string_buf; -#line 937 "config_lexer.cc" +#line 937 "../../../lib/config/config_lexer.cc" yylval = yylval_param; @@ -1382,7 +1382,7 @@ YY_RULE_SETUP #line 230 "config_lexer.ll" ECHO; YY_BREAK -#line 1386 "config_lexer.cc" +#line 1386 "../../../lib/config/config_lexer.cc" case YY_STATE_EOF(INITIAL): case YY_STATE_EOF(C_COMMENT): case YY_STATE_EOF(STRING): diff --git a/tools/Makefile.am b/tools/Makefile.am index 9f4d8e980..5d21b1d6e 100644 --- a/tools/Makefile.am +++ b/tools/Makefile.am @@ -1,3 +1,11 @@ - SUBDIRS = \ mkembedconfig + +bin_SCRIPTS = i2modconf +CLEANFILES = $(bin_SCRIPTS) + +EXTRA_DIST = i2modconf.in + +install-exec-hook: + $(LN_S) -f i2modconf $(bindir)/i2enmod + $(LN_S) -f i2modconf $(bindir)/i2dismod