Monday, April 4, 2022

Module 28: Nagios – Continuous Monitoring

 What is Nagios?

Nagios is used for Continuous monitoring of systems, applications, services, and business processes etc in a DevOps culture. In the event of a failure, Nagios can alert technical staff of the problem, allowing them to begin remediation processes before outages affect business processes, end-users, or customers. With Nagios, you don’t have to explain why an unseen infrastructure outage affect your organization’s bottom line.

Nagios runs on a server, usually as a daemon or a service.

It periodically runs plugins residing on the same server, they contact hosts or servers on your network or on the internet. One can view the status information using the web interface. You can also receive email or SMS notifications if something happens.
The Nagios daemon behaves like a scheduler that runs certain scripts at certain moments. It stores the results of those scripts and will run other scripts if these results change.

Plugins: These are compiled executables or scripts (Perl scripts, shell scripts, etc.) that can be run from a command line to check the status or a host or service. Nagios uses the results from the plugins to determine the current status of the hosts and services on your network.

Let’s now discuss it’s architecture.

Nagios Architecture:

  • Nagios is built on a server/agents architecture.
  • Usually, on a network, a Nagios server is running on a host, and Plugins interact with local and all the remote hosts that need to be monitored.
  • These plugins will send information to the Scheduler, which displays that in a GUI

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
Installation of Nagios on EC2

Spin two Servers ( Amazon Linux 2 AMI) ready for this demo 
Do the following command on Nagios Master 

yum install httpd php gcc glibc glibc-comman gd gd-devel make net-snmp unzip -y

wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.3.2/nagios-4.3.2.tar.gz

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

tar -zxvf nagios-4.3.2.tar.gz

tar -zxpvf nagios-plugins-2.2.1.tar.gz

useradd nagios

passwd nagios

groupadd nagcmd

usermod -G nagcmd nagios

usermod -G nagcmd apache

cd nagios-4.3.2

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

 make all

 make install

 make install-init

 make install-commandmode

 make install-config

 make install-webconf

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

 systemctl restart httpd

 cd ..

 cd nagios-plugins-2.2.1/

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

 make

 make install

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

 systemctl enable  nagios

 systemctl start  nagios

 systemctl restart httpd

systemctl restart  nagios

open the browser http://ip address/nagios

uid:nagiosadmin(set in the previous steps)

pwd: nagios


cd /usr/local/nagios/ ls cd etc/

vi nagios.cfg

# then uncomment this line /usr/local/nagios/etc/servers



mkdir servers cd servers/ ls hostname vi ip-172-31-21-155.ec2.internal.cfg
cat /usr/local/nagios/etc/objects/localhost.cfg
#copy the above file into ip-172-31-21-155.ec2.internal.cfg and replace servers address with master private ip address and localhost with private dns of the master server

systemctl restart nagios



On Nagios Host (linux):

rpm -ivh https://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm

yum install nrpe nagios-plugins-all -y

vim /etc/nagios/nrpe.cfg

# enter edit model by pressing i and replace the server ip with with the node private ip and Host ip with Nagios Master with the private ip


and master ip with private ip

systemctl enable nrpe

systemctl start nrpe

let do some exercise by installing LAMP on the Host 

sudo yum update -y

sudo amazon-linux-extras install -y lamp-mariadb10.2-php7.2 php7.2

cat /etc/system-release

sudo yum install -y httpd mariadb-server

yum info package_name

sudo systemctl start httpd

sudo systemctl enable httpd

sudo systemctl is-enabled httpd

#log into the master server with the following

cd /

cd var 

cd log

 cat yum.log

No comments:

Post a Comment

Module 34: Understanding Terraform

  Terraform is a platform-agnostic tool that allows you to build, change, and version infrastructure securely and efficiently. Terraform is ...