How to Install Nagios on EC2

black and gray laptop computer turned on doing computer codes
Reading Time: 4 minutes

Hello Readers, In this blog, we’ll learn about Nagios which is an open-source monitoring system for computer systems also we’ll see how to install Nagios on EC2, and what Nagios Dashboard looks like.

What is Nagios?

  • Nagios is basically a tool that is used for continuous monitoring of systems, applications, services, business processes, etc in DevOps culture.
  • In the event of failure, Nagios can alert technical staff of the problem allowing them to begin remediation processes before outages affect the business process, end-users or customers.

History of Nagios

  • In the year 1999, Ethan galstad developed it as a part of Netscaint distribution.
  • The year 2002, Ethan renames the project “Nagios” because of trademark issues with the name “Netsaint”.
  • In 2009, Nagios releases its first commercial version, Nagios XI.
  • In 2012, Nagios was again renamed as Nagios Core.

Pre-requisite

To start Nagios core installation you must have your EC2 instance up and running and have already configured SSH and HTTP access to the instance.

so Install pre-requisite software on your ec2 machine prior to Nagios installation like apache, PHP, gcc and gd development libraries.

httpd:-Browser

php:- for dashboard

gcc and gd:- compiler to convert row code into binaries

Installation

step 1 :

installing apache , PHP, GCC compiler and gd development libraries

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

Step 2 :

Create account information you need to set up a Nagios user , Run the following command

adduser -m nagios 

passwd nagios

Now,it asks you to enter the password to your user Nagios

I have given atisha12345 as a password of my user Nagios, it could be anything of your choice.

you can add the group as well by following the given command below.

groupadd nagioscmd 
usermod -a -G nagioscmd nagios

Step 3 :

Download Nagios Core and the plugins, Create a directory for storing the downloads

mkdir ~/Nagios
cd ~/Nagios

now download the source code tarball of both Nagios and the Nagios plugins.

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.0.8.tar.gz

wget http://nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz

Here we are downloading the nagios 4.0.8 version

Step 4 :

Compile and install Nagios and extract the Nagios source code tarball

tar zxvf nagios-4.0.8.tar.gz 

cd nagios-4.0.8

Run the configuration script with the name of the group which you have created in the above steps

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

compile the Nagios source code

Install Binaries ,init script in /lib/systemd/system,sample config files in usr/local/nagios/etc, and set permission on the external command directly.

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

Step 5 :

Configuring the web interface

make install-webconf

Step 6 :

Create a ‘nagiosadmin’ account for login into the Nagios web interface

set password as well

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

asking for password, set a new password

Step 7 :

Compile and install the Nagios plugins and extract the Nagios plugins source code tarball.

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

Now, compile and install the plugins

/configure --with-nagios-user=nagios --with-nagios-group=nagios 

 make all

make install

Step 8 :

Start Nagios and add nagios to the list of system services and have it automatically start when the system boots.

chkconfig --add nagios 

 chkconfig nagios on

Varify the sample nagios configuration files by using the command given below

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

if there are no errors in your configuration file then start the Nagios.

Step 10

Copy public IP of your EC2 instance and paste it on google in given way

for instance :- 20.1.1.1/nagios/

after all it’ll ask for username and password

and finally you will be able to access your nagios dashboard.

Reference

https://www.nagios.org/documentation/

https://blog.knoldus.com/devops-infrastruture-monitoring-with-nagios/

In conclusion

In conclusion, we’ve learned about what is Nagios monitoring tool , how to install Nagios on EC2 instances, and how to access the dashboard of Nagios.

knoldus

Leave a Reply