❤️ AZDIGI has officially updated to a new blog system. However, some posts may have incorrect or mismatched images. Please click the Report article button at the bottom of the post so AZDIGI can update as quickly as possible. Thank you!

Nagios is a popular open source monitoring system used to monitor IT infrastructure and services in server, network, application and device environments. Developed by Ethan Galstad in 1999, Nagios has become one of the leading monitoring tools in the world and is widely used in the enterprise and user community.

I. Main features of Nagios

  1. Flexible architecture: Nagios uses a modular architecture that allows integration with many plugins and addons, helping to expand monitoring capabilities according to the specific needs of the environment.
  2. Diverse monitoring: Nagios can monitor everything from servers , networks, applications to services running on the system. It is capable of checking parameters such as the health of hard drives, memory, CPU, network, services like HTTP, SMTP, SSH, and more.
  3. Notifications and warnings: Nagios has the ability to warn administrators through many means such as email, SMS, and other notification channels when detecting problems or exceeding set thresholds.
  4. Web interface: Provides a beautiful and easy-to-use web interface for status viewing, reporting, and monitoring system management.
  5. Extensive integration: Nagios supports integration with many other technologies through the use of plugins and APIs, helping to integrate with other solutions such as ticketing systems, dashboards, or automated configuration management systems.
  6. Strong community development: The Nagios user community is large and active, which means there is plenty of documentation, plugins and support available online.

Nagios has developed and added many versions and expansion modules over time to meet the increasingly diverse requirements of the information technology environment.

II. How to install Nagios on Ubuntu 22.04

Step 1: Update system g

Before proceeding with the installation, it is necessary to update the system packages to ensure you have the latest software version. Open a terminal and run the following lines of code:

AZDIGI Tutorial
apt update && apt upgrade -y
    

Step 2: Install necessary packages

Now install the necessary packages using apt :

AZDIGI Tutorial
sudo apt install wget unzip apache2 php libapache2-mod-php php-gd libgd-dev libapache2-mod-php php-mbstring php-xml libssl-dev build-essential libssl-dev libgd-dev
    

Step 3: Download Nagios Core

We will download Nagios and extract it.

AZDIGI Tutorial
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar -xzf nagios-4.4.6.tar.gz
cd nagios-4.4.6
    

Step 4: Compile and install Nagios Core

Create users and groupsnagios . This command will create the usernagios , groupnagcmd , and addnagios into both groupsnagcmd andwww-data .:

AZDIGI Tutorial
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -aG nagcmd nagios
sudo usermod -aG nagcmd www-data
    

Run the following command to compile Nagios source code and install.

AZDIGI Tutorial
./configure --with-httpd-conf=/etc/apache2/sites-enabled
make all
sudo make install
sudo make install-init
sudo make install-daemoninit
sudo make install-config
sudo make install-commandmode
sudo make install-exfoliation
sudo make install-webconf
    

Below is a brief explanation for each command during the Nagios installation process:

  1. ./configure --with-httpd-conf=/etc/apache2/sites-enabled: Prepare configuration for the compilation process, configure it so that Apache can understand and integrate Nagios. Option--with-httpd-conf Specifies where Apache’s configuration files are stored.
  2. make all: Compile Nagios source code and accompanying components.
  3. sudo make install: Install Nagios on the system.
  4. sudo make install-init: Install the init file to manage the Nagios service when the system starts.
  5. sudo make install-daemoninit: Install init script to manage Nagios Daemon (main platform of Nagios).
  6. sudo make install-config: Installs default configuration files for Nagios.
  7. sudo make install-commandmode: Set the execution mode for Nagios command files.
  8. sudo make install-exfoliation: Install necessary files for Nagios web interface.
  9. sudo make install-webconf: Install Apache configuration to be able to access the Nagios web interface.

Step 5: Create a user and password for Nagios

You use the following command to create an administrative user and password.

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

Step 6: Install Nagios Plugins and NRPE Plugins

To extend the monitoring capabilities of Nagios, we need to install Nagios Plugins and NRPE Plugin

AZDIGI Tutorial
apt install monitoring-plugins nagios-nrpe-plugin -y
    

Step 7: Configure Nagios Plugins and NRPE Plugins

After installing Nagios Plugins and NRPE Plugins, navigate to the /usr/local/nagios/etc directory. Create a folder named “servers” .

AZDIGI Tutorial
cd /usr/local/nagios/etc/
mkdir servers
    

Next use the vim or nano editor to edit the file:nagios.cfg .

Remove # from line cfg_dir=/usr/local/nagios/etc/servers

Next, adjust the file configuration resource.cfg

Add the following parameter: $USER1$=/usr/lib/nagios/plugins , to specify the Nagios Monitoring Plugin path

Next findobjects/contacts.cfg Edit email contact.

Finally openobjects/commands.cfg Add the following content at the end of the configuration file.

define command{
        command_name check_nrpe
        command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Step 8: Open port on Firewall

AZDIGI Tutorial
sudo ufw enable
sudo ufw allow 80
sudo ufw allow 443
sudo ufw allow 22
sudo ufw reload
sudo ufw status
    

Step 8: Start Apache and Nagios

AZDIGI Tutorial
sudo a2enmod cgi
sudo systemctl restart apache2
sudo systemctl start nagios
    

Next, everyone accesses the link http://your_ip_server/nagios or http://your_domain/nagios

Instructions for installing Nagios on Ubuntu 22.04

With these steps, you will have successfully deployed Nagios on Ubuntu 22.04, ready to monitor and manage the health of systems and services in your IT environment.

If you need assistance, you can contact support in the ways below:

Share:
This article has been reviewed by AZDIGI Team

About the author

Thạch Phạm

Thạch Phạm

Đồng sáng lập và Giám đốc điều hành của AZDIGI. Có hơn 15 năm kinh nghiệm trong phổ biến kiến thức liên quan đến WordPress tại thachpham.com, phát triển website và phát triển hệ thống.

10+ years serving 80,000+ customers

Start your web project with AZDIGI