Back to Blogs
#monitoring#linux#devops#networking

Installing Nagios on Ubuntu 24.04

Nagios Core is an open-source monitoring tool for networks, services, and applications, using the...

3 min read
Cover for Installing Nagios on Ubuntu 24.04

Nagios Core is an open-source monitoring tool for networks, services, and applications, using the NRPE agent to collect metrics (disk, CPU, network) from remote hosts and report them on a web dashboard. This guide compiles Nagios Core from source on Ubuntu 24.04, installs plugins, and configures it to monitor a separate remote host.

Prerequisites: two Ubuntu 24.04 servers — one for Nagios, one as the monitored remote host.


Compile and Install Nagios Core

Not packaged for Ubuntu — build from source.

$ sudo apt install -y autoconf gcc libc6 make wget unzip apache2 php libapache2-mod-php libgd-dev openssl libssl-dev
$ cd
$ mkdir nagios-core
$ cd nagios-core
Enter fullscreen mode Exit fullscreen mode

Check the releases page for the current version:

$ wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.5.7.tar.gz
$ tar xzf nagioscore.tar.gz
$ ls
$ cd nagioscore-nagios-4.5.7/
$ sudo ./configure --with-httpd-conf=/etc/apache2/sites-enabled
$ sudo make all
$ sudo make install-groups-users
$ sudo usermod -a -G nagios www-data
Enter fullscreen mode Exit fullscreen mode

Install Nagios and Apache Config

$ sudo make install
$ sudo make install-daemoninit
$ sudo make install-commandmode
$ sudo make install-config
$ sudo make install-webconf
$ sudo a2enmod rewrite
$ sudo a2enmod cgi
Enter fullscreen mode Exit fullscreen mode

Create the dashboard login user:

$ sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
$ sudo systemctl restart apache2
Enter fullscreen mode Exit fullscreen mode

Install Nagios Plugins

$ sudo apt install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
$ cd
Enter fullscreen mode Exit fullscreen mode

Check the plugins releases page for the current version:

$ wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.4.12.tar.gz
$ tar zxf nagios-plugins.tar.gz
$ cd nagios-plugins-release-2.4.12
$ sudo ./tools/setup
$ sudo ./configure
$ sudo make
$ sudo make install
Enter fullscreen mode Exit fullscreen mode

Validate config and start:

$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
$ sudo systemctl enable nagios
$ sudo systemctl start nagios
Enter fullscreen mode Exit fullscreen mode

Expect Total Warnings: 0 / Total Errors: 0.


Access the Dashboard

$ sudo ufw status
$ sudo ufw allow ssh && sudo ufw enable
$ sudo ufw allow 80/tcp
$ sudo ufw reload
Enter fullscreen mode Exit fullscreen mode

Visit http://SERVER-IP/nagios, log in as nagiosadmin. Hosts in the sidebar shows localhost by default — remote hosts come next.


Set Up the Remote Host

On the remote host:

$ sudo apt install nagios-plugins nagios-nrpe-server -y
$ sudo systemctl enable --now nagios-nrpe-server
$ sudo nano /etc/nagios/nrpe.cfg
Enter fullscreen mode Exit fullscreen mode
allowed_hosts=127.0.0.1,::1,nagios_server_IP
Enter fullscreen mode Exit fullscreen mode

Replace nagios_server_IP with your Nagios server's actual IP.

$ sudo systemctl restart nagios-nrpe-server
Enter fullscreen mode Exit fullscreen mode

Configure the Nagios Server to Watch It

On the Nagios server:

$ sudo mkdir -p /usr/local/nagios/etc/servers/
$ sudo nano /usr/local/nagios/etc/servers/host.cfg
Enter fullscreen mode Exit fullscreen mode
define host {
        use                             linux-server
        host_name                       remote-app-01
        alias                           First Remote Host
        address                         remote-host-ip
        max_check_attempts              5
        check_period                    24x7
        notification_interval           30
        notification_period             24x7
}
Enter fullscreen mode Exit fullscreen mode

Replace host_name and address with your actual remote host name and IP.

$ sudo nano /usr/local/nagios/etc/nagios.cfg
Enter fullscreen mode Exit fullscreen mode

Append:

cfg_dir=/usr/local/nagios/etc/servers
Enter fullscreen mode Exit fullscreen mode
$ sudo systemctl restart nagios
$ sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
$ sudo systemctl restart nagios
Enter fullscreen mode Exit fullscreen mode

Reload http://SERVER-IP/nagios → Hosts — the remote host now appears alongside localhost.


Next Steps

Nagios is monitoring both the local server and a remote host over NRPE. From here:

  • Install NRPE on additional hosts and add matching host.cfg entries to scale monitoring out
  • Configure notification contacts (email, etc.) so alerts actually reach someone
  • Add service checks (disk, CPU, custom scripts) beyond the default host checks

For the full guide, visit the original article on Vultr Docs.