How to setup Nagios basic configuration from scratch

This setup is intended to provide you with simple instructions on how to install Nagios on Fedora , Redhat and Centos and have it monitoring your local machine. Nagios is very easy to setup and monitor.

We would require the following packages to install Nagios.

Apache --> yum -y install httpd*
PHP --> yum -y install php*
GCC --> yum -y install gcc, yum -y install gcc-c++, yum -y install glibc
GD --> yum -y install gd gd-level

* -y will not prompt you for an yes/no input.

Create a new nagios user account and give it a password.
useradd nagios

Create a new  nag group for allowing external commands to be submitted through the web interface. Add both the nagios user and the apache user to that group.

groupadd nag
usermod -a -G nag nagios
usermod -a -G nag apache

Download nagios tar file along with the plugins



Now go to the folder or directory where you have downloaded the files. In my case it is /root

cd /root
tar xzf nagios-3.2.0.tar.gz
cd nagios-3.2.0
./configure --with-command-group=nag
make all
make install
make install-init
make install-config
make install-commandmode

cd /root
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 install

Now start Nagios and add it to the list of system services.

service nagios start
chkconfig nagios on

We are done with the basic installation of nagios and its corresponding plugins. Now, I will show you how to monitor a group of hosts. I cannot explain you all the configuration files but will try to throw light on those we require. On successful completion of the installation you will find localhost.cfg in the following path.


In short localhost.cfg is used to define the hosts and services that we want to monitor on the host system.(Host system here refers to the one we want to monitor)

open this file and add the following next to host definition lines.

define host{
use linux-server

use - uses the default template defined in templates.cfg
host_name - hostname can be anything
address- address of the host

Now save the file and restart Nagios.
service nagios restart

NOTE: Make sure you dont add anything to this file because if you are new to nagios debugging would be difficult.

Now you can check the output in the browser.

http://localhost/nagios (Create the password using the htpasswd command)

Computer Training

You can see the host that you have mentioned in the localhost.cfg file. You can add any number of hosts and by default it will check whether the host is alive or not using the check_host_alive plug in. If the host is dead it will display in red and you can click on that to see the details. This is the most basic configuration of Nagios one can configure it according to their requirements. There are lot many features which sets nagios apart from the crowd. Go through the official documentation for further information.

No comments: