Inhaltsverzeichnis

Nagios unter Getnoo mit Lilac-Reloaded

Installation des Nagiosdienstes

Grundsätzliches

Fogende Features werden installiert:

Folgende Zeilen müssen in der package.keywords stehen:

net-analyzer/nagios-plugins
=sys-apps/portage-2.2* ~*
net-analyzer/nagios
net-analyzer/nagios-core
net-analyzer/nagios-plugins

Folgende Zeilen müssen in der package.use stehen:

net-analyzer/nagios-plugins ipv6 nagios-ssh ssl jabber ldap mysql nagios-dns nagios-game nagios-ntp nagios-ping postgres radius samba snmp ups
net-analyzer/nagios-core apache2
net-fs/samba -server -acl -avahi -cups
net-nds/openldap minimal
dev-lang/php snmp cgi curl mysql pcntl pdo gd xml apache2 ldap ldap-sasl
www-servers/apache ldap
dev-libs/apr-util ldap

Daneben gibt es noch die speziellen Variablen APACHE2_MODULES und APACHE2_MPMS, die bestimmen, welche Apache-Module und welche MPMs (Multi-Processing Modules) im späteren Einsatz zur Verfügung stehen. Das ganze kann man in der make.conf festlegen.

...
APACHE2_MPMS="worker"
...

Und das ganze installieren:

emerge -qa net-analyzer/nagios net-analyzer/nagios-plugins-snmp net-analyzer/nagios-plugins

Ausgabe von Portage:

* APACHE
 * The location of SSL certificates has changed. If you are
 * upgrading from www-servers/apache-2.2.13 or earlier (or remerged
 * *any* apache version), you might want to move your old
 * certificates from /etc/apache2/ssl/ to /etc/ssl/apache2/ and
 * update your config files.
 * 
 * Attention: cgi and cgid modules are now handled via APACHE2_MODULES flags
 * in /etc/make.conf. Make sure to enable those in order to compile them.
 * In general, you should use 'cgid' with threaded MPMs and 'cgi' otherwise.


PHP
* Please note that this version of PHP does not yet come with a suhosin patch
* Installing SAPI: cli
 * Installing php.ini for cli into /etc/php/cli-php5.3
 * 
 * Installing SAPI: cgi
 * Installing php.ini for cgi into /etc/php/cgi-php5.3
 * 
 * Installing SAPI: apache2
 * Installing php.ini for apache2 into /etc/php/apache2-php5.3
 * 
 * 
 * To enable php, you need to edit your /etc/conf.d/apache2 file and
 * add '-D PHP5' to APACHE2_OPTS.
 * 
 * 
 * Configuration file installed as
 *     /etc/apache2/modules.d/70_mod_php5.conf
 * You may want to edit it before turning the module on in /etc/conf.d/apache2
 * 
 * Switched cli to use php:5.3
 * 
 * Switched cgi to use php:5.3
 * 
 * Switched apache2 to use php:5.3
 * 
 * Make sure that PHP_TARGETS in /etc/make.conf includes php5-3 in order
 * to compile extensions for the 5.3 ABI
 * 
 * 
 * This ebuild installed a version of php.ini based on php.ini-development version.
 * You can chose which version of php.ini to install by default by setting PHP_INI_VERSION to either
 * 'production' or 'development' in /etc/make.conf
 * Both versions of php.ini can be found in /usr/share/doc/php-5.3.6

Einrichten der Dienste

-D PHP5

emerge --config =dev-db/mysql-5.1.56
rc-update add mysql
/etc/init.d/mysql start
rc-update add apache2
/etc/init.d/apache2 start
rc-update add nagios
/etc/init.d/nagios start

Konfiguration

Man kann zusätzliche Berechtigungen in folgender Datei übergeben

nano /etc/apache2/modules.d/99_nagios3.conf

Wir bleiben hier aber bei „Allow from all“

Jetzt erstellen wir den Apache authorization table. Hierzu legen wir jeweils eine „.htaccess“ in folgenden Verzeichnissen an:

Pfad
nano /usr/share/nagios/htdocs/.htaccess
nano /usr/lib/nagios/cgi-bin/.htaccess

Der Inhalt der Datei soll so aussehen:

AuthName "Nagios Access"
AuthType Basic
AuthUserFile /etc/nagios/auth.users
Require valid-user

Jetzt legen wir den Nagiosbenutzer für das Webinterface an:

htpasswd2 -c /etc/nagios/auth.users nagiosadmin
(Apache needs read access to auth.users)
chown nagios:nagios /etc/nagios/auth.users

Apache konfigurieren

Zuerst müssen wir unseren default VHOST festlegen.

nano /etc/apache2/vhosts.d/00_default_vhost.conf

...
<VirtualHost *:80>
        ServerName localhost
        Include /etc/apache2/vhosts.d/default_vhost.include

        <IfModule mpm_peruser_module>
                ServerEnvironment apache apache
        </IfModule>

ScriptAlias /nagios/cgi-bin /usr/lib/nagios/cgi-bin
<Directory "/usr/lib/nagios/cgi-bin">
        Options ExecCGI
        AllowOverride None
        AllowOverride AuthConfig
        Order allow,deny
        Allow from all
</Directory>

Alias /nagios /usr/share/nagios/htdocs
<Directory "/usr/share/nagios/htdocs">
        Options Indexes
        AllowOverride None
        Order allow,deny
        Allow from all
</Directory>

</VirtualHost>
</IfDefine>
...

Jetzt noch die erforderlichen Dienste neu starten:

/etc/init.d/nagios restart && /etc/init.d/apache2 restart

Jetzt kann man sich über http://nagios-test.darkwolf.lan/nagios einloggen.