Nagios Tutorial - DevOps Courses and Certification (2024)

Continuous Monitoring

Nagios Tutorial - DevOps Courses and Certification (1)

What is Continuous Monitoring?

Continuous Monitoring is the process and technology used to detectcompliance and risk issues associated with an organization’sfinancial and operational environment. The financial and operationalenvironment consists of people, processes, and systems workingtogether to support efficient and effective operations.

Continuous Monitoring refers to the process and technology requiredto incorporate monitoring across each phase in DevOps and IToperation lifecycles. It helps to continuously ensure the healthperformance, and reliability of your application and infrastructureas it moves from development to production.

Why we need Continuous Monitoring?

Continuous Monitoring assists IT organizations, DevOps teams inparticular, with procuring real-time data from public environments.It also helps general feedback on the overall IT setup, includingoffsite 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. Nagiosruns on a server, usually as a daemon or a service. It periodicallyruns plugins residing on the same server, contact hosts or serverson your network or the internet.

Nagios is used as an infrastructure monitoring tool. Nagios is themost powerful infrastructure monitoring. Nagios was first launchedon March 14, 1999, and formerly known as Netsaint.

How Nagios Works?

Nagios is an open-source computer software application which monitorscomputer systems, network and entire IT infrastructure. It wasdesigned to run on the Linux operating system and can monitordevices running Linux, Windows, and Unix operating systems. Nagiossoftware runs periodic checks on critical parameters ofapplications, network and server resources.

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

Nagios act as apparent and NRP act as a child. Through Nagios itsmonitors 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 goeswrong and alerts them a second time when the problem has beenresolved.

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 selecta web based graphical user interface (GUI) in some versions ofNagios and from third parties. Nagios dashboard provides an overviewof the critical parameters monitored assets.

Based on the parameters and thresholds defined, Nagios can send outalerts if critical is reached. These notifications can be sent indifferent 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 Tutorial - DevOps Courses and Certification (2)

Nagios Tutorial - DevOps Courses and Certification (3)

Install Nagios on Master

Step 1: Update the master.

The Command is sudo apt-get update

Output Is:

Nagios Tutorial - DevOps Courses and Certification (4)

Step 2: Run the following command

sudo apt-get install wget build-essential unzip openssllibssl-dev

Output Is:

Nagios Tutorial - DevOps Courses and Certification (5)

Step 3: Run the following command

sudo apt-get install apache2 php libapache2-mod-php php-gdlibgd-dev

Output Is:

Nagios Tutorial - DevOps Courses and Certification (6)

Step 4: Now, add the user with the commands givenbelow.

sudo adduser nagios

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

Nagios Tutorial - DevOps Courses and Certification (7)

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

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

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (8)

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

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (9)

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 Tutorial - DevOps Courses and Certification (10)

Step 9: Now with the given command make the requiredconfigurations.

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (11)

Now we will make all the configuration work.

Step 10:

sudo make all

Output Is:

Nagios Tutorial - DevOps Courses and Certification (12)

Step 11: Run the following command.

sudo make install

Output Is:

Nagios Tutorial - DevOps Courses and Certification (13)

Step 12: Install init and run the following command.

sudo make install-init

Output Is:

Nagios Tutorial - DevOps Courses and Certification (14)

Step 13: Install config and run the followingcommand.

sudo make install-config

Output Is:

Nagios Tutorial - DevOps Courses and Certification (15)

Step 14: Install command mode as shown below:

sudo make install-commandmode

Output Is:

Nagios Tutorial - DevOps Courses and Certification (16)

Step 15: Before moving ahead run the followingcommands 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 Tutorial - DevOps Courses and Certification (17)

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 Tutorial - DevOps Courses and Certification (18)

Save the file and exit from the nano editor.

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

sudo htpasswd -c /usr/local/nagios/etc/htpasswd.usersnagiosadmin

Output Is:

Nagios Tutorial - DevOps Courses and Certification (19)

Step 18: Enable Apache configuration.

sudo a2enconf nagios

Output Is:

Nagios Tutorial - DevOps Courses and Certification (20)

sudo a2enmod cgi rewrite

Output Is:

Nagios Tutorial - DevOps Courses and Certification (21)

Step 19: Restart apache service.

sudo service apache2 restart

Output Is:

Nagios Tutorial - DevOps Courses and Certification (22)

Step 20: Now go to the main directory.

Cd

Output Is:

Nagios Tutorial - DevOps Courses and Certification (23)

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

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (24)

Step 22: Untar the file.

tar xzf nagios-plugins-2.2.1.tar.gz

Output Is:

Nagios Tutorial - DevOps Courses and Certification (25)

Step 23: Go inside Nagios-2.2.1 directory.

cd nagios-plugins-2.2.1

Output Is:

Nagios Tutorial - DevOps Courses and Certification (26)

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

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (27)

sudo make

Output Is:

Nagios Tutorial - DevOps Courses and Certification (28)

sudo make install

Output Is:

Nagios Tutorial - DevOps Courses and Certification (29)

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

Step 25: Go to the main directory.

cd

Output Is:

Nagios Tutorial - DevOps Courses and Certification (30)

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 Tutorial - DevOps Courses and Certification (31)

Save and exit the file.

Step 27: Make the following directory.

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (32)

Step 28: Verify the configuration before startingNagios.

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (33)

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

Step 29: Start Nagios.

sudo service nagios start

Output Is:

Nagios Tutorial - DevOps Courses and Certification (34)

sudo systemctl enable nagios

Output Is:

Nagios Tutorial - DevOps Courses and Certification (35)

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 Tutorial - DevOps Courses and Certification (36)

Step 2: Install the required plugins.

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (37)

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 toallowed_hosts=127.0.0.1, master IP.

After made changes save and exit the file.

Output Is:

Nagios Tutorial - DevOps Courses and Certification (38)

Step 4: Start NRPE service as shown below:

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

Output Is:

Nagios Tutorial - DevOps Courses and Certification (39)

Nagios Tutorial - DevOps Courses and Certification (2024)
Top Articles
Latest Posts
Article information

Author: Patricia Veum II

Last Updated:

Views: 5833

Rating: 4.3 / 5 (64 voted)

Reviews: 87% of readers found this page helpful

Author information

Name: Patricia Veum II

Birthday: 1994-12-16

Address: 2064 Little Summit, Goldieton, MS 97651-0862

Phone: +6873952696715

Job: Principal Officer

Hobby: Rafting, Cabaret, Candle making, Jigsaw puzzles, Inline skating, Magic, Graffiti

Introduction: My name is Patricia Veum II, I am a vast, combative, smiling, famous, inexpensive, zealous, sparkling person who loves writing and wants to share my knowledge and understanding with you.