Nagios monitoring tool installation and configuration


Nagios is an open source computer system monitor, network monitoring and infrastructure monitoring software applications. Nagios offers monitoring and alerting for servers, switches, applications, and services.

It alerts users when things go wrong and alerts them again when the problem has been resolved.

Nagios was originally designed to run under Linux, but also runs well on other Unix variants and can monitor Windows, Linux/Unix/BSD, Netware and network devices.

It is a free software licensed under the term of the GNS General Public License verstion 2.

Before going for installation, please make sure your Apache and Postfix servers are up and running.

Prerequisites

Verify whether gcc is installed

[root@server.local ~]# rpm -qa | grep gcc
gcc-3.4.6-8
compat-gcc-32-3.2.3-47.3
libgcc-3.4.6-8
compat-libgcc-296-2.96-132.7.2
compat-gcc-32-c++-3.2.3-47.3
gcc-c++-3.4.6-8

•Verify whether GD is installed

[root@server.local ~]# rpm -qa gd
gd-2.0.28-5.4E

Step 1: Create user and group for nagios

[root@server.local ~]# useradd nagios
[root@server.local ~]# passwd nagios
[root@server.local ~]# groupadd nagcmd
[root@server.local ~]# usermod -G nagcmd nagios
[root@server.local ~]# usermod -G nagcmd apache

Step 2: Install nagios

[root@server.local ~]# tar xvf nagios-3.5.1.tar.gz
[root@server.local ~]# cd nagios-3.5.1
[root@server.local ~]# ./configure --with-command-group=nagcmd
[root@server.local ~]# make all
[root@server.local ~]# make install
[root@server.local ~]# make install-init
[root@server.local ~]# make install-config
[root@server.local ~]# make install-commandmode

Following are some additional parameters that you can pass to ./configure to customize your installation. I used only –with-command-group as shown above.

--prefix /opt/nagios Where to put the Nagios files
--with-cgiurl /nagios/cgi-bin Web server url where the cgi's will be available
--with-htmurl /nagios Web server url where nagios will be available
--with-nagios-user nagios user account under which Nagios will run
--with-nagios-group nagios group account under which Nagios will run
--with-command-group nagcmd group account which will allow the apache user to submit commands to Nagios

At the end of the configure output, it will display a summary as shown below:

*** Configuration summary for nagios 3.5.1 05-28-2012 ***:

General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /etc/rc.d/init.d
Apache conf.d directory: /etc/httpd/conf.d
Mail program: /bin/mail
Host OS: linux-gnu

Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP): /bin/traceroute

Step 3: Configure the web interface

[root@server.local ~]# make install-webconf
[root@server.local ~]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin

Step 4: Compile and install nagios plugins

[root@server.local ~]# tar xvf nagios-plugins-1.4.11.tar.gz
[root@server.local ~]# cd nagios-plugins-1.4.11
[root@server.local ~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
[root@server.local ~]# make
[root@server.local ~]# make install

if you get redhat-pthread-workaround error then enter the below command

[root@server.local ~]# ./configure --with-nagios-user=nagios --with-nagios-group=nagios --enable-redhat-pthread-workaround

Step 4: Start Nagios daemon

[root@server.local ~]# chkconfig --add nagios
[root@server.local ~]# chkconfig nagios on

Verify to make sure there are no errors in the nagios configuration file

[root@server.local ~]# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check

Start the nagios

[root@server.local ~]# /etc/init.d/nagios start

Step 5: Login to web interface

Nagios Web URL: http://localhost/nagios/

Use the userid, password that was created from step#3 above.

Step 6: Mail id configuration

The first configuration to modify is to change the default value of email address in /usr/local/nagios/etc/objects/contacts.cfg file to your email address.

define contact{
contact_name nagiosadmin ; Short name of user
use generic-contact ; Inherit default values from generic-contact template (defined above)
alias Nagios Admin ; Full name of user
email yourname@yourdomainname.com ; CHANGE THIS TO YOUR EMAIL ADDRESS
}

Now reload your nagios to apply changes by command

[root@server.local ~]# /etc/init.d/nagios reload

Leave a comment

Leave a comment