Install Nagios on CentOS

Posted on Tue 19 April 2011 in CentOS

Install CentOS 5.3 using the Server template.

After you installed the system log in as root and run update the system:

yum update

If the kernel was updated reboot the system.

reboot
Now we have to include the rpmforge repository to install Nagios 3.0.x.
If you are not familiar with installing repostiorys using yum read this.
yum install yum-priorities

Add the priority lines to your repositories.

rpm --import http://dag.wieers.com/rpm/packages/RPM-GPG-KEY.dag.txt

download the rpm including the repository files for your architecture:

wget http://apt.sw.be/redhat/el5/en/i386/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.i386.rpm

or

wget http://apt.sw.be/redhat/el5/en/x86_64/RPMS.dag/rpmforge-release-0.3.6-1.el5.rf.x86_64.rpm

verify the rpm:

rpm -K rpmforge-release-0.3.6-1.el5.rf.*.rpm

Now install the Nagios software:

yum install nagios nagios-plugins nagios-devel nagios-plugins-nrpe

You need to disable SELinux if you want to start nagios or you have to modify the configuration of SELinux. I will only explain the easier way to disable SELinux.

system-config-securitylevel-tui

set the SELinux to warn or disabled.

Allow http traffic to you machine:

system-config-securitylevel-tui

Set the nagiosadmin password:

htpasswd -c /etc/nagios/htpasswd.users nagiosadmin

The username has to be nagiosadmin otherwise you will not have accessrights.

Add Nagios to your runlevels:

chkconfig --levels 35 nagios on

Add httpd to your runlevels:

chkconfig --levels 35 httpd on

Start the two services:

service httpd start
service nagios start

Connect to your Nagios Interface:

http://<ip>/nagios