Thursday, April 23, 2009

How to setup and configure nagios


Nagios

Nagios is a popular open source computer system and network monitoring software application. It watches hosts and services, alerting users when things go wrong and again when they get better.It allows you to gain insight into your network and fix problems before customers know they even exist. It's stable, scalable, supported, and extensible. Most importantly, it works.

It will do the Comprehensive Network Monitoring in the following

* Windows
* Linux/Unix
* Routers, Switches, Firewalls
* Printers
* Services
* Applications


Installation of Nagios in localhost

Before installing nagios,you have to install the following packages
* Apache
* GCC compiler
* GD development libraries

if you are using rpm based packages,

yum install httpd
yum install gcc
yum install glibc glibc-common
yum install gd gd-devel

If you are using ubuntu,

sudo apt-get install apache2
sudo apt-get install build-essential
sudo apt-get install libgd2-xpm-dev

1) Create Account Information

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

/usr/sbin/useradd -m nagios
passwd nagios

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

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd apache(or www-data)

2) Download Nagios and the Plugins
mkdir ~/downloads
cd ~/downloads

for downloading Nagios click here

or in terminal type the following line

wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.2.tar.gz

Extract the Nagios source code tarball.

tar xvzf nagios-3.0.2.tar.gz

cd nagios-3.0.2

Run the Nagios configure script, passing the name of the group you created earlier like so:

./configure --with-command-group=nagcmd

3) Compile the Nagios source code.

make all

Install binaries, init script, sample config files and set permissions on the external command directory.

make install
make install-init
make install-config
make install-commandmode

4) Configure the Web Interface

Install the Nagios web config file in the Apache conf.d directory.

make install-webconf

Create a nagiosadmin account for logging into the Nagios web interface. Remember the password you assign to this account - you’ll need it later.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
If you want to add more users then

htpasswd /usr/local/nagios/etc/htpasswd.users username

Edit the file in /usr/local/apache/conf/includes/pre_virtualhost_global.conf and append the following line in to the virtual host directories
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

/etc/init.d/apache2 restart(or service httpd restart)

5) Download, Compile and Install the Nagios Plugins

For downloading Nagios-plugins click here

or in terminal we can download using the wget command,its shown below:

wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz

cd ~/downloads
tar xvzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11/

Compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install

6) Start Nagios

Configure Nagios to automatically start when the system boots.

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios configuration files.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

If there are no errors, start Nagios.

/etc/init.d/nagios start (service nagios start)

Add Nagios to the list of system services and have it automatically start when the system boots.

chkconfig --add nagios
chkconfig nagios on

you can check the Nagios in your browser typing the following url:

http://localhost/nagios

You should now be able to access the Nagios web interface at the URL below. You'll be prompted for the username (nagiosadmin) and password you specified earlier.

Installation and configuration of of Nagios with NRPE for both remote hosts and local host will be posted on next session








No comments:

Post a Comment