Nagios Tutorial for Beginners – Continuous Monitoring With Nagios


Nagios now known as Nagios Core, is a free and open-source computer-software application that monitors systems, networks and infrastructure. Nagios offers monitoring and alerting services for servers, switches, applications and services. It alerts users when things go wrong and alerts them a second time when the problem has been resolved.

Nagios monitors your entire IT infrastructure to ensure systems, applications, services, and business processes are functioning properly. It is integral to the DevOps lifecycle and is a must for DevOps Certification. In this Nagios tutorial, I will be covering the below topics:

  1. What Is Continuous Monitoring?
  2. Why We Need Continuous Monitoring?
  3. What Is Nagios?
  4. How To Install Nagios?

Let’s begin this Nagios tutorial, by understanding why we need Continuous Monitoring because everything exists for a reason. So, let’s try to find out that reason.

What is Continuous Monitoring?

Continuous monitoring is a process to detect, report, respond all the attacks which occur in its infrastructure. Once the application is deployed into the server, the role of Continuous Monitoring comes in to play. The entire process is all about taking care of the company’s infrastructure and respond appropriately.


Continuous Monitoring is actually not new, it’s been around for some time. For years our security professionals are performing static analysis from – system log, firewall logs, IDS logs, IPS logs etc. But, it did not provide proper analysis and response. Today’s Continuous Monitoring approache gives us the ability to aggregate all of the events that I discussed above, co-relate them, compare them and then estimate the organization’s risk posture.

If we take all these pieces and ensure the interlinking between them. This is the crux of Continuous Monitoring.

Yeah, it does a lot of cool work, but why we need it?

Why We Need Continuous Monitoring?

Continuous Monitoring Tools resolve any system errors ( low memory, unreachable server etc. ) before they have any negative impact on your business productivity.

Important reasons to use a monitoring tool are

  • It detects any network or server problems
  • It determines the root cause of any issues
  • It maintains the security and availability of the service
  • It monitors and troubleshoot server performance issues
  • It allows us to plan for infrastructure upgrades before outdated systems cause failures
  • It can respond to issues at the first sign of a problem
  • It can be used to automatically fix problems when they are detected
  • It ensures IT infrastructure outages have a minimal effect on your organization’s bottom line
  • It can monitor your entire infrastructure and business processes

Next up in this Nagios tutorial, I will be introducing you to one of the most famous monitoring tool Yeah you guessed it it’s ‘Nagios’.

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.


I also need to explain you NRPE (Nagios Remote Plugin Executor).

The NRPE addon is designed to allow you to execute Nagios plugins on remote Linux/Unix machines. The main reason for doing this is to allow Nagios to monitor “local” resources (like CPU load, memory usage, etc.) on remote machines. Since these public resources are not usually exposed to external machines, an agent like NRPE must be installed on the remote Linux/Unix machines.

Features of Nagios
  • 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

Now in this Nagios tutorial, it is time for some Hands-on

Let’s start by installing Nagios Core

Install Nagios Core

Following are steps to setup Nagios on Ubuntu.

Before you install Nagios, some packages such as Apache, PHP, building packages etc., are required to be present on your Ubuntu system. Hence, let us install them first.

Step 1 ? Run the following command to install pre-required packages ?

sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd
libgd-dev sendmail unzip

Step 2 ? Next, create user and group for Nagios and add them to Apache www-data user.

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

Step 3 ? Run the following command to install pre-required packages ?

sudo apt-get install wget build-essential apache2 php apache2-mod-php7.0 php-gd
libgd-dev sendmail unzip

Step 4- Extract the tarball file

tar-xzf nagios-4.4.3.tar.gz
cd nagios-4.4.3/

Step 5 - Run the following command to compile Nagios from source


Step 6 ? Run the following command to build Nagios files ?

make all

Step 7 ? Run the command shown below to install all the Nagios files.

sudo make install

Step 8 ? Run the following commands to install init and external command configuration files

sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo/usr/bin/install-c-m 644 sample-config/httpd. conf/etc/apache2/sitesavailable/

Step 9 - Now copy the event handler directory to Nagios directory

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

Step 10 ? Download and extract Nagios plugins

cd wget
tar -xzf nagios-plugins*.tar.gz
cd nagios-plugins-2.2.1/

Step 11 ? Install Nagios plugins using the below command.

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

Step 12 Now edit the Nagios configuration file and uncomment line number 51 ? cfg_dir=/usr/local/nagios/etc/servers

sudo gedit /usr/local/nagios/etc/nagios.cfg

Step 13 ? Now, create a server directory.

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

Step 14 ? Edit contacts configuration file

gedit /usr/local/nagios/etc/

Step 15 ? Now enable the Apache modules and configure a user nagiosadmin.

sudo a2enmod rewrite
sudo a2enmod cgi
sudo htpasswd -c/usr/local/nagios/etc/htpasswd.
users nagiosadmin
ln -s/etc/apache2/sites-available/nagios.

Step 16 ? Now, restart Apache and Nagios.

service apache2 restart
service nagios start
sudo cp/etc/init.d/skeleton/etc/init.d/

Step 17 ? Edit the Nagios file

sudo gedit/etc/init.d/Nagios DESC=“Nagios” NAME=nagios DAEMON=
/usr/local/nagios/bin/$NAME DAEMON_ARGS =
“-d /usr/local/nagios/etc/nagios.cfg” PIDFILE =

Step 18 ? Make the Nagios file executable and start Nagios.

sudo chmod +x/etc/init.d/nagios
service apache2 restart
service nagios start

Step 19 ? Now go to your browser and open url ? http://localhost/nagios. Now login to Nagios with username nagiosadmin and use the password which you had set earlier. The login screen of Nagios will be shown.

If you have followed all the steps correctly, you Nagios web interface will show up.

Application of Nagios

Nagios 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)

Disadvantages of Using Nagios

  • Important feature 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


  • Continuous Monitoring is a process to detect, report, respond all the attacks which occur in its infrastructure
  • Nagio is free to use open source software tool for continuous monitoring
  • Nagio offers effective monitoring of your entire infrastructure and business processes
  • Ethan Galstad uses the ideas and architecture of his earlier work to begin building a new application Nagios which runs under Linux OS
  • Nagios is relatively scalable, Manageable, and Secure
  • Three important components of Nagios architecture are 1) Web Interface (GUI) 2)Nagios Server 3)Plugin
  • Nagios allows application monitoring from a single console with transaction-level insights
  • This tool not allows you to manage the network but only allows to monitor the network

Continuous Monitoring"> Mildaintrainings offers DevOps Certification Training Program will provide you with in-depth knowledge of various DevOps tools including Git , Jenkins , Docker , Ansible , Puppet ,Kubernetes and Nagios . This training is completely hands-on and designed in a way to help you become a certified practitioner through best practices in Continuous Development, Continuous Testing, Configuration Management and Continuous Integration, and finally, Continuous Monitoring of software throughout its development life cycle. Enroll & Get Certified now

Drop us a Query

About the author



The author has a keen interest in exploring the latest technologies such as AI, ML, Data Science, Cyber Security, Guidewire, Anaplan, Java, Python, Web Designing tools, Web Development Technologies, Mobile Apps, and whatnot. He bags over a decade of experience in writing technical content.

whatsapp arrow