Nagios/Centreon auf Ubuntu 12.04.5 LTS installieren

Damit ich sicherstellen kann, das zu jeder Zeit alle Systeme im grünen Bereich laufen, gehört eine Monitoring-Software in jede IT Umgebung. Ich setze dabei auf das bewährte Nagios in Verbindung mit Centreon, da dadurch die Einrichtung der Konfigurationsdateien enorm erleichtert wird. Da ich aktuell einen neuen Server installieren muss, folgt gleich eine aktuelle Anleitung. Alle Schritte sollten als root User ausgeführt werden, deshalb ist vorab ein sudo -s zu empfehlen.

Pakete installieren

apt-get update
apt-get install gcc make g++ libgd2-xpm libgd2-xpm-dev php5-ldap php-DB build-essential cmake librrd-dev libqt4-dev libqt4-sql-mysql libgnutls28-dev snmp-mibs-downloader
apt-get upgrade

Nagios User und Gruppen hinzufügen

/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

Nagios + Plugins herunterladen und entpacken, die aktuellen Source Dateien findet man unter http://www.nagios.org/download/

wget http://downloads.sourceforge.net/project/nagios/nagios-3.x/nagios-3.5.0/nagios-3.5.0.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar xzfv nagios-3.5.0.tar.gz 
tar xzfv nagios-plugins-2.0.3.tar.gz

Nagios compilieren und installieren

cd nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config

Wenn die Installation von Nagios nun abgeschlossen ist, kann man an dieser Stelle noch den Befehl make install-webconf ausführen. Da ich aber meine eigene Apache Config benutze, führe ich das nicht aus.

Nagios-Plugins compilieren und installieren

cd nagios-plugins-2.0.3
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

Damit wäre die Installation von Nagios inklusive der Plugins abgeschlossen.

Da ich aus Performance Gründen auf den Centreon Broker statt auf ndoutils setze, müssen wir diesen zuerst installieren.
Die Dateien für Centreon und Broker finden wir unter https://download.centreon.com/
Eine ausführlichere Anleitung für den Centreon-Broker sowie für Centreon selbst, findet sich auch in der Centreon Dokumentation.

Centreon Broker installieren

wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon-broker/centreon-broker-2.8.2.tar.gz
/usr/sbin/groupadd centreon-broker
/usr/sbin/useradd -g centreon-broker -m -r -d /var/lib/centreon-broker centreon-broker
tar xzfv centreon-broker-2.8.2.tar.gz
cd centreon-broker-2.8.2/build
cmake -DWITH_DAEMONS='central-broker;central-rrd' -DWITH_GROUP=centreon-broker -DWITH_PREFIX=/usr/local/centreon-broker -DWITH_STARTUP_DIR=/etc/init.d -DWITH_STARTUP_SCRIPT=auto -DWITH_TESTING=0 -DWITH_USER=centreon-broker
make
make install

Centreon installieren

wget https://s3-eu-west-1.amazonaws.com/centreon-download/public/centreon/centreon-2.6.0.tar.gz
tar xzfv centreon-2.6.0.tar.gz
cd centreon-2.6.0/
mkdir /var/log/nagios
chown nagios:nagios /var/log/nagios
./install.sh -i

Jetzt müssen alle Pfade angepasst werden:

------------------------------------------------------------------------
        Please choose what you want to install
------------------------------------------------------------------------

Do you want to install : Centreon Web Front
[y/n], default to [n]:
> y

Do you want to install : Centreon CentCore
[y/n], default to [n]:
> y

Do you want to install : Centreon Nagios Plugins
[y/n], default to [n]:
> y

Do you want to install : Centreon Snmp Traps process
[y/n], default to [n]:
> y
------------------------------------------------------------------------
        Start CentWeb Installation
------------------------------------------------------------------------

Where is your Centreon directory?
default to [/usr/local/centreon]
>

Do you want me to create this directory ? [/usr/local/centreon]
[y/n], default to [n]:
> y
Path /usr/local/centreon                                   OK

Where is your Centreon log directory
default to [/usr/local/centreon/log]
> /var/log/centreon

Do you want me to create this directory ? [/var/log/centreon]
[y/n], default to [n]:
> y
Path /var/log/centreon                                     OK

Where is your Centreon etc directory
default to [/etc/centreon]
>

Do you want me to create this directory ? [/etc/centreon]
[y/n], default to [n]:
> y
Path /etc/centreon                                         OK

Where is your Centreon binaries directory
default to [/usr/local/centreon/bin]
>

Do you want me to create this directory ? [/usr/local/centreon/bin]
[y/n], default to [n]:
> y
Path /usr/local/centreon/bin                               OK

Where is your Centreon data informations directory
default to [/usr/local/centreon/data]
>

Do you want me to create this directory ? [/usr/local/centreon/data]
[y/n], default to [n]:
> y
Path /usr/local/centreon/data                              OK

Where is your Centreon variable library directory?
default to [/var/lib/centreon]
>
Path /var/lib/centreon                                     OK
/usr/bin/rrdtool                                           OK
/usr/bin/mail                                              OK
/usr/bin/php                                               OK

Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]
>
Path /usr/share/php                                        OK
/usr/bin/perl                                              OK
Finding Apache user :                                      www-data
Finding Apache group :                                     www-data

What is the Centreon group ? [centreon]
default to [centreon]
>

Do you want me to create this group ? [centreon]
[y/n], default to [n]:
> y

What is the Centreon user ? [centreon]
default to [centreon]
>

Do you want me to create this user ? [centreon]
[y/n], default to [n]:
> y

What is the Monitoring engine user ?
> nagios

What is the Broker user ? (optional)
> centreon-broker

What is the Monitoring engine log directory ?
> /var/log/nagios

Where is your monitoring plugins (libexec) directory ?
default to [/usr/lib/nagios/plugins]
> /usr/local/nagios/libexec
Path /usr/local/nagios/libexec                             OK
Add group centreon to user www-data                        OK
Add group centreon to user nagios                          OK
Add group nagios to user www-data                          OK
Add group nagios to user centreon                          OK

------------------------------------------------------------------------
        Configure Sudo
------------------------------------------------------------------------

Where is sudo configuration file
default to [/etc/sudoers]
>
/etc/sudoers                                               OK

What is the Monitoring engine init.d script ?
> /etc/init.d/nagios

What is the Monitoring engine binary ?
> /usr/local/nagios/bin/nagios

What is the Monitoring engine configuration directory ?
> /usr/local/nagios/etc

Where is the configuration directory for broker module ?
> /usr/local/centreon-broker/etc

Where is the init script for broker module daemon ?
> /etc/init.d/cbd
Your sudo is not configured

Do you want me to configure your sudo ? (WARNING)
[y/n], default to [n]:
> y
Configuring Sudo                                           OK
------------------------------------------------------------------------
        Configure Apache server
------------------------------------------------------------------------

Do you want to add Centreon Apache sub configuration file ?
[y/n], default to [n]:
> n
Please config Apache with this example:
 /usr/local/centreon/examples/centreon.apache.conf
Preparing Centreon temporary files
Change right on /var/log/centreon                          OK
Change right on /etc/centreon                              OK
Change macros for insertBaseConf.sql                       OK
Change macros for sql update files                         OK
Change macros for php files                                OK
Change macros for perl binary                              OK
Change right on /usr/local/nagios/etc                      OK
Add group centreon-broker to user www-data                 OK
Add group centreon-broker to user nagios                   OK
Add group centreon to user centreon-broker                 OK
Change right on /usr/local/centreon-broker/etc             OK
Copy CentWeb in system directory
Install CentWeb (web front of centreon)                    OK
Change right for install directory
Change right for install directory                         OK
Install libraries                                          OK
Write right to Smarty Cache                                OK
Copying libinstall                                         OK
Change macros for centreon.cron                            OK
Install Centreon cron.d file                               OK
Change macros for centAcl.php                              OK
Change macros for downtimeManager.php                      OK
Install cron directory                                     OK
Change right for eventReportBuilder                        OK
Change right for dashboardBuilder                          OK
Change macros for centreon.logrotate                       OK
Install Centreon logrotate.d file                          OK
Prepare centFillTrapDB                                     OK
Install centFillTrapDB                                     OK
Prepare centreon_trap_send                                 OK
Install centreon_trap_send                                 OK
Prepare centreon_check_perfdata                            OK
Install centreon_check_perfdata                            OK
Prepare centreonSyncPlugins                                OK
Install centreonSyncPlugins                                OK
Prepare centreonSyncArchives                               OK
Install centreonSyncArchives                               OK
Install generateSqlLite                                    OK
Install changeRrdDsName.pl                                 OK
Prepare export-mysql-indexes                               OK
Install export-mysql-indexes                               OK
Prepare import-mysql-indexes                               OK
Install import-mysql-indexes                               OK
Centreon Web Perl lib installed                            OK
------------------------------------------------------------------------
                Centreon Post Install
------------------------------------------------------------------------
Create /usr/local/centreon/www/install/install.conf.php    OK
Create /etc/centreon/instCentWeb.conf                      OK
------------------------------------------------------------------------
        Start CentStorage Installation
------------------------------------------------------------------------

Where is your Centreon Run Dir directory?
default to [/var/run/centreon]
>
Path /var/run/centreon                                     OK

Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK

Where is your CentStorage RRD directory
default to [/var/lib/centreon]
>
Path /var/lib/centreon                                     OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
install www/install/createTablesCentstorage.sql            OK
CentStorage status Directory already exists                PASSED
CentStorage metrics Directory already exists               PASSED
Install CentStorage binary                                 OK
Change right : /var/run/centreon                           OK
Change macros for centstorage init script                  OK
Replace Centstorage default script Macro                   OK

Do you want me to install CentStorage init script ?
[y/n], default to [n]:
> y
CentStorage init script installed                          OK
CentStorage default script installed                       OK

Do you want me to install CentStorage run level ?
[y/n], default to [n]:
> y
 System start/stop links for /etc/init.d/centstorage already exist.
CentStorage Perl lib installed                             OK
Install logAnalyser                                        OK
Install logAnalyserBroker                                  OK
Install nagiosPerfTrace                                    OK
Change macros for centstorage.cron                         OK
Install CentStorage cron                                   OK
Change macros for centstorage.logrotate                    OK
Install Centreon Storage logrotate.d file                  OK
Create /etc/centreon/instCentStorage.conf                  OK
------------------------------------------------------------------------
        Start CentCore Installation
------------------------------------------------------------------------

Where is your CentCore binary directory
default to [/usr/local/centreon/bin]
>
Path /usr/local/centreon/bin                               OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Copy CentCore in binary directory                          OK
Change right : /var/run/centreon                           OK
Change right : /var/lib/centreon                           OK
Change macros for centcore.logrotate                       OK
Install Centreon Core logrotate.d file                     OK
Replace CentCore init script Macro                         OK
Replace CentCore default script Macro                      OK

Do you want me to install CentCore init script ?
[y/n], default to [n]:
> y
CentCore init script installed                             OK
CentCore default script installed                          OK

Do you want me to install CentCore run level ?
[y/n], default to [n]:
> y
 System start/stop links for /etc/init.d/centcore already exist.
CentCore Perl lib installed                                OK
Create /etc/centreon/instCentCore.conf                     OK
------------------------------------------------------------------------
        Start CentPlugins Installation
------------------------------------------------------------------------

Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]
>
Path /var/lib/centreon/centplugins                         OK
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for CentPlugins                              OK
Installing the plugins                                     OK
Change right on centreon.conf                              OK
CentPlugins is installed

------------------------------------------------------------------------
        Start CentPlugins Traps Installation
------------------------------------------------------------------------

Where is your SNMP configuration directory
default to [/etc/snmp]
>
/etc/snmp                                                  OK

Where is your CentreonTrapd binaries directory
default to [/usr/local/centreon/bin]
>
/usr/local/centreon/bin                                    OK
Finding Apache user :                                      www-data
Preparing Centreon temporary files
/tmp/centreon-setup exists, it will be moved...
Change macros for snmptrapd.conf                           OK
Replace CentreonTrapd init script Macro                    OK
Replace CentreonTrapd default script Macro                 OK

Do you want me to install CentreonTrapd init script ?
[y/n], default to [n]:
> y
CentreonTrapd init script installed                        OK
CentreonTrapd default script installed                     OK

Do you want me to install CentreonTrapd run level ?
[y/n], default to [n]:
> y
 System start/stop links for /etc/init.d/centreontrapd already exist.
trapd Perl lib installed                                   OK
Install : snmptrapd.conf                                   OK
Install : centreontrapdforward                             OK
Install : centreontrapd                                    OK
Create /etc/centreon/instCentPlugins.conf                  OK

Da wir bisher noch keine Apache Konfiguration vorgenommen haben, sollten wir das an dieser Stelle machen. Ich benutze hierfür meine eigene Konfiguration, diese liegt bei mir unter /etc/apache2/sites-available/nagios.conf und hat folgenden Inhalt:

Listen 8080
<VirtualHost _default_:8080>

 ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
 Alias /nagios "/usr/local/nagios/share"
 Alias /centreon/ /usr/local/centreon/www/

 <Directory "/usr/local/centreon/www">
 Options Indexes
 AllowOverride AuthConfig Options
 Order allow,deny
 Allow from all
 </Directory>

 <Directory "/usr/local/nagios/sbin">
 Options ExecCGI
 AllowOverride None
 Order allow,deny
 Allow from all
 AuthName "Access"
 AuthType Basic
 AuthUserFile /usr/local/nagios/etc/htpasswd.users
 Require valid-user
 </Directory>

 <Directory "/usr/local/nagios/share">
 Options None
 AllowOverride None
 Order allow,deny
 Allow from all
 AuthName "Access"
 AuthType Basic
 AuthUserFile /usr/local/nagios/etc/htpasswd.users
 Require valid-user
 </Directory>

</VirtualHost>

Brauchen wir noch ein Passwort für Nagios und aktivieren die Apache Conf

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
a2ensite nagios.conf
service apache2 reload

Nun können wir auf der Weboberfläche, in diesem Fall http://:8080/centreon, die Benutzeroberfläche von Centreon aufrufen. Falls auf der Website nichts auftaucht, ein Serverneustart bewirkt manchmal wunder ;-). Bei der Installation von Centreon müssen noch einige Pfade angegeben werden:

Monitoring engine information
Monitoring engine: nagios
Nagios directory: /usr/local/nagios
Nagiostats binary: /usr/local/nagios/bin/nagiostats
Nagios image directory: /usr/local/nagios/share/images

Broker Module information
Broker Module: centreon-broker
Centreon Broker etc directory: /usr/local/centreon-broker/etc
Centreon Broker module (cbmod.so): /usr/local/centreon-broker/lib/cbmod.so
Centreon Broker log directory: /var/log/centreon
Retention file directory: /var/lib/centreon-broker
Centreon Broker lib (*.so) directory: /usr/local/centreon-broker/lib/centreon-broker

Wenn ihr Plesk benutzt, dann müsst ihr bei der MySQL Konfiguration den Benutzer ändern. In der Datei /usr/local/centreon/www/install/steps/functions.php muss der Benutzer root in admin geändert werden. Das Passwort für dem admin Benutzer bekommt ihr mit dem Befehl cat /etc/psa/.psa.shadow

Es könnte nützlich sein vorher noch einige Berechtigungen anzupassen:

/usr/sbin/usermod -a -G centreon-broker nagios

Damit Nagios und der Broker auch beim Systemstart läuft, brauchen wir diese noch im Autostart. Vorher am Besten nochmal die Konfigurationen neu verteilen.

update-rc.d nagios defaults
update-rc.d cbd defaults
/etc/init.d/nagios start
/etc/init.d/cbd start

Dennis

Hallo zusammen, mein Name ist Dennis. Ich bin Geschäftsführer eines IT-Dienstleistungsunternehmen für den Mittelstand. In meiner Freizeit treibe ich gerne Sport und beschäftige mich mit allerlei Technik. Bei Fragen jeglicher Art könnt ihr einfach auf mich zukommen :)

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.