Icinga

Aus wiki.archlinux.de

„Icinga“ wurde von Fotoniker (Diskussion) als in Bearbeitung markiert. Um Bearbeitungskonflikte zu vermeiden, kontaktiere Fotoniker (Diskussion) bitte, bevor du den Artikel bearbeitest.


Icinga ist ein Open-Source-Anwendung zur System- und Netzwerküberwachung. Es wurde ursprünglich als Fork der Nagios-Systemüberwachungsanwendung im Jahr 2009 erstellt. - Quelle: Wikipedia

Aktuell (2019) wird Icinga2 aktiv weiter entwickelt, als frontend empfielt sich die Installation von icingaweb2, die eine Weboberfläche zur verfügung stellt. Hierfür ist es allerdings nötig einen Webserver wie Apache2 zu verwenden. icinga2 wie auch icingaweb2 benötigen zusätzliche eine SQL-Datenbank, vorgesehen dafür wäre MariaDB (mysql) oder ProgreSQL.

MariaDB sollte bereits Installiert sein, ansonsten siehe: MariaDB

Installation

Das Programm ist als icinga2 in AUR verfügbar, und kann von dort mittels Pacman installiert werden.

pacman -S icinga2

Bei der Verwendung von AUR-Hilfsprogrammen ist zu beachten, dass Pakete niemals „blind“ installiert werden sollten. Vor dem Installieren sollten die Kommentare im AUR gelesen, und das PKGBUILD geprüft werden.

Pfade:
/etc/icinga2/
/usr/share/icinga2/
/usr/share/icinga2-ido-mysql/
systemctl Befehle:
Icinga2 Service automatisch beim starten laden:
systemctl enable icinga2

Icinga2 Service nicht mehr laden beim starten:
systemctl disable icinga2

Dienst starten:
systemctl start icinga2

Dienst stoppen:
systemctl stop icinga2

Dienst neustarten und Konfiguration neu einlesen:
systemctl reload icinga2

Status des Dienstes anzeigen:
systemctl status icinga2

Icinga2 Konfiguration

Anlegen einer Datenbank in MariaDB:
mysql -u root -p
CREATE DATABASE icinga;
GRANT SELECT, INSERT, UPDATE, DELETE, DROP, CREATE VIEW, INDEX, EXECUTE ON icinga.* TO 'icinga'@'localhost' IDENTIFIED BY 'icinga';
quit

In die neu erzeugte Datenbank importieren wir ein neues Schema: mysql -u root -p icinga < /usr/share/icinga2-ido-mysql/schema/mysql.sql

Ist die Datenbank eingerichtet sollten wir das IDO-Modul von Icinga2 mit den passenden Zugangsdaten versorgen und aktivieren:
nano /etc/icinga2/features-available/ido-mysql.conf
/**
 * The IdoMysqlConnection type implements MySQL support
 * for DB IDO.
 */
object IdoMysqlConnection "icinga" {
  user = "icinga"
  password = "CHANGEME"
  host = "localhost"
  database = "icinga"
}

IDO-Modul in Icinga2 aktivieren: icinga2 feature enable ido-mysql danach sollte der Dienst neugestartet werden: systemctl restart icinga2 und der Status überprüft werden: systemctl status icinga2

Um icingaweb2 später verwenden zu können ist es nötig das REST API feature zu Konfigurieren: icinga2 api setup

nano /etc/icinga2/conf.d/api-users.conf Achtung: "ApiUser" den eigenen wünschen nach anpassen, den API Key benötigen wir später für icingaweb2

/**
 * The ApiUser objects are used for authentication against the API.
 */
object ApiUser "icingaweb" {
  password = "API_KEY_HERE"
  // client_cn = ""
  permissions = [ "*" ]
}

icingaweb2 Installation

pacman -S icingaweb2

Pfade:
/etc/icingaweb2/
/usr/share/icingaweb2/
/usr/share/webapps/icingaweb2/

icingaweb2 Konfiguration

PHP-FPM installieren: pacman -S php-fpm

/etc/php.php.ini
/etc/php/php-fpm.conf
/etc/php/php-fpm.d/www.conf

Prüfen ob in der www.conf unter listen folgendes steht: listen = /run/php-fpm/php-fpm.sock

php-fpm Dienst aktivieren und starten: systemctl enable php-fpm, systemctl start php-fpm sowie Status prüfen: systemctl status php-fpm

Apache2 Konfiguration

nano /etc/httpd/conf/extra/php-fpm.conf

DirectoryIndex index.php index.html
<FilesMatch \.php$>
    SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
</FilesMatch>

nano /etc/httpd/conf/extra/icingaweb2.conf

Alias /icingaweb2 "/usr/share/webapps/icingaweb2/public"
 
<IfVersion < 2.4>
    # Forward PHP requests to FPM
    SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
    <LocationMatch "^/icingaweb2/(.*\.php)$">
        ProxyPassMatch "fcgi://localhost/usr/share/icingaweb2/public/$1"
    </LocationMatch>
</IfVersion>
 
<Directory "/usr/share/webapps/icingaweb2/public">
    Options SymLinksIfOwnerMatch
    AllowOverride None

    DirectoryIndex index.php

    <IfModule mod_authz_core.c>
        # Apache 2.4
        <RequireAll>
            Require all granted
        </RequireAll>
    </IfModule>
 
    <IfModule !mod_authz_core.c>
        # Apache 2.2
        Order allow,deny
        Allow from all
    </IfModule>
 
    SetEnv ICINGAWEB_CONFIGDIR "/etc/icingaweb2"
 
    EnableSendfile Off
 
    <IfModule mod_rewrite.c>
        RewriteEngine on
        RewriteBase /icingaweb2/
        RewriteCond %{REQUEST_FILENAME} -s [OR]
        RewriteCond %{REQUEST_FILENAME} -l [OR]
        RewriteCond %{REQUEST_FILENAME} -d
        RewriteRule ^.*$ - [NC,L]
        RewriteRule ^.*$ index.php [NC,L]
    </IfModule>
 
    <IfModule !mod_rewrite.c>
        DirectoryIndex error_norewrite.html
        ErrorDocument 404 /icingaweb2/error_norewrite.html
    </IfModule>
 
    <IfVersion >= 2.4>
        # Forward PHP requests to FPM
        SetEnvIf Authorization "(.*)" HTTP_AUTHORIZATION=$1
        <FilesMatch "\.php$">
            #SetHandler "proxy:fcgi://localhost/"
            SetHandler "proxy:unix:/run/php-fpm/php-fpm.sock|fcgi://localhost/"
            ErrorDocument 503 /icingaweb2/error_unavailable.html
        </FilesMatch>
    </IfVersion>
</Directory>

Editieren der Apache2 config und aktivieren der Proxy-Module sowie die oben erstellen Konfigurationen laden lassen:

/etc/httpd/conf/httpd.conf

LoadModule proxy_module modules/mod_proxy.so LoadModule proxy_fcgi_module modules/mod_proxy_fcgi.so

Include conf/extra/php-fpm.conf Include conf/extra/icingaweb2.conf

Siehe auch

Weblinks