Install Nagios on AWS EC2 | Configure Host and Service |2021

Nagios Tutorial image

What is Continuous Monitoring?

Continuous Monitoring is the process of continuously keeping the track of all the servers and the applications which are hosted on that server and creating a log out of it. It helps in cases when your application transition from an active to a critical state. Sometimes you are not on the application and in that caseyou can’t check whether your application is up or down. So this work is basically done by the tool which continuously monitors the application whether it is up or down. If there is any performance issues or any non-responsiveness or there is any downtime, all these are monitored by the continuous monitoring tool.

Install Nagios on AWS EC2

Nagios

It is open-source software that helps us in continuous monitoring applications which are running on the remote host. Nagios follows Master-Slave Architecture. There is one server on which Nagios is installed and others are basically normal systems on which applications are running. In order to interact with Nagios Server to services that are running on some other server, we have to install some plugins on that server that wants to get monitored.

Nagios Architecture

  1. Nagios has Master-Slave Architecture.
  2. Nagios is installed on a separate server i.e. Master Server and plugins are installed on the host side which needs to be monitored.
  3. Nagios Master Server sends a signal to Plugins of the host server.
  4. Plugins collect data from host server such as CPU Utilization, Core Utilized and send back to Nagios Master Server.
  5. Then Nagios Master Server Send Status to admin and update Nagios GUI.

Install Nagios on AWS EC2

Steps to Install Nagios on AWS EC2 (Centos)

Use the Below script to install Nagios

sudo su
yum install httpd php -y
yum install gcc glibc glibc-common -y
yum install gd gd-devel -y

adduser -m nagios
passwd nagios

groupadd nagioscmd
usermod -a -G nagioscmd nagios
usermod -a -G nagioscmd apache

mkdir ~/downloads
cd ~/downloads

wget https://webwerks.dl.sourceforge.net/project/nagios/nagios-4.x/nagios-4.0.8/nagios-4.0.8.tar.gz
wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

tar zxvf nagios-4.0.8.tar.gz
cd nagios-4.0.8

./configure --with-command-group=nagioscmd
make all


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

In order to Change Configuration such as email, contact name then edit:

vi /usr/local/nagios/etc/objects/contacts.cfg

In order to configure the web interface.

make install-webconf

Install Nagios on AWS EC2

First set a password for the web Interface and then restart httpd.

htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
service httpd restart

Install Nagios on AWS EC2

Now in order to install Nagios Plugins

cd ~/downloads
tar zxvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3

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


chkconfig --add nagios
chkconfig nagios on

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

service nagios start
service httpd restart
Install Nagios on AWS EC2

Install Nagios on AWS EC2

Add Host & Service in Nagios

1. Copy localhost.cfg file in the server folder

cp objects/localhost.cfg servers/hosts.cfg

2. Replace IP and hostname in host.cfg file using VI editor and comment hostgroup

:%s/127.0.0.1/<Server IP>
%s/localhost/durgesh

Install Nagios on AWS EC2

3. In nagios.cfg file add new line

cfg_file=/usr/local/nagios/etc/servers/hosts.cfg
Install Nagios on AWS EC2

Install Nagios on AWS EC2

If you want to add new service then you can simply add new service in “/usr/local/nagios/etc/servers/hosts.cfg”

Questions

How to change notification interval in Nagios?

In order to change host or service notification Interval, we can add notification_interval and notification_period in host and service.

Install Nagios on AWS EC2

Check_Swap Nagios Example?

Critical if less than 10% of swap is free, warning if less than 20% is free

define service{
   use                   loacl-service
   host_name             durgesh
   service_description   Swap Usage
   check_command         check_local_swap!20!10
   }

Check_tcp Nagios Example?

Check Port 2001 is Up TCP

define service{
   use                      loacl-service
   host_name                durgesh
   service_description      My application [Port 2001]
   check_command            check_tcp!2001
   }

Check_udp Nagios Example?

Check Port 2001 is Up UDP

define service{
   use                      loacl-service
   host_name                durgesh
   service_description      My application [Port 2001]
   check_command            check_udp!2001
   }

For more Blog Related to DevOps Tools Please visit our InfoHubBlog

Hope You Like our Install Nagios on AWS EC2 Blog.  Please Subscribe to our blog for the Upcoming Blog. If you want to visit more such blogs then please visit our Tech Blog.

Reference :

https://assets.nagios.com/downloads/nagioscore/docs/nagioscore/4/en/quickstart.html

Be the first to comment on "Install Nagios on AWS EC2 | Configure Host and Service |2021"

Leave a comment

Your email address will not be published.


*