Skip to content

how to setup nagios on Linux

May 18, 2010

Here with a simple instructions on how to install Nagios on Fedora , Redhat and Centos (Linux Based Distro) and have it monitoring your local machine.

Nagios is very easy to setup and monitor.

We would require the following packages to install Nagios.

# yum -y install httpd* ( To install Apache)
# yum -y install php* (To install PHP)
# yum -y install gcc, yum -y install gcc-c++, yum -y install glibc (To Install GCC )
# yum -y install gd gd-devel (To Install GD)

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

# wget

# wget

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

# cd /tmp
# 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 /tmp
# 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

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. 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)

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.

For more Infotmation Click here World Of Information.


From → Linux

Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: