Installing Nagios Monitoring on Ubuntu 24.04

Step by step guide to Installing Nagios Monitoring on Ubuntu 24.04

Installing Nagios Monitoring on Ubuntu 24.04

Nagios is one of the most widely used open-source IT infrastructure monitoring tools that helps organizations ensure their critical systems, applications, and services are running smoothly. It provides administrators with real-time visibility into the health, performance, and availability of their IT environment, enabling proactive identification and resolution of issues before they impact business operations.

At its core, Nagios works by actively monitoring hosts, services, and network devices through plugins that perform checks and return status information. This allows it to track metrics such as CPU usage, memory consumption, disk space, service uptime, network connectivity, and much more. When an issue is detected such as a server going down or a service becoming unresponsive. Nagios can send alerts via email, SMS, or integrated notification systems, ensuring that the right teams are informed immediately.

One of Nagios’ strengths lies in its modular and extensible architecture. It uses plugins for monitoring specific services or metrics, and its functionality can be expanded through add-ons and integrations. For example, administrators can integrate Nagios with ticketing systems, reporting tools, or dashboards for better incident management and visualization.

In addition to monitoring, Nagios provides:

  • Alerting: Immediate notifications when problems occur and when they are resolved.

  • Event Handling: Automated scripts or actions to attempt to fix issues when detected.

  • Performance Graphing & Reporting: Historical data that helps in capacity planning and identifying performance trends.

  • Scalability: Ability to monitor small setups or large, distributed enterprise environments.

By offering a centralized monitoring solution, Nagios helps reduce downtime, improve system reliability, and optimize resource usage. It plays a critical role in IT operations, especially in environments where uptime and service continuity are crucial.

In short, Nagios is both a monitoring framework and a powerful alerting system that empowers organizations to maintain control over their IT infrastructure, from simple servers to complex, multi-tiered networks.

Installing Nagios on Ubuntu 24.04

There are various ways you can install nagios, for learning purposes we are going to compile from the source but I will give the various methods either way.

1. Installing from Source (Manual Compilation)

  • How: Download Nagios Core source code, compile, and configure manually.

  • Advantages:

    • Full control over configuration and customization.

    • Access to the latest version and features.

    • Good for learning how Nagios works internally.

  • Disadvantages:

    • Time-consuming setup process.

    • Requires Linux administration skills.

    • More effort to maintain and upgrade.

2. Installing via Package Manager (APT/YUM/DNF)

  • How: Use system package managers (apt, yum, or dnf) to install prebuilt Nagios packages.

  • Advantages:

    • Fast and simple installation.

    • Automatic handling of dependencies.

    • Easier updates and security patches.

  • Disadvantages:

    • May not have the latest version.

    • Less flexibility for customization.

3. Using Preconfigured Virtual Machines/Appliances

  • How: Download ready-to-use Nagios VMs or images (e.g., Nagios XI VM, OVA/OVA files).

  • Advantages:

    • Quick deployment (plug-and-play).

    • Preconfigured with plugins and web UI.

    • Ideal for testing or proof-of-concept.

  • Disadvantages:

    • Limited control over base OS.

    • May use more resources than a minimal install.

    • Updates depend on the appliance provider.

4. Using Docker Containers

  • How: Run Nagios inside a Docker container with official or community images.

  • Advantages:

    • Lightweight and portable.

    • Easy to spin up, scale, or destroy environments.

    • Isolated from the host system.

  • Disadvantages:

    • Requires Docker knowledge.

    • Persistent storage and networking need extra configuration.

    • Some plugins may not work seamlessly in containerized environments.

Installing from Source (Manual Compilation)

As elaborated earlied, this is the best way to make sure you are getting the latest version.

First let's make sure our system packages are up to date:

sudo apt update

The next step is to install the required built tools and development environment libraries

apt install autoconf \
    gcc \
    libc6 \
    make \
    wget \
    unzip \
    apache2 \
    apache2-utils \
    php \
    libapache2-mod-php \
    libgd-dev \
    libssl-dev -y

Now let's download nagios from the source. As of the time of writing this. The latest version for nagios core was version 4.5.9 : Nagios Core

First on your terminal, set the version with the following command:

VER=4.5.9

Then Use wget to extract the file from nagios source tarball:

wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-${VER}.tar.gz

then extract the source archive:

tar xzf nagios-${VER}.tar.gz

When you you check in your current directory, you should be able to see the extracted nagios directory

Now let's navigate into the nagios directory and begin the installation

cd nagios-${VER}

Now you can Configure Nagios to use Apache as the web server. Use the --with-httpd-conf to specify where to install Nagios Server Apache site configs.

./configure --with-httpd-conf=/etc/apache2/sites-enabled

As you can see, everything looks ok. Now let's compile the nagios program and the CGIs:

make all

If there are no errors, you can proceed to create Nagios user and group.

sudo make install-groups-users
sudo usermod -aG nagios www-data

Let's now install Nagios server and all the required files:

sudo make install

And now the startup scrips:

sudo make install-init

Now let's install and configure permissions on the directory, initialize the init scripts and install nagios in the appropriate directory:

sudo make install-commandmode
sudo make install-daemoninit
sudo make install-config

This should be your output:

Now let's finalize all the apache configurations:

sudo make install-webconf
sudo a2enmod rewrite cgi
sudo a2dissite 000-default.conf

Now let's configure the login details for Nagios: you can change nagiosadmin to your preferred admin account:

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

Running Nagios Service

Fist let's make sure nagios starts on reboot then restart nagios:

sudo systemctl enable --now nagios
sudo systemctl restart nagios
systemctl status nagios

You should see nagios running:

Let's restart and enable the webserver then allow firewall for apache2:

sudo systemctl restart apache2
sudo systemctl enable apache2
sudo ufw allow Apache

Nagios is currently accessible but before we do that, let's first install Nagios Server plugins in order to start monitoring hosts:

sudo apt install monitoring-plugins

Let's update the nagios plugins to use the required directory:

sudo vim /usr/local/nagios/etc/resource.cfg

Let's create a sym link before reloading nagios services:

sudo ln -s /usr/lib/nagios/plugins/* /usr/local/nagios/libexec/
sudo systemctl reload nagios.service

Now you can be able to access Nagios using the default server IP of domain name you assigned to it

What's Your Reaction?

like

dislike

love

funny

angry

sad

wow