Tuesday, 13 September 2016

Step by Step Nagios Core installation in Centos

Nagios is one of the User friendly monitoring tool and it is a boon for devops to monitor the servers.Around 60% users were using nagios world wide.Nagios Core, is a free and open source computer-software application that monitors systems, networks and infrastructure.It states on all sorts of hosts, and one of its primary advantages is that the configuration can be as simple or as complex as required.

  • Nagios offers monitoring and alerting services for servers, switches, applications and services. 
  • Nagios was originally designed to run under Linux, but it also runs well on other Unix variants.
  • Nagios will send PING requests to the hosts and will notify us when it fails.
  • It alerts users when things go wrong and alerts them a second time when the problem has been resolved.
  • Nagios will collect the slave data through NRPE.
  • Default Update interval for Nagios core is 90 Seconds.
  • Alert states - OK,WARNING,CRITICAL,UNKNOWN.

Prerequisites:

Package requirements may vary depending on what type of installation platform Nagios is being installed.

# yum install wget httpd php
# yum install gcc glibc glibc-common
# yum install gd gd-devel make net-snmp
# yum install openssl-server openssl-devel

Download Nagios Core and Plugins:

Note: Please find the latest stable version from the below link,

Download link for Nagios core:
http://www.nagios.org/download/core/thanks/?t=1385616648

Download link for Nagios plugins:

http://www.nagios.org/download/plugins


Extract the tar files:

# mkdir ~/Downloads &&  cd ~/Downloads
# tar xzf nagios-*.tar.gz
# tar xzf nagios-plugins-*.tar.gz

Creating the Nagios User and Group:-

 i) Create a new nagios user account and a new nagcmd group
ii) Add both the nagios user and the apache user to the group

# useradd nagios
# groupadd nagcmd
# usermod -a -G nagcmd nagios

Nagios Core Installation:

# cd ~/Downloads/nagios*

Run the Nagios configure script:

# ./configure --with-nagios-user=nagios --with-nagios-group=nagcmd

Compile the Nagios source code:

# make all

Install binaries, init script, sample config files:

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

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

# make install-webconf

Create a Default User for Web Access:

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin


Nagios Plugin Installation:

# cd ~/Downloads/nagios-plugins*

Compile and install the plugins:

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

Install the Nagios Plugins:

# make
# make install


Copy the Event handlers and change the permissions to nagios user:

# cp -R contrib/eventhandlers/ /usr/local/nagios/libexec/
# chown -R nagios:nagios /usr/local/nagios/libexec/eventhandlers

Set the system to startup nagios and httpd at startup time:

# chkconfig nagios --level 235 on
# chkconfig httpd --level 235 on

Verify the sample Nagios configuration files:

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

Note:

To avoid “Error: Could not open command file ‘/var/nagios/rw/nagios.cmd’ for update!”

# chown nagios.nagcmd /usr/local/nagios/var/rw
# chmod g+rwx /usr/local/nagios/var/rw
# chmod g+s /usr/local/nagios/var/rw
# usermod -G nagcmd apache

If it is seems to be ok ,then start Nagios and httpd:

# /etc/init.d/httpd start
# /etc/init.d/nagios start

Nagios Web Interface

http://localhost/nagios/

If you able to load the above url,then you have successfully installed nagios core.

5 comments: