Nagios Tutorials

Continuous Monitoring

Continuous Monitoring

What is Continuous Monitoring?

Continuous Monitoring is the process and technology used to detect compliance and risk issues associated with an organization’s financial and operational environment. The financial and operational environment consists of people, processes, and systems working together to support efficient and effective operations.

Continuous Monitoring refers to the process and technology required to incorporate monitoring across each phase in DevOps and IT operation lifecycles. It helps to continuously ensure the health performance, and reliability of your application and infrastructure as it moves from development to production.

Why we need Continuous Monitoring?

Continuous Monitoring assists IT organizations, DevOps teams in particular, with procuring real-time data from public environments. It also helps general feedback on the overall IT setup, including offsite network and deployed software.

What Are Continuous Monitoring Tools?

  • Lansweeper
  • Spiceworks
  • Snort
  • SolarWinds
  • Nagios
  • Tenable
  • Ipswich WhatsUp Gold
  • Paessler PRTG
  • Rapid7 Insight
  • Cisco Identity Service Engine

Let us Discuss Nagios

What is Nagios?

Nagios is used for continuous monitoring of system applications, services, and business processes, etc in a DevOps culture. Nagios runs on a server, usually as a daemon or a service. It periodically runs plugins residing on the same server, contact hosts or servers on your network or the internet.

Nagios is used as an infrastructure monitoring tool. Nagios is the most powerful infrastructure monitoring. Nagios was first launched on March 14, 1999, and formerly known as Netsaint.

How Nagios Works?

Nagios is an open-source computer software application which monitors computer systems, network and entire IT infrastructure. It was designed to run on the Linux operating system and can monitor devices running Linux, Windows, and Unix operating systems. Nagios software runs periodic checks on critical parameters of applications, network and server resources.

For the Nagios, we have to install Nagios server in any of one server we have install Nagios. And rest of all how many servers we have to monitor through the Nagios we have to install into that has an NRP.

Nagios act as apparent and NRP act as a child. Through Nagios its monitors all the child servers.

What is the Purpose of Nagios?

Nagios offers to monitor and altering services for servers, switches, applications, and services. It alerts users when the thing goes wrong and alerts them a second time when the problem has been resolved.

From 2018 companies reportedly use Nagios in their tech stacks, including Uber, Twitch, and Dropbox.

Nagios Structure?

A user can choose to work in a command-line interface (CLI) or select a web based graphical user interface (GUI) in some versions of Nagios and from third parties. Nagios dashboard provides an overview of the critical parameters monitored assets.

Based on the parameters and thresholds defined, Nagios can send out alerts if critical is reached. These notifications can be sent in different ways, including email and text messages.

Nagios Installation on Ubuntu

Nagios installation has been divided into three parts.

  1. Installing Nagios on Master
  2. Installing NRPE on slave
  3. Installing Check NRPE Plugin on Master

Green Terminal is Master, Yellow Terminal is Slave machine.

Nagios Installation 1

Nagios Installation 2

Install Nagios on Master

Step 1: Update the master.

The Command is sudo apt-get update

Output Is:

Nagios Installation Step-1

Step 2: Run the following command

sudo apt-get install wget build-essential unzip openssl libssl-dev

Output Is:

Nagios Installation Step-2

Step 3: Run the following command

sudo apt-get install apache2 php libapache2-mod-php php-gd libgd-dev

Output Is:

Nagios Installation Step-3

Step 4: Now, add the user with the commands given below.

sudo adduser nagios

In this command, it asks to enter a password. Give whatever password you want. It helps to view the Nagios on the web-page.

Nagios Installation Step-4

In the above image add Full Name as your wish. And remaining information as same.

Step 5: Run the following commands to complete the user adding process.

sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data

Output Is:

Nagios Installation Step-5

Step 6: Now that we are set with the prerequisites, install Nagios Core as shown below.

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.2.tar.gz

Output Is:

Nagios Installation Step-6

Step 7: Untar the file with the command shown below.

tar xzf nagios-4.4.2.tar.gz

Step 8: Enter the Nagios-4.4.2 directory.

The Command is cd nagios-4.4.2

Output Is:

Nagios Installation Step-8

Step 9: Now with the given command make the required configurations.

sudo ./configure –with-command-group=nagcm

Output Is:

Nagios Installation Step-9

Now we will make all the configuration work.

Step 10:

sudo make all

Output Is:

Nagios Installation Step-10

Step 11: Run the following command.

sudo make install

Output Is:

Nagios Installation Step-11

Step 12: Install init and run the following command.

sudo make install-init

Output Is:

Nagios Installation Step-12

Step 13: Install config and run the following command.

sudo make install-config

Output Is:

Nagios Installation Step-13

Step 14: Install command mode as shown below:

sudo make install-commandmode

Output Is:

Nagios Installation Step-14

Step 15: Before moving ahead run the following commands to copy eventhandlers scripts under the libexec directory.

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

Output Is:

Nagios Installation Step-15

Step 16: Create Apache configuration on the nano.

sudo nano /etc/apache2/conf-available/nagios.conf

ScriptAlias /nagios/cgi-bin “/usr/local/nagios/sbin”


Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

Alias /nagios “/usr/local/nagios/share”


Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName “Restricted Area”
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user

Copy the file and past it on nano editor

Output Is:

Nagios Installation Step-16-B

Save the file and exit from the nano editor.

Step 17: Add a password as shown below, to complete the apache configuration. The same password which you gave first.

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

Output Is:

Nagios Installation Step-17

Step 18: Enable Apache configuration.

sudo a2enconf nagios

Output Is:

Nagios Installation Step-18

sudo a2enmod cgi rewrite

Output Is:

Nagios Installation Step-18-B

Step 19: Restart apache service.

sudo service apache2 restart

Output Is:

Nagios Installation Step-19

Step 20: Now go to the main directory.

Cd

Output Is:

Nagios Installation Step-20

Step 21: To install the required Nagios plugin, download the plugins.

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

Output Is:

Nagios Installation Step-21

Step 22: Untar the file.

tar xzf nagios-plugins-2.2.1.tar.gz

Output Is:

Nagios Installation Step-22

Step 23: Go inside Nagios-2.2.1 directory.

cd nagios-plugins-2.2.1

Output Is:

Nagios Installation Step-23

Step 24: Compile the plugins and then complete the plugin installation process running the three commands given below:

sudo ./configure –with-nagios-user=nagios –with-nagios-group=nagios –with-openssl

Output Is:

Nagios Installation Step-24

sudo make

Output Is:

Nagios Installation Step-24-B

sudo make install

Output Is:

Nagios Installation Step-24-C

Before we can start using Nagios, we going to need to make a small change in the base configurations.

Step 25: Go to the main directory.

cd

Output Is:

Nagios Installation Step-25

Step 26: Get inside /usr/local/nagios/etc/nagios.cfg

sudo nano /usr/local/nagios/etc/nagios.cfg
Scroll down until you will see. #cfg_dir=/usr/local/nagios/etc/servers
Remove # from #cfg_dir=/usr/local/nagios/etc/servers

Output Is:

Nagios Installation Step-26

Save and exit the file.

Step 27: Make the following directory.

sudo mkdir /usr/local/nagios/etc/servers

Output Is:

Nagios Installation Step-27

Step 28: Verify the configuration before starting Nagios.

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

Output Is:

Nagios Installation Step-28

Here we can see there are no warnings and no errors. Everything looks fine!

Step 29: Start Nagios.

sudo service nagios start

Output Is:

Nagios Installation Step-29

sudo systemctl enable nagios

Output Is:

Nagios Installation Step-29-B

Installing NRPE on Slave

In the slave machine, we are adding a host in Nagios.

Installing NRPE on the slave

Step 1: Update the slave machine

sudo apt-get update

Output Is:

Nagios on Slave Machine Step-1

Step 2: Install the required plugins.

sudo apt-get install nagios-nrpe-server nagios-plugins

Output Is:

Nagios on Slave Machine Step-2

Step 3: Open the configuration file as shown below:

sudo nano /etc/nagios/nrpe.cfg

In the file allowed_hosts=127.0.0.1,xxx to allowed_hosts=127.0.0.1, master IP.

After made changes save and exit the file.

Output Is:

Nagios on Slave Machine Step-3

Step 4: Start NRPE service as shown below:

sudo /etc/init.d/nagios-nrpe-server restart

Output Is:

Nagios on Slave Machine Step-4

Install Check NRPE on Master

Install check_nrpe on Master

Now we need to install check_nrpe on Master.

Step 1: Update the master machine

sudo apt-get update

Output Is:

Nagios on Master Machine Step-1

Step 2: Install the following package.

sudo apt-get install -y autoconf automake gcc libc6 libmcrypt-dev make libssl-dev wget openssl

Output Is:

Nagios on Master Machine Step-2

Step 3: Get in the tmp

cd /tmp

Output Is:

Nagios on Master Machine Step-3

Step 4: Download the source.

wget –no-check-certificate -O nrpe.tar.gz

https://github.com/NagiosEnterprises/nrpe/archive/nrpe-3.2.1.tar.gz

Output Is:

Nagios on Master Machine Step-4

Step 5: Untar the file.

tar xzf nrpe.tar.gz

Step 6: Then execute the following command.

cd
cd /tmp/nrpe-nrpe-3.2.1
./configure

Output Is:

You will see this output

Nagios on Master Machine Step-6

Step 7: Run the check_nrpe

make check_nrpe

Output Is:

Nagios on Master Machine Step-7

Step 8: Install plugins.

sudo make install-plugin

Output Is:

Nagios on Master Machine Step-8

Step 9: We will check the connection

cd
/usr/local/nagios/libexec/check_nrpe -H

Now we need to make the following configuration file before we observe the connection.

Step 10:

sudo nano /usr/local/nagios/etc/servers/MyHost01.cfg

It will open a nano editor. Copy and paste the below file in the nano editor

#########################################################
# Linux Host 001 configuration file
#########################################################

define host {
uselinux-server
host_nameLinux_Host_001
aliasLinux Host 001
address
register1
}
define service{
host_nameLinux_Host_001
service_descriptionPING
check_commandcheck_ping!100.0,20%!500.0,60%
max_check_attempts2
check_interval2
retry_interval2
check_period24x7
check_freshness1
contact_groupsadmins
notification_interval2
notification_period24x7
notifications_enabled1
register1
}

#########################################################
# END OF FILE
#########################################################

After adding the content, the configuration file should look like this:

Nagios on Master Machine Step-10

Step 11: Now verify the configuration again

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

Output Is:

Nagios on Master Machine Step-11

Here we can see there are no errors and no warnings.

Step 12: Start Nagios

sudo service nagios restart

Output Is:

Nagios on Master Machine Step-12

Installation of Nagios is done. To see the Nagios, go to the web-page

http://MasterIP/nagios/

Output Is:

Output-1

The username should be: nagiosadmin

Password: Which we gave in first

After Sign in you will saw this

Output-2

On the left side, there is a current status part. In that there is a part called, click on the map

Output-3

0 Comments

Submit a Comment

Your email address will not be published. Required fields are marked *