Tuesday, September 29, 2009

Install Nagios with Centreon on Debian

Introduction
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 come 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.
Before we begin
All commands in this guide must be run as root user, in Ubuntu you can become a root user by using command "sudo -s".
This guide is indented for Debian/Ubuntu based distributions. It was tested on Debian 4.0r2, and Ubuntu 7.10 Server/Desktop.
Warning: Centreon installer will not work on Ubuntu 8.04 LTS, the installer failing to detect Apache User/Group names. It is because those settings are defined via environment variables in apache2.conf, those variables are located in /etc/apache2/envvars.
Still, you can use the installer after replacing 2 configuration options in apache2.conf
To do it, follow those commands:
# cp /etc/apache2/apache2.conf /etc/apache2/apache2.conf.default
# sed "s/\${APACHE_RUN_USER}/www-data/g" /etc/apache2/apache2.conf.default > /etc/apache2/apache2.tmp
# sed "s/\${APACHE_RUN_GROUP}/www-data/g" /etc/apache2/apache2.tmp > /etc/apache2/apache2.conf
# rm /etc/apache2/apache2.tmp
I recommend, to restore default apache configuration after Centreon Installation is finished:
# mv /etc/apache2/apache2.conf.default /etc/apache2/apache2.conf
Install required Ubuntu/Debian packages:
Sudo for Debian
# apt-get install sudo
dos2unix, Converts DOS <-> Unix text files, alias tofromdos
# apt-get install tofrodos
Apache 2 web server
# apt-get install apache2
Nagios 2
# apt-get install nagios2 nagios-plugins nagios-images nagios-nrpe-plugin
MySQL 5 database server
# apt-get install mysql-server-5.0
PHP5 + required modules
# apt-get install php5 php5-cli php-db php-date php5-gd php5-mysql php5-snmp \
php5-ldap php-mail php-mail-mime php-net-smtp php-net-socket php5-xmlrpc
RRDTool
# apt-get install rrdtool librrds-perl
Perl "ini" files support
# apt-get install libconfig-inifiles-perl
SNMP
# apt-get install snmp snmpd libnet-snmp-perl
Open file /etc/snmp/snmpd.conf for editing.
Find:
#com2sec readonly default public
Remove "#" sign
Save & restart SNMP deamon:
# invoke-rc.d snmpd restart
Test it:
# snmpget -v1 -c public localhost sysDescr.0
Successful output will be something like:
SNMPv2-MIB::sysDescr.0 = STRING: Linux monitor01 2.6.22-14-server #1 SMP Tue Feb 12 08:27:05 UTC 2008 i686
Additional pear modules
# pear channel-update pear.php.net
# pear upgrade pear
# pear install -f -a DB_DataObject DB_DataObject_FormBuilder MDB2 Numbers_Roman \
Numbers_Words HTML_Common HTML_QuickForm HTML_QuickForm_advmultiselect \
HTML_Table Auth_SASL HTTP Image_Canvas Image_Color Image_Graph \
Image_GraphViz Net_Traceroute Net_Ping Validate XML_RPC SOAP
Install optional packages, not required
PHPMyAdmin - web based Mysql console
# apt-get install phpmyadmin
JOE - Text editor
# apt-get install joe
Install Centreon
Download latest version of Centreon, http://www.centreon.com/Download/Download.html
By the time of writing the latest version is 1.4.2.6:
# wget http://download.centreon.com/centreon/centreon-1.4.2.6.tar.gz
Uncompress the archive
# tar xzvf centreon-1.4.2.6.tar.gz
Create symbolic link for nagios2, Centreon installation requires it
# ln -s /usr/sbin/nagios2 /usr/sbin/nagios
Run installation script
# cd centreon-1.4.2.6
# bash ./install.sh
Answer questions during install script
Are you sure to continue ?
[y/n], default to [n]: y
Were is installed Nagios ?
default to [/usr/local/nagios]: /usr/lib/cgi-bin/nagios2
Were is your nagios etc directory ?
default to [/usr/lib/cgi-bin/nagios2/etc]: /etc/nagios2
Were is your nagios var directory ?
default to [/usr/lib/cgi-bin/nagios2/var]: /var/lib/nagios2
Were is your nagios plugins (libexec) directory ?
default to [/usr/lib/cgi-bin/nagios2/libexec]: /usr/lib/nagios/plugins
Were is your nagios bin directory ?
default to [/usr/lib/cgi-bin/nagios2/bin]: /usr/sbin
Were is your nagios image directory ?
default to [/usr/lib/cgi-bin/nagios2/share/images]: /usr/share/nagios/htdocs/images/logos
Where do I install centreon ?
default to [/usr/local/centreon]: /usr/local/centreon
Do you want me to create this directory [/usr/local/centreon]?[Y/n] y
Where is sudo configuration file?
default to [/etc/sudoers]: /etc/sudoers
Where is installed RRD perl modules [RRDs.pm] ?
Just put directory, not full path.
default to [/usr/local/rrdtool/lib/perl]: /usr/lib/perl5
Where is rrdtool binary ?
default to [/usr/bin/rrdtool]: /usr/bin/rrdtool
Where is mail binary ?
default to [/usr/bin/mail]: /usr/bin/mail
Where is PEAR Path ?
default to [/usr/share/pear]: /usr/share/php
Do you want to install Centreon Plugins ?
[y/n], default to [y]: y
Do you want to install Centreon Traps Plugins ?
[y/n], default to [y]: y
Where is your SNMP configuration file?
default to [/etc/snmp/]: /etc/snmp
You already seem to have installed the plugins Centreon.
Do you want overwrite this file ? You must regenerate this one from Centreon interface.
[y/n], default to [n]: y
Specify user do you use for Centreon cron
Default to [nagios]
Apply writing permissions for plugins directory:
# chmod 775 /usr/lib/nagios/plugins
Restart Mysql server
# invoke-rc.d mysql restart
Restart Apache web server
# invoke-rc.d apache2 restart
Finalize the installation with the Centreon Web interface:
open in webrowser: http:///centreon/
replace with your server ip address or hostname.
Follow Centreon Setup instructions:
- Press Start
- Check "I Accept" and press Next
- Make sure that selected "Nagios Version" is "2.x", then press Next
- On next 2 screens, make sure that all components status is "OK", then press Next
- If everything is ok, then press Next again
- Fill required DB info, then press Next
· Root Password for MySQL: [Enter your DB root password]
· Centreon Database Name: centreon
· Centreon Data Storage Database Name: centreon_ods
· 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.
- 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"
Fix paths to meet Nagios installation on Debian based distributions:
Login to Centreon Interface
Go to: Options -> Centreon -> General Options -> Nagios
Change settings to some options, as writed below:
Init Script: /etc/init.d/nagios2
Directory + Binary: /usr/sbin/nagios2
Press Save
Go to: Configuration -> Nagios -> CGI CFG, Press on Edit Icon
Change settings to some options, as writed below:
Physical HTML Path: /usr/share/nagios2/htdocs
URL HTML Path: /nagios2
Nagios Process Check Command: /usr/lib/nagios/plugins/check_nagios /var/cache/nagios2/status.dat 5 '/usr/sbin/nagios2'
Press Save
Go to: Configuration -> Nagios -> Nagios CFG, Press on Edit Icon
Change settings to some options, as writed below:
Log File: /var/log/nagios2/nagios.log
Temp File: /var/cache/nagios2/nagios.tmp
P1 File: /usr/lib/nagios2/p1.pl
Object Cache File: /var/cache/nagios2/objects.cache
Status File: /var/cache/nagios2/status.dat
Log Archive Path: /var/log/nagios2/archives/
Downtime File: /var/lib/nagios2/downtime.dat
Comment File: /var/lib/nagios2/comment.dat
Lock File: /var/run/nagios2/nagios2.pid
State Retention File: /var/lib/nagios2/retention.dat
Performance Data Processing Option: Yes
Service Performance Data Processing Command: process-service-perfdata
Press Save
Go back to terminal console, then...
Apply permissions, so Web interface can also send External Commands
# chmod g+rx /var/lib/nagios2/rw/
Also change ownership of nagios archive logs directory
# chown nagios:adm /var/log/nagios2/archives
Enable Centreon Data Storage (ods) deamon:
# update-rc.d ods defaults
Add htaccess user for nagios CGI:
# htpasswd -bc /etc/nagios2/htpasswd.users nagiosadmin P@ssw0rd
Reboot Server
# sync;sync;init 6
Start adding Hosts, Services, Contacts, Commands, Escalations...
Open Centreon web interface and Login
Start adding hosts, services, users
Restart Nagios to apply the changes, go to: Configuration -> Nagios
Select as writed below:
- Include Comments: Yes
- Run Nagios debug (-v): Yes
- Run Optimisation test (-s): Yes
- Move Export Files: Yes
- Restart Nagios: Yes, Restart
Press Export
This will restart Nagios & apply all changes you made in Web Interface.
You will do it every time you make changes like adding/modifying: hosts, commands, contacts, services...etc...etc...

1 comment:

TeamGeek said...

Just go to http://www.dlightdaily.com , download fullyautomatednagios - ready made nagios iso. Installation guide also available there.