0% found this document useful (0 votes)
13 views

Nagios

A guy walks into a store and buys balenciaga, you think that of me

Uploaded by

moyowib961
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Nagios

A guy walks into a store and buys balenciaga, you think that of me

Uploaded by

moyowib961
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 27

Mahavir Education Trust's

SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,


Chembur, Mumbai - 400 088

proficient with Cloud based DevOps solution deployment options to meet your business
requirements, To use Continuous Monitoring Tools to resolve any system errors (low
memory, unreachable server etc.) before they have any negative impact on the business
productivity.

Theory:
What is Nagios?
Nagios is an open-source software for continuous monitoring of systems, networks, and
infrastructures. It runs plugins stored on a server which is connected with a host or another
server on your network or the Internet. In case of any failure, Nagios alerts about the issues so
that the technical team can perform recovery process immediately. Nagios is used for
continuous monitoring of systems, applications, service, and business process in a DevOps
culture.

Why We Need Nagios tool?


Here are the important reasons to use Nagios monitoring tool:
• Detects all types of network or server issues

• Helps you to find the root cause of the problem which allows you to get the permanent
solution to the problem
• Active monitoring of your entire infrastructure and business processes
• Allows you to monitor and troubleshoot server performance issues

• Helps you to plan for infrastructure upgrades before outdated systems create failures
• You can maintain the security and availability of the service

• Automatically fix problems in a panic situation History of Nagios


• 1996-Ethan Galstad uses the ideas and architecture of his earlier work to begin building
a new application which runs under Linux OS

• 1999-The plugins that were which were originally distributed as a part of the
NetSaint distribution are soon as a separate Nagios Plugins project
• 2002-Ethan renames the project to “Nagios” because of trademark issues with the
name “NetSaint.”
• 2005- Nagios becomes SourceForge.net Project of the Month in June
• 2009-Nagios Enterprises releases its first commercial version, Nagios XI
• 2012-Nagios again renamed as Nagios Core
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

• 2016-Nagios core surpasses 7,500,000 downloads directly from SourceForge.net website


Features of Nagios
Following are the important features of Nagios monitoring tool:
• Relatively scalable, Manageable, and Secure
• Good log and database system

• Informative and attractive web interfaces


• Automatically send alerts if condition changes

• If the services are running fine, then there is no need to do check that host is an alive
• Helps you to detect network errors or server crashes
• You can troubleshoot the performance issues of the server.

• The issues, if any, can be fixed automatically as they are identified during the monitoring
process
• You can monitor the entire business process and IT infrastructure with a single

pass •The product’s architecture is easy writing new plugins in the language of

your choice
• Nagios allows you to read its configuration from an entire directory which helps you to
decide how to define individual files
• Utilizes topology to determine dependencies

• Monitor network services like HTTP, SMTP, HTTP, SNMP, FTP, SSH, POP, etc.
• Helps you to define network host hierarchy using parent hosts
• Ability to define event handlers which runs during service or host events for proactive
problem resolution

• Support for implementing redundant monitoring hosts


Nagios Architecture
Nagios is a client-server architecture. Usually, on a network, a Nagios server is running on a
host, and plugins are running on all the remote hosts which should be monitored.
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Nagios Architecture
1. The scheduler is a component of server part of Nagios. It sends a signal to execute the
plugins at the remote host.
2. The plugin gets the status from the remote host
3. The plugin sends the data to the process scheduler
4. The process scheduler updates the GUI and notifications are sent to admins
Plugins
Nagios plugins provide low-level intelligence on how to monitor anything and everything
with Nagios Core. Plugins operate acts as a standalone application, but they are designed to
be executed by Nagios Core. It connects to Apache that is controlled by CGI to display the
result.
Moreover, a database connected to Nagios to keep a log file.
How do plugins work
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Consider the above example:


• Check_nt is a plugin to monitor a windows machine which is mostly available in the
monitoring server
• NSClinet++ should be installed in every Windows machine that you wants to monitor
• There is an SSL connection between the server and the host which continuously
exchange information with each other
Likewise, NRPE (Nagios Remote plug-in Executor) and NSCA plugins are used to monitor
Linux and Mac OS X respectively.
Application of Nagios
Nagios application monitoring tool is a health check & monitoring system for a

typical Data Centre, comprises all type of equipment’s such as:


• Server & Network Nodes
• Application monitoring from a single console
• Application Monitoring with transaction-level insights

• Monitor Middleware & Messaging Components


• Customizable Reports and Dashboards

• UPS Backup System


• Bio-Metric Identification System
• Temperature & Humidity Control System (Sensing Mechanism)

• CCTV/NVR System
• Storage Subsystem (NAS&SAN)
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Disadvantages of Using Nagios


• Important features like wizards or interactive dashboard are only available on Nagios XI,
which is quite an expensive tool
• Nagios core has a confusing interface

• There’re many configuration files which are very hard to configure for users
• Nagios can’t monitor network throughput

• The tool not allows you to manage the network but only allows to monitor the network

• Nagios makes no difference between various devices like servers, routers, or switches as it
treats every device as a host

Conclusion: Continuous monitoring is a process to detect, report, respond all the attacks which
occur in its infrastructure. Nagios offers effective monitoring of your entire infrastructure and
business processes.
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Experiment No: 10
Date of 25/09/2023
Performance:
Date of 3/10/2023
Submission:
Program
formation/ Documentation Timely Viva Experiment Teacher
Execution/ (02) Submission Answer Marks (15) Signature
ethical (03) (03) with date
practices (07)

Name: Siddhesh Ganesh Chavan


Department: IT
TE 5
Roll No.: 9

Experiment No 10
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Aim: To perform Port, Service monitoring, Windows/Linux server monitoring using


Nagios.

Lab Outcome No.: ITL504.1, ITL504.5

Lab Outcome: To understand the fundamentals of Cloud Computing and be fully


proficient with Cloud based DevOps solution deployment options to meet your
business requirements and to use Continuous Monitoring Tools to resolve any system
errors (low memory, unreachable server etc.) before they have any negative impact on
the business productivity.

Theory:
Nagios is a powerful open-source monitoring system that allows you to monitor the
availability and performance of various network services, hosts, and resources,
including both Windows and Linux servers. Here's a step-by-step guide on how to set
up Port and Service monitoring and Windows/Linux server monitoring using Nagios:

Before you begin, make sure you have a Linux server or VM where you'll install
Nagios.

1. Install and Configure Nagios:

- Install a Linux distribution (e.g., CentOS, Ubuntu) on your monitoring server.


- Install Nagios Core using your system's package manager or by compiling from
source. You can find installation instructions for your specific distribution on the
Nagios website.

2. Install Required Dependencies:

Nagios requires several packages to be installed, such as Apache, PHP, and other
plugins. You can install them using your package manager.

- On Ubuntu:
bash
sudo apt-get install apache2 php libapache2-mod-php
sudo apt-get install build-essential libgd2-xpm-dev openssl libssl-dev xinetd

- On CentOS:
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

bash
sudo yum install httpd php gcc glibc glibc-common gd gd-devel
sudo yum install openssl-devel perl unzip xinetd

3. Configure Apache:
You need to configure Apache to serve the Nagios web interface. Edit the Apache
configuration file:

sudo nano /etc/httpd/conf.d/nagios.conf

Add the following lines:


ScriptAlias /nagios/cgi-bin "/usr/local/nagios/sbin"
<Directory "/usr/local/nagios/sbin">
Options ExecCGI
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Alias /nagios "/usr/local/nagios/share"


<Directory "/usr/local/nagios/share">
Options None
AllowOverride None
Order allow,deny
Allow from all
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
Require valid-user
</Directory>

Create the user for web interface access:


sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

4. Configure Nagios:

- Define hosts, services, and commands in the Nagios configuration files located in
`/usr/local/nagios/etc/`. You can customize these files based on your requirements.

5. Port and Service Monitoring:


To monitor ports and services on remote hosts, you can define service checks in your
Nagios configuration files. For example, to monitor an SSH service on a remote
Linux server, you can add a service definition like this:
define service {
host_name your_server
service_description SSH
check_command check_ssh
}

6. Windows Server Monitoring:

To monitor Windows servers, you can use NSClient++ or NRPE (Nagios Remote
Plugin Executor) as agents on the Windows servers. This allows Nagios to execute
checks on the Windows machines.

- Install NSClient++ on Windows servers and configure it to accept commands from


your Nagios server.
- Define service checks for Windows-specific metrics like CPU usage, memory, and
disk space.

7. Restart Services:

After making any configuration changes, restart the Nagios service and the web
server:
sudo systemctl restart nagios
sudo systemctl restart httpd

8. Access the Nagios Web Interface:

Open a web browser and access your Nagios web interface at


`http://your_server/nagios`. Log in using the username and password you created
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

earlier.

9. Monitor and Customize:


From the web interface, you can monitor the status of your services and hosts.
Customize your Nagios configuration and add more checks as needed.
That's a basic overview of setting up port and service monitoring and Windows/Linux
server monitoring using Nagios. You can expand and fine-tune your configuration to
meet your specific monitoring requirements.

Output:
$ sudo apt update

$sudo apt install wget unzip curl openssl build-essential libgd-dev


libssl-dev libapache2-mod-php php-gd php apache2 -y
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

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

$sudo tar -zxvf nagios-4.4.6.tar.gz

$cd nagios-4.4.6
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$ sudo ./configure
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$sudo make all


Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$ sudo make install-groups-users

$ sudo make install


Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$sudo make install-init

$
sudo make install-commandmode
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$ sudo make install-config

$ sudo make install-webconf

$ sudo a2enmod rewrite


Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

$ sudo a2enmod cgi

$ sudo systemctl restart apache2


$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users admin

2. Install Nagios Plugins

Download the Nagios Core plugin. To download the latest plugins, visit
the plugins download page.

$ cd ~/

$ wget https://nagios-plugins.org/download/nagios-plugins-
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

2.3.3.tar.gz

Extract the downloaded plugin.

$ sudo tar -zxvf nagios-plugins-2.3.3.tar.gz

Navigate to the plugins' directory.

$ cd nagios-plugins-2.3.3/

Run the plugin configure script.

$ sudo ./configure --with-nagios-user=nagios --with-nagios-


group=nagios
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Compile Nagios Core plugins.

$ sudo make

Install the plugins.

$ sudo make install

3. Verify Nagios Configuration


Verify the Nagios Core configuration.
$ sudo /usr/local/nagios/bin/nagios -v
/usr/local/nagios/etc/nagios.cfg
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Start the Nagios service.

$ sudo systemctl start nagios


Enable Nagios service to run at system startup.

$ sudo systemctl enable nagios

Access Nagios Web Interface


Open your web browser and access Nagios web interface via the URL
http://ServerIP/nagios. For example:

http://192.0.2.10/nagios

You have successfully installed Nagios Core on your server. To log in,
use admin as your username and the password you set during the user
account creation step as your password. You can now access the dashboard
and begin configuring Nagios.
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Add Remote Hosts

Now that your Nagios server is configured, it's time to configure a


remote host to monitor.

To get started, connect as root over SSH to the host you want to
monitor.
Install Prerequisites

To monitor hosts, we need to add them to Nagios. By default, Nagios only


monitors localhost (the server it's running on). We're going to add
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

hosts that are part of our network to gain even more control. You will
need to use the following instructions on all hosts that you want to
monitor.

First, install nagios-plugins and nagios-nrpe-server:

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

Configure NRPE

Next, open the /etc/nagios/nrpe.cfg file. Replace the value of


allowed_hosts with 127.0.0.1,0.0.0.0 replacing the second IP with the IP
address of the Nagios server.

We will now open the file /etc/nagios/nrpe.cfg and replace a couple of


values.

Replace the value of server_address to the private IP address of the


host.

Set allowed_hosts to the private IP address of your Nagios server.

Execute df -h /, copy the output, and put that as the value of


command. It indicates your root file system.

Save the file when you are finished.

Now restart NRPE:

service nagios-nrpe-server restart

Add the Host to Nagios

Now that we've configured the host we're going to monitor, we need to
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

switch back to our Nagios server and add the host to it. Open the
following file with your favorite editor:

# nano /usr/local/nagios/etc/objects/windows.cfg

Use the following block as a template. Replace host with an appropriate


name for your remote host, and update the host_name, alias, and address
values accordingly.

define host {

use linux-server

host_name yourhost

alias My first Apache server

address 1.2.3.4 //ipv4 adddress

max_check_attempts 5

check_period 24x7

notification_interval 30

notification_period 24x7

This will allow you to simply monitor whether the server is up or down.
Now reload Nagios:
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

# service nagios reload

Congratulations, you have completed a very basic Nagios setup for


monitoring your servers. Now you can log into the Nagios web panel to
view the status of your servers.

#sudo nano /usr/local/nagios/etc/cgi.cfg


Change nagios.admin to admin
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088
Mahavir Education Trust's
SHAH & ANCHOR KUTCHHI ENGINEERING COLLEGE,
Chembur, Mumbai - 400 088

Conclusion:Thus we have successfully implemented and perform Port, Service


monitoring, Windows/Linux server monitoring using Nagios

You might also like