Skip to content

TechDirectArchive

Hands-on IT, Cloud, Security & DevOps Insights

  • Home
  • About
  • Advertise With US
  • Reviews
  • Contact
  • Toggle search form
Home » Linux » How to Install and Configure Nagios on Ubuntu
  • Test your webcam and microphone before meeting
    How to Test Your Webcam And Microphone Before Meeting Windows
  • oracle q4 earnings are in e28094 but what does it really mean 700x425 1
    How to uninstall Oracle Database 11G or 12c Oracle/MSSQL/MySQL
  • image 64
    How to install Fax Server on a Windows Server Windows
  • Screenshot 2020 11 17 at 12.20.15
    PA Server Monitor Ultra: How to setup PA Server Monitor Reviews
  • SSL on WAMPServer
    Setup VirtualHost with SSL on WAMP Server Linux
  • Veeam V11
    What’s new in Veeam Backup and replication v11? Backup
  • Featured image BSOD
    How to troubleshoot and fix Windows 11 blue screen Windows
  • DUE Deligence vs Due Care
    Relating Due Diligence and Due Care to Veeam Backup and Replication Backup

How to Install and Configure Nagios on Ubuntu

Posted on 21/03/202224/09/2024 Raphael Gab-Momoh By Raphael Gab-Momoh No Comments on How to Install and Configure Nagios on Ubuntu
Feature-image-nagios

Nagios is an open-source monitoring system that is widely used. What’s more, it maintains track of your servers and monitors them so you can be certain that your mission-critical services are up and functioning. In this article, we shall discuss ‘How to Install and Configure Nagios on Ubuntu”. Please see How to install free Hyper-V Server on a VMware Workstation, How to Configure Windows Server Core using SConfig, and “Docker Setup: Monitoring Synology with Prometheus and Grafana“.

Any production environment should employ a monitoring system like Nagios, since by monitoring uptime, CPU consumption, and disk space, you may prevent problems before they happen or before your users call you. Ever wondered how to install Nagios step by step? Here’s all you need to know about the installation process.

In this article, you’ll learn how to install and configure Nagios 4 on Ubuntu so you can use the web interface to monitor host resources. You’ll also install the Nagios Remote Plugin Executor (NRPE), an agent that runs on remote systems and allows you to monitor their resources.

Here are other interesting articles: How to Install and Configure Postfix as a Send-Only SMTP Server/, How to implement SAMBA (SMB) file shares for Servers and Clients/, also How to Configure Advanced PAM in Linux/ and How to Install LAMP Stack on Ubuntu 18.04 / and How to install MariaDB on Ubuntu

Requirements for Installing Nagios on Ubuntu

Make sure you’ve installed the following packages on your Ubuntu installation before continuing.

  • Apache 2
  • PHP
  • GCC compiler and development libraries
  • GD development libraries

You can use apt-get to install these packages by running the following commands:

sudo apt-get install apache2 libapache2-mod-php5 build-essential libgd-dev
How to install and configure Nagios on Ubuntu- 2022-03-20_14h37_23
required packages

Steps to Installing and Configuring Nagios on Ubuntu

The other steps required for the successful installation of Nagios are shown below

Step 1: Create a user account

To create a new account and a password, kindly use the command below.

/usr/sbin/useradd -m -s /bin/bash nagios
passwd nagios
How to install and configure Nagios on Ubuntu-userandpasswd
user & passwd created

Create a new nagcmd group for allowing external commands to be submitted through the web interface. Add both the Nagios user and the apache user to the group.

/usr/sbin/groupadd nagcmd
/usr/sbin/usermod -a -G nagcmd nagios
/usr/sbin/usermod -a -G nagcmd www-data

Step 2: Download Nagios together with its plugin

To this end, make a separate directory where the downloaded packages will be kept.

mkdir ~/downloads
cd ~/downloads

Download the source code tarballs of both Nagios Core and the Nagios plugins

wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-4.2.1.tar.gz
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
How to install and configure nagios on Ubuntu
nagios

The Plugin

how to install and configure nagios on Ubuntu-plugin
nagios plugin

Step 3: Compile and Install Nagios Core on Ubuntu

Meanwhile, extract the Nagios Core source code tarball.

cd ~/downloads
tar xzf nagios-4.2.1.tar.gz
cd nagios-4.2.1

Run the Nagios configure script as follows, using the name of the group you defined previously as a parameter:

./configure --with-command-group=nagcmd
how to install and configure nagios on Ubuntu-config-option-for-nagios
config options for nagios

Then, compile the Nagios Core source code.

make all
makeall-receipt

Consequently, set permissions on the external command directory and install binaries, an init script, and example config files.

make install
make install-init
make install-config
make install-commandmode
boom
external command directory

Here is how to fix “The module ping was not found in configured module paths, core modules are missing“, and how to “Harden your Veeam Backup Server with Microsoft AppLocker“.

Step 4: Customize Configuration

In addition, change the email address associated with the nagiosadmin contact definition to the address you’d want to use for receiving alerts in the /usr/local/nagios/etc/objects/contacts.cfg config file with your favorite editor.

vi /usr/local/nagios/etc/objects/contacts.cfg
email
i changed to my email

Please see Monitor Windows Hosts via Nagios: A Guide, How to Backup and Restore your WordPress Files and Database and how to fix “The module ping was not found in configured module paths, core modules are missing“.

Step 5: Set up the Web User Interface

Moreover, install the Nagios Core web config file in the Apache conf.d directory.

make install-webconf

Possible Error

/usr/bin/install: regular file cannot be created 'etc/apache2/sites-enabled/nagios.conf': File or directory doesn't exist
Makefile:298: failure in the instructions for objective 'install-webconf'
make: *** [install-webconf] Error 1

Resolved by running:

/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/apache2/sites-enabled/nagios.conf
./configure --with-httpd-conf=/etc/apache2/sites-enabled
instll-mkeconf
fixed

Furthermore, to use the Nagios Core web interface, create a nagiosadmin account. But, remember the password you choose for this account; you’ll need it in the future.

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

Restart Apache to make the new settings take effect.

/etc/init.d/apache2 reload

Step 6:  Compile and Install the Nagios Plugins

On the other hand, extract the Nagios plugins source code tarball.

cd ~/downloads
tar xzf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3

Then, compile and install the plugins.

./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
make
make & plugin install

Step7 : Start Nagios Core

Configure Nagios Core to automatically start when the system boots.

ln -s /etc/init.d/nagios /etc/rcS.d/S99nagios

Verify the sample Nagios Core configuration files.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
check
verify

If there are no errors, start Nagios Core.

/etc/init.d/nagios start
startnagios

Step 8: Login to the Web Interface

Type the command below in your VM or environment’s browser. You’ll be prompted for the username (nagiosadmin) and password you specified earlier

http://localhost/nagios/
login
web interface
how to install and configure nagios on Ubuntu-login
logged in

Step 9: Additional Modifications:

If you want to receive email notifications for Nagios Core alerts, you need to install the mailx (Postfix) package.

sudo apt-get install mailx
sudo apt-get install postfix
how to install and configure Nagios on Ubuntu-posfixconfig
postfix
sudo /etc/init.d/nagios restart
how to install and configure Nagios on Ubuntu-postfix

Summary

We installed Nagios by following the series of steps shown above. Rest assured, you will successfully install and configure Nagios on Ubuntu, following the aforementioned steps. Furthermore, you might want to refer to this guide on how to monitor Windows hosts via Nagios

I hope you found this blog post helpful. If you have any questions, please let me know in the comment session.

5/5 - (1 vote)

Thank you for reading this post. Kindly share it with others.

  • Click to share on X (Opens in new window) X
  • Click to share on Reddit (Opens in new window) Reddit
  • Click to share on LinkedIn (Opens in new window) LinkedIn
  • Click to share on Facebook (Opens in new window) Facebook
  • Click to share on Pinterest (Opens in new window) Pinterest
  • Click to share on Tumblr (Opens in new window) Tumblr
  • Click to share on Telegram (Opens in new window) Telegram
  • Click to share on WhatsApp (Opens in new window) WhatsApp
  • Click to share on Pocket (Opens in new window) Pocket
  • Click to share on Mastodon (Opens in new window) Mastodon
  • Click to share on Bluesky (Opens in new window) Bluesky
  • Click to share on Threads (Opens in new window) Threads
  • Click to share on Nextdoor (Opens in new window) Nextdoor
Linux Tags:Monitoring

Post navigation

Previous Post: How to add one or more external displays with your Mac
Next Post: How to Set Up and Configure a Squid Proxy Server

Related Posts

  • sshkey
    How to perform SSH key-based authentication in Linux Linux
  • Locate Find and Grep Required 1
    A Brief Introduction to Linux and How to Create Disk Partition in Ubuntu Linux Linux
  • systemd services
    How to use Systemd Timers on Linux Linux
  • FEATURE ZABBIX
    How to Install Zabbix Monitoring Tool on a Linux System Linux
  • prometheus feature image
    How to use Prometheus for Monitoring Linux
  • Screenshot 2020 05 14 at 18.00.59
    Linux Error 13: Permission denied, are you root Linux

More Related Articles

sshkey How to perform SSH key-based authentication in Linux Linux
Locate Find and Grep Required 1 A Brief Introduction to Linux and How to Create Disk Partition in Ubuntu Linux Linux
systemd services How to use Systemd Timers on Linux Linux
FEATURE ZABBIX How to Install Zabbix Monitoring Tool on a Linux System Linux
prometheus feature image How to use Prometheus for Monitoring Linux
Screenshot 2020 05 14 at 18.00.59 Linux Error 13: Permission denied, are you root Linux

Leave a Reply Cancel reply

You must be logged in to post a comment.

Microsoft MVP

VEEAMLEGEND

vexpert-badge-stars-5

Virtual Background

GoogleNews

Categories

veeaam100

sysadmin top30a
 
  • Test your webcam and microphone before meeting
    How to Test Your Webcam And Microphone Before Meeting Windows
  • oracle q4 earnings are in e28094 but what does it really mean 700x425 1
    How to uninstall Oracle Database 11G or 12c Oracle/MSSQL/MySQL
  • image 64
    How to install Fax Server on a Windows Server Windows
  • Screenshot 2020 11 17 at 12.20.15
    PA Server Monitor Ultra: How to setup PA Server Monitor Reviews
  • SSL on WAMPServer
    Setup VirtualHost with SSL on WAMP Server Linux
  • Veeam V11
    What’s new in Veeam Backup and replication v11? Backup
  • Featured image BSOD
    How to troubleshoot and fix Windows 11 blue screen Windows
  • DUE Deligence vs Due Care
    Relating Due Diligence and Due Care to Veeam Backup and Replication Backup

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 1,841 other subscribers
  • RSS - Posts
  • RSS - Comments
  • About
  • Authors
  • Write for us
  • Advertise with us
  • General Terms and Conditions
  • Privacy policy
  • Feedly
  • Telegram
  • Youtube
  • Facebook
  • Instagram
  • LinkedIn
  • Tumblr
  • Pinterest
  • Twitter
  • mastodon

Tags

AWS Azure Bitlocker Microsoft Windows PowerShell WDS Windows 10 Windows 11 Windows Deployment Services Windows Server 2016

Copyright © 2025 TechDirectArchive

 

Loading Comments...
 

You must be logged in to post a comment.