Home Tool Instructions for installing Nagios on Ubuntu 22.04

Instructions for installing Nagios on Ubuntu 22.04

by Lê Quyền
Published: Last Updated on
A+A-
Reset

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
    
CleanShot 2024 01 05 at 23.31.12

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
    
CleanShot 2024 01 05 at 23.42.45

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
    
CleanShot 2024 01 05 at 23.44.29

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

CleanShot 2024 01 06 at 08.13.16

Next, adjust the file configuration resource.cfg

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

CleanShot 2024 01 06 at 08.14.38

Next findobjects/contacts.cfg Edit email contact.

CleanShot 2024 01 06 at 08.15.36

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$
}
CleanShot 2024 01 06 at 08.17.47

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
CleanShot 2024 01 06 at 08.21.58

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:

Đánh giá

Tham gia nhóm hỗ trợ Server - Hosting

Tham gia nhóm Hỗ trợ Server - Hosting & WordPress để cùng nhau hỏi đáp và hỗ trợ các vấn đề về WordPress, tối ưu máy chủ/server.

Tham gia ngay

Bài viết cùng chuyên mục

AZDIGI – Không chỉ là đơn vị hàng đầu trong lĩnh vực Web Hosting và Máy chủ, chúng tôi mong muốn mang lại những kiến thức bổ ích nhất và luôn cập nhật thường xuyên cho cộng đồng người đam mê thiết kế website, công nghệ,…

Vui lòng không sao chép nội dung nếu chưa xin phép. Designed and Developed by PenciDesign