Nagios 3 with Centreon 2.1 on Debian based Distributions (Eng)

About Nagios (http://www.nagios.org)
Nagios is a host and service monitor designed to inform you of network problems before your clients, end-users or managers do. It has been designed to run under the Linux operating system, but works fine under most *NIX variants as well. The monitoring daemon runs intermittent checks on hosts and services you specify using external “plugins” which return status information to Nagios. When problems are encountered, the daemon can send notifications out to administrative contacts in a variety of different ways (email, instant message, SMS, etc.). Current status information, historical logs, and reports can all be accessed via a web browser.
About Centreon (http://www.centreon.com)
Centreon is a network, system, applicative supervision and monitoring tool, it is based upon the most effective Open Source monitoring engine: Nagios. Centreon provides a new frontend and new functionalities to Nagios.
Prerequisites that not covered in this guide:
– You will need some knowledge of basic Linux administration, in case you will need to do troubleshooting.
– You will need to be familiar with Nagios architecture, and know how to solve errors that comes from nagios config validation.
– You will need an MTA daemon installed & configured, so nagios will able to send notifications, good examples are sendmail, postfix, exim.
Notes before we begin:
– This guide is intended for Debian/Ubuntu based distributions. It was tested on Debian 5.0 64-bit, and Ubuntu 8.10/9.04 Server 64-bit
– Centreon version 2.1.x is required for this gude to work, version 2.0.x of Centreon won’t work with this article.
– It’s recommended to use a clean install of Debian/Ubuntu.
– All commands in this article must be run as root user, in Ubuntu you can become a root user by using command “sudo -s”.
Install required Ubuntu/Debian packages:
Debian only:
# apt-get install sudo lsb-release
dos2unix, Converts DOS <-> Unix text files, alias tofromdos:
# apt-get install tofrodos
MTA (exim by default) and mail utilities:
# apt-get install mailx
Apache web server and PHP5:
# apt-get install apache2 php5 php-pear php5-mysql php5-ldap php5-snmp php5-gd
MySQL-Server:
# apt-get install mysql-server-5.0
You will be asked to specify a new password for the MySQL “root” user. Remember it, we will use it later.
RRDTool:
# apt-get install rrdtool librrds-perl
Required Perl modules:
# apt-get install libconfig-inifiles-perl libcrypt-des-perl libdigest-hmac-perl libdigest-sha1-perl libgd-gd2-perl
SNMP daemon:
# apt-get install snmp snmpd libnet-snmp-perl libsnmp-perl
Install Nagios 3 and NDOutils for MySQL:
Type:
# apt-get install nagios3 nagios-nrpe-plugin ndoutils-nagios3-mysql
When asked for “Configure database for ndoutils-mysql with dbconfig-common?”, answer NO, Centreon installation script will deal with it.
Now let’s move/backup the original Nagios configuration directory, as Centreon will use its own structure for Nagios configuration files:
# mv /etc/nagios3 /etc/nagios3.orig
# mkdir /etc/nagios3
# cp -Rt /etc/nagios3 /etc/nagios3.orig/nagios.cfg /etc/nagios3.orig/apache2.conf /etc/nagios3.orig/stylesheets/
# chown nagios:www-data /etc/nagios3
# chmod ug+w /etc/nagios3
Install optional packages (not required):
OpenSSH server (Every linux server must have it!):
# apt-get install ssh
PHPMyAdmin – web based Mysql console:
# apt-get install phpmyadmin
Install Centreon:
Note: Before beginning the installation make sure you have an internet connection!
Now download the latest Centreon distribution (by the time of writing latest version was 2.1.1):
Centreon installation script will update PEAR modules (if required). If you are behind proxy, use following command for PEAR proxy configuration:
# pear config-set http_proxy http://<my_proxy&gt;:<port>/
Replace “<my_proxy>” with to your proxy address and “<port>” with your proxy port.
Next, type following commands (remember to replace the names to Centreon version you use):
# tar xzf centreon-2.1.1.tar.gz
# cd centreon-2.1.1
# ./install.sh -i
Let’s follow the installation script questions:
Press “Enter” to read the Centreon License, then type “y” to accept it.
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
Where is your Centreon directory?
default to [/usr/local/centreon]: /usr/local/centreon
Do you want me to create this directory ? [/usr/local/centreon]
[y/n], default to [n]: y
Where is your Centreon log directory
default to [/usr/local/centreon/log]: /usr/local/centreon/log
Do you want me to create this directory ? [/usr/local/centreon/log]
[y/n], default to [n]: y
Where is your Centreon etc directory
default to [/etc/centreon]: /etc/centreon
Do you want me to create this directory ? [/etc/centreon]
[y/n], default to [n]: y
Where is your Centreon generation_files directory?
default to [/usr/local/centreon]: /usr/local/centreon
Where is your Centreon variable library directory?
default to [/var/lib/centreon]: /var/lib/centreon
Do you want me to create this directory ? [/var/lib/centreon]
[y/n], default to [n]: y
Where is your CentPlugins Traps binary
default to [/usr/local/centreon/bin]: /usr/local/centreon/bin
Do you want me to create this directory ? [/usr/local/centreon/bin]
[y/n], default to [n]: y
Where is the RRD perl module installed [RRDs.pm]
default to [/usr/lib/perl5/RRDs.pm]: /usr/lib/perl5/RRDs.pm
Where is PEAR [PEAR.php]
default to [/usr/share/php/PEAR.php]: /usr/share/php/PEAR.php
Where is installed Nagios ?
default to [/usr/local/nagios]: /usr/lib/cgi-bin/nagios3
Where is your nagios config directory
default to [/usr/local/nagios/etc]: /etc/nagios3
Where is your Nagios var directory ?
default to [/usr/local/nagios/var]: /var/lib/nagios3
Where is your Nagios plugins (libexec) directory ?
default to [/usr/local/nagios/libexec]: /usr/lib/nagios/plugins
Where is your Nagios image directory ?
default to [/usr/local/nagios/share/images/logos]: /usr/share/nagios/htdocs/images/logos
Where is your NDO ndomod binary ?
default to [/usr/sbin/ndomod.o]: /usr/lib/ndoutils/ndomod-mysql-3x.o
Where is sudo configuration file
default to [/etc/sudoers]: /etc/sudoers
Do you want me to configure your sudo ? (WARNING)
[y/n], default to [n]: y
Do you want to add Centreon Apache sub configuration file ?
[y/n], default to [n]: y
Do you want to reload your Apache ?
[y/n], default to [n]: y
Do you want me to install/upgrade your PEAR modules
[y/n], default to [y]: y
Where is your Centreon Run Dir directory?
default to [/var/run/centreon]: /var/run/centreon
Do you want me to create this directory ? [/var/run/centreon]
[y/n], default to [n]: y
Where is your CentStorage binary directory
default to [/usr/local/centreon/bin]: /usr/local/centreon/bin
Where is your CentStorage RRD directory
default to [/var/lib/centreon]: /var/lib/centreon
Do you want me to install CentStorage init script ?
[y/n], default to [n]: y
Do you want me to install CentStorage run level ?
[y/n], default to [n]: y
Where is your CentCore binary directory
default to [/usr/local/centreon/bin]: /usr/local/centreon/bin
Do you want me to install CentCore init script ?
[y/n], default to [n]: y
Do you want me to install CentCore run level ?
[y/n], default to [n]: y
Where is your CentPlugins lib directory
default to [/var/lib/centreon/centplugins]: /var/lib/centreon/centplugins
Do you want me to create this directory ? [/var/lib/centreon/centplugins]
[y/n], default to [n]: y
Where is your SNMP configuration directory
default to [/etc/snmp]: /etc/snmp
Where is your SNMPTT binaries directory
default to [/usr/local/centreon/bin/]: /usr/local/centreon/bin/
Continue the installation with the Centreon Web interface:
Open in web browser: “http://<yourserverip>/centreon/&#8221; replace “<yourserverip>” with your Centreon server ip address or hostname.
Follow Centreon Setup instructions:
– Press Start
– Check “I Accept” and press Next
– Make sure that selected “Nagios Version” is “3.x”, then press Next
– On next screen, make sure that all components status is “OK”, then press Next
– If all components are “OK”, then press Next again
– Fill required DB info as follows, then press Next
· Root Password for MySQL: [MySQL root password which you entered during MySQL installation]
· Centreon Database Name: centreon
· Centreon Data Storage Database Name: centstorage
· Database Password: centreon
· Confirm it: centreon
· MySQL Client version (Password Haching Changes): >=4.1 – PASSWORD()
– Press Next in the screen of DataBase Verification
– Fill required Admin user info, then press next (make sure that a username is Admin)
– Check “No” in “LDAP Authentication” screen, then press Next
– Press Next again
– Press Next in “Creating Database” screen
– Press on “Click here to complete your install”
NDOUtils configuration (from command line):
In Centreon version 2.1 and newer, NDO database is configured as part of the Centreon installation. We don’t need to configure manually. We only need to enable NDO, in “/usr/default/ndoutils”.
Edit the “/usr/default/ndoutils” by typing:
# vi /etc/default/ndoutils
Change “ENABLE_NDOUTILS=0” to “ENABLE_NDOUTILS=1”
Finalize Centreon configuration:
Open in webrowser: “http://<yourserverip>/centreon/&#8221;, replace “<yourserverip>” with your Centreon server ip address or hostname.
Go to: Configuration -> Nagios -> cgi (in sidebar), Press on “CGI.cfg” link
Change settings to some options, as writed below:
– Physical HTML Path: /usr/share/nagios3/htdocs
– URL HTML Path     : /nagios3
– Nagios Process Check Command: /usr/lib/nagios/plugins/check_nagios /var/cache/nagios3/status.dat 5 ‘/usr/sbin/nagios3’
Press Save
Go to: Configuration -> Nagios -> nagios.cfg (in sidebar), Press on “Nagios CFG 1” link, you should be in “Files” section of the configuration screen.
Make sure to set folowing configuration values:
– Log File              : /var/log/nagios3/nagios.log
– Downtime File         : /var/lib/nagios3/downtime.dat
– Comment File          : /var/lib/nagios3/comment.dat
– Temp File             : /var/cache/nagios3/nagios.tmp
– P1 File               : /usr/lib/nagios3/p1.pl
– Lock File             : /var/run/nagios3/nagios3.pid
– Object Cache File     : /var/cache/nagios3/objects.cache
– Status File           : /var/cache/nagios3/status.dat
– External Command File : /var/lib/nagios3/rw/nagios.cmd
Now Press on “Logs Options” tab to go to “Logs Options” section.
Make sure to set folowing configuration values:
– Log Archive Path     : /var/log/nagios3/archives/
– State Retention File : /var/lib/nagios3/retention.dat
Press Save
Go to: Administration -> Options -> CentStorage (in sidebar)
Make sure to set folowing configuration values:
– Nagios current log file to parse: /var/log/nagios3/nagios.log
Press Save
Now let’s apply our changes, go to: Configuration -> Nagios
Select as below:
– Generate Configuration Files
– Include Comments
– Run Nagios debug (-v)
– Move Export Files
– Restart Nagios
– Method: “External Command”
Press Export
This will restart Nagios & apply all changes you made in Web Interface.
You will do it every time you make changes, e.g. adding/modifying of hosts, commands, contacts, services…etc…
The installation of Centreon is completed.
Final fixes (very important):
Go to terminal console, then…
In Debian/Ubuntu the user “nagios” is set to “/bin/false” shell. Because of it “centcore” and “centstorage” daemons won’t start. A reason for that is because those daemons use “su -c” command which requires a real shell, so the shell for “nagios” user must be set to “/bin/sh”:
# usermod -s /bin/sh nagios
Apply permissions for Web interface to be able to send “External Commands”, perform the following commands to change directory permissions and to make the changes permanent:
# invoke-rc.d nagios3 stop
# dpkg-statoverride –update –add nagios www-data 2710 /var/lib/nagios3/rw
# dpkg-statoverride –update –add nagios nagios 751 /var/lib/nagios3
Add htaccess user with password “P@ssw0rd” for nagios CGI:
# htpasswd -bc /etc/nagios3/htpasswd.users nagiosadmin P@ssw0rd
Allow SNMP readonly access:
# echo “rocommunity public” > /etc/snmp/snmpd.conf
If you want to allow SNMP access only for localhost then use this instead:
# echo “rocommunity public 127.0.0.1” > /etc/snmp/snmpd.conf
Now, restart the server
# sync;sync;init 6
That’s it, after reboot, you will have a fully functional Nagios & Centreon environment.
Feel free to add comments/suggestions.

5 pensamentos sobre “Nagios 3 with Centreon 2.1 on Debian based Distributions (Eng)

  1. […] (Eng) Escrito por Sergio Sainz en GNU/Linux, Sistemas, Tips Hago un C&P completo de un post de Mundonix, que me ha pasado un compi y no quiero perder About Nagios (http://www.nagios.org) Nagios is a […]

  2. Leonardo disse:

    Sorry for my poor english, how to configure Centreon to get the 100% UNDETERMINED ja tetei of several ways and could not straighten someone could help me.

  3. Leonardo disse:

    Como eu faço para tirar o 100% UNDETERMINED no Dashboard do Centreon?

Deixe um comentário