Wednesday, December 15, 2010

Installing Nagios on CentOS

1. First we make sure these prerequisites are installed and up to date
Run these commands from a command line:
-> yum install httpd
-> yum install gcc
-> yum install glibc glibc-common
-> yum install gd gd-devel

2. Elevate to root
From command line:
-> su -

3. Create a new nagios user account and give it a password
From command line:
-> /usr/sbin/useradd -m nagios
-> passwd nagios
Type the new password twice.

4.Create a new nagcmd group for external commands
From Command line:
-> /usr/sbin/groupadd nagcmd
-> /usr/sbin/usermod -a -G nagcmd nagios
-> /usr/sbin/usermod -a -G nagcmd apache

5. Create a directory to install Nagios
From command line:
-> mkdir downloads
-> cd dowloads/

6. Download source code from
These commands will download version 3.2.0 of the Core Nagios files and version 1.4.13 of the Nagios plugins.
From command line:
-> wget
-> wget

7. Extract and compile nagios-3.0.6.tar.gz
From Command line:
-> tar -xzvf nagios-3.0.6.tar.gz
-> cd nagios-3.0.6
-> ./configure --with-command-group=nagcmd
-> make all
-> make install
-> make install-init
-> make install-config
-> make install-commandmode

8. Edit the /usr/local/nagios/etc/objects/contacts.cfg config file. Change the email address associated with the nagiosadmin contact to the address you'd like to use for receiving alerts.
From command line:
-> vi /usr/local/nagios/etc/objects/contacts.cfg

9. Install the Nagios web config file in the Apache conf.d directory
From command line:
-> make install-webconf

10. Create a nagiosadmin account for logging into the Nagios web interface
From command line:
-> htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

11. Restart Apache
From command line:
-> service httpd restart

12. Compile and Install the Nagios Plugins
From command line:
-> cd downloads/
-> tar xzf nagios-plugins-1.4.11.tar.gz
-> cd nagios-plugins-1.4.11
-> ./configure --with-nagios-user=nagios --with-nagios-group=nagios
-> make
-> make install

13. Add Nagios to the list of system services
From command line:
-> chkconfig --add nagios
-> chkconfig nagios on

14. Check for config errors
From command line:
-> /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

15. Start Nagios
From command line:
-> service nagios start

16. Login to the Web Interface using username (nagiosadmin) and password you specified earlier
From your internet browser navigate to the following URL:

1 comment:

laksh.R said...

Good post on nagios

The nagios-plugins-1.4.11.tar.gz compilation generating error. if you get new version of nagios plugin than the error fixed.


Laxman Singh