Icinga 2 und Icinga Web 2 installieren

In diesem Artikel wird die Installation von Icinga 2 unter Ubuntu inklusive Datenbank und Icinga Web 2 Schritt für Schritt beschrieben.

Da Icinga 2 wesentlich flexibler ist als Icinga 1, gliedert sich die Installationbeschreibung in mehrere Abschnitte.

Grundinstallation

In diesem Abschnitt wird die grundlegende Installation unter Ubuntu 14.04 beschrieben. Aufbauend auf dieser Grundinstallation kann das System später seine eigentlich Funktion erhalten.

Zum verifizieren der Pakete muss zuerst der Key für das Repository hinzugefügt werden.

$ wget -O - http://packages.icinga.org/icinga.key | sudo apt-key add -
OK

Anschließend kann das Icinga Repository konfiguriert werden. Wird eine andere Ubuntu Version oder Debian verwendet, muss die URL eventuell angepasst werden.

$ echo "deb http://packages.icinga.org/ubuntu icinga-trusty main" | sudo tee /etc/apt/sources.list.d/icinga.list
deb http://packages.icinga.org/ubuntu icinga-trusty main

Damit die Pakete installiert werden können, muss die Paketliste aktualisiert werden.

$ sudo apt-get update

Anschließend sollte sich Icinga2 direkt aus den Paketquellen installieren lassen.

$ sudo apt-get install icinga2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  icinga2-bin icinga2-common icinga2-doc libboost-program-options1.54.0
  libboost-regex1.54.0 libboost-system1.54.0 libboost-thread1.54.0 libicu52
  libyajl2 nagios-plugins-basic nagios-plugins-common
Suggested packages:
  nagios3 icinga
The following NEW packages will be installed:
  icinga2 icinga2-bin icinga2-common icinga2-doc
  libboost-program-options1.54.0 libboost-regex1.54.0 libboost-system1.54.0
  libboost-thread1.54.0 libicu52 libyajl2 nagios-plugins-basic
  nagios-plugins-common
0 upgraded, 12 newly installed, 0 to remove and 31 not upgraded.
Need to get 10.1 MB of archives.
After this operation, 48.5 MB of additional disk space will be used.
Do you want to continue? [Y/n]

[2015-06-04 23:02:26 +0200] information/cli: Icinga application loader (version: v2.3.4)
[2015-06-04 23:02:26 +0200] information/cli: Loading application type: icinga/IcingaApplication
[2015-06-04 23:02:26 +0200] information/Utility: Loading library 'libicinga.so'
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/icinga2.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/constants.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/zones.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/itl
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/plugins
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/apt.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/commands.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/downtimes.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/groups.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/hosts.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/notifications.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/satellite.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/services.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/templates.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/timeperiods.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /etc/icinga2/conf.d/users.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command-icinga.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/timeperiod.conf
[2015-06-04 23:02:26 +0200] information/ConfigCompiler: Compiling config file: /usr/share/icinga2/include/command-plugins.conf
[2015-06-04 23:02:26 +0200] information/Utility: Loading library 'libmethods.so'
[2015-06-04 23:02:26 +0200] information/ConfigItem: Committing config items
[2015-06-04 23:02:26 +0200] warning/ApplyRule: Apply rule 'satellite-host' (in /etc/icinga2/conf.d/satellite.conf: 29:1-29:41) for type 'Dependency' does not match anywhere!
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 Endpoint(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 Zone(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 46 CheckCommand(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 2 NotificationCommand(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 3 TimePeriod(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 2 HostGroup(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 3 ServiceGroup(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 Host(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 12 Service(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 User(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 13 Notification(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 UserGroup(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 IcingaApplication(s).
[2015-06-04 23:02:26 +0200] information/ConfigItem: Checked 1 ScheduledDowntime(s).
[2015-06-04 23:02:26 +0200] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2015-06-04 23:02:26 +0200] information/ConfigItem: Triggering Start signal for config items
[2015-06-04 23:02:26 +0200] information/ConfigItem: Activated all objects.


enabling default icinga2 features
Enabling feature checker. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature mainlog. Make sure to restart Icinga 2 for these changes to take effect.
Setting up icinga2 (2.3.4~trusty) ...
Processing triggers for libc-bin (2.19-0ubuntu6.6) ...

Da Icinga während der Installation gestartet wurde, bevor alle Features aktiviert sind, muss es noch einmal neu gestartet werden.

$ sudo service icinga2 restart

Anschließend sollte der Icinga 2 Dienst laufen.

$ sudo service icinga2 status
 * icinga2 is running

Icinga 2 MySQL

Für die Speicherung von Ereignissen und damit auch andere Dienste schnell auf die Einstellungen etc. zugreifen können, müssen diese Information in einer Datenbank abgelegt werden. Zum jetzigen Zeitpunkt werden dafür MySQL/MariaDB und PostgreSQL unterstützt. In dieser Beschreibung wird auf MySQL zurückgegriffen.

$ sudo apt-get install mysql-server mysql-client
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libterm-readkey-perl mysql-client-5.5 mysql-client-core-5.5 mysql-common
  mysql-server-5.5 mysql-server-core-5.5
Suggested packages:
  libclone-perl libmldbm-perl libnet-daemon-perl libplrpc-perl
  libsql-statement-perl libipc-sharedcache-perl tinyca mailx
The following NEW packages will be installed:
  libaio1 libdbd-mysql-perl libdbi-perl libhtml-template-perl libmysqlclient18
  libterm-readkey-perl mysql-client mysql-client-5.5 mysql-client-core-5.5
  mysql-common mysql-server mysql-server-5.5 mysql-server-core-5.5

Damit Icinga 2 den aktuellen Status in eine Datenbank schreiben kann wird das Icinga Data Out(IDO) Feature benötigt, welches wie folgt installiert werden kann.

$ sudo apt-get install icinga2-ido-mysql
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  dbconfig-common
The following NEW packages will be installed:
  dbconfig-common icinga2-ido-mysql
0 upgraded, 2 newly installed, 0 to remove and 0 not upgraded.

Während der Installation wird über ein Dialog nach der Aktivierung des Features und der Einrichtung der Datenbank gefragt. An dieser Stelle wird auf die automatische Konfiguration zurückgegriffen, diese kann jedoch auch später händisch durchgeführt werden.

An dieser Stelle sollte geprüft werden, ob das Feature bereits aktiviert wurde.

$ sudo icinga2 feature list
Disabled features: api command compatlog debuglog gelf graphite icingastatus ido-mysql livestatus  opentsdb perfdata statusdata syslog
Enabled features: checker mainlog notification

Zwar wurde nach der Aktivierung gefragt, jedoch wurde diese nicht durchgeführt. Daher wird das Feature nachträglich aktiviert.

$ sudo icinga2 feature enable ido-mysql
Enabling feature ido-mysql. Make sure to restart Icinga 2 for these changes to take effect.

Damit das Feature geladen wird und Informationen in die Datenbank geschrieben werden, wird Icinga neu gestartet. Das Laden des IDO Features sollte mit einer Meldung signalisiert werden.

$ sudo service icinga2 restart
[...]
information/DbConnection: Resuming IDO connection: ido-mysql

Auch in der Logdatei /var/log/icinga2/icinga2.log sollte sich ein Hinweis finden lassen.

information/ConfigItem: Activated all objects.
information/IdoMysqlConnection: MySQL IDO instance id: 1 (schema version: '1.13.0')

Der aktuelle Status und die Ereignisse sollten sich jetzt über die Datenbank abfragen lassen.

Wurde die automatische Installation gewählt, so lautet der Name der Datenbank icinga2idomysql .

Icinga Web 2

Icinga Web 2 ist ein neues Frontend für Icinga 2 und lässt sich wie folgt installieren. Damit es funktioniert, wird eine Datenbank benötigt.

$ sudo apt-get install icingaweb2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  apache2 apache2-bin apache2-data icingaweb2-module-doc
  icingaweb2-module-monitoring icingaweb2-module-setup libapache2-mod-php5
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-icinga php5
  php5-cli php5-common php5-json php5-ldap php5-mysql php5-readline ssl-cert
Suggested packages:
  apache2-doc apache2-suexec-pristine apache2-suexec-custom apache2-utils
  php-pear php5-user-cache openssl-blacklist
The following NEW packages will be installed:
  apache2 apache2-bin apache2-data icingaweb2 icingaweb2-module-doc
  icingaweb2-module-monitoring icingaweb2-module-setup libapache2-mod-php5
  libapr1 libaprutil1 libaprutil1-dbd-sqlite3 libaprutil1-ldap php-icinga php5
  php5-cli php5-common php5-json php5-ldap php5-mysql php5-readline ssl-cert
0 upgraded, 21 newly installed, 0 to remove and 0 not upgraded.
Need to get 11.0 MB of archives.
After this operation, 56.5 MB of additional disk space will be used.

Anschließend muss in der Datei /etc/php5/apache2/php.ini ca. bei Zeile 879 folgende Einstellung gemacht werden.

date.timezone = Europe/Berlin

Damit die Einstellung übernommen wird, muss der Webserver neu gestartet werden.

Der Webserver muss im weiteren Verlauf mehrfach neu gestartet werden. Es reicht, wenn es nur einmal nach allen Schritten gemacht wird.

$ sudo service apache2 restart

Für weitere Funktionen wie die automatische Ermittlung der Zeitzone und der im Browser eingestellten Sprache wird das intl Modul benötigt. Die Module GD und Imagemagick werden für den Export von PDFs und Bildern benötigt.

$ sudo apt-get install php5-intl php5-gd php5-imagick
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
  fontconfig-config fonts-dejavu-core ghostscript gsfonts imagemagick-common
  libavahi-client3 libavahi-common-data libavahi-common3 libcups2
  libcupsfilters1 libcupsimage2 libfftw3-double3 libfontconfig1 libgd3 libgs9
  libgs9-common libijs-0.35 libjasper1 libjbig0 libjbig2dec0 libjpeg-turbo8
  libjpeg8 liblcms2-2 liblqr-1-0 libltdl7 libmagickcore5 libmagickwand5
  libpaper-utils libpaper1 libtiff5 libvpx1 poppler-data ttf-dejavu-core
Suggested packages:
  ghostscript-x hpijs cups-common libfftw3-bin libfftw3-dev libgd-tools
  fonts-droid libjasper-runtime liblcms2-utils libmagickcore5-extra
  poppler-utils fonts-japanese-mincho fonts-ipafont-mincho
  fonts-japanese-gothic fonts-ipafont-gothic fonts-arphic-ukai
  fonts-arphic-uming fonts-unfonts-core
The following NEW packages will be installed:
  fontconfig-config fonts-dejavu-core ghostscript gsfonts imagemagick-common
  libavahi-client3 libavahi-common-data libavahi-common3 libcups2
  libcupsfilters1 libcupsimage2 libfftw3-double3 libfontconfig1 libgd3 libgs9
  libgs9-common libijs-0.35 libjasper1 libjbig0 libjbig2dec0 libjpeg-turbo8
  libjpeg8 liblcms2-2 liblqr-1-0 libltdl7 libmagickcore5 libmagickwand5
  libpaper-utils libpaper1 libtiff5 libvpx1 php5-gd php5-imagick php5-intl
  poppler-data ttf-dejavu-core
0 upgraded, 36 newly installed, 0 to remove and 0 not upgraded.
Need to get 14.5 MB of archives.
After this operation, 55.0 MB of additional disk space will be used.

Apache neu starten oder bis zum nächsten Schritt warten.

$ sudo service apache2 restart

Damit über das Webfrontend Aktionen wie zum Beispiel das erneute Prüfen eines Dienstes ausgeführt werden können, muss das command Feature aktiviert werden.

$ sudo icinga2 feature enable command
Enabling feature command. Make sure to restart Icinga 2 for these changes to take effect.

Anschließend muss der Nutzer www-data der Gruppe nagios hinzugefügt werden.

$ sudo usermod -a -G nagios www-data

An dieser Stelle sollten die Dienste spätestens neu gestartet werden.

$ sudo service apache2 restart
$ sudo service icinga2 restart

Für die Konfiguration des Webfrontends wird ein Token benötigt, der wie folgt erstellt wird.

$ sudo icingacli setup token create
The newly generated setup token is: 81de643c66508672

Die weitere Konfiguration von Icinga Web 2 kann direkt über den Webbrowser über http://HOSTNAME/icingaweb2/setup erfolgen. Anschließend können die Informationen und Meldungen über das Frontend abgerufen werden.

Verwandte Artikel