In this article, we will have explained the necessary steps to install and configure Nagios on Ubuntu 20.04 LTS. Before continuing with this tutorial, make sure you are logged in as a user with sudo
privileges. All the commands in this tutorial should be run as a non-root user.
Nagios is an open source monitoring tool used to monitor different Linux Machines or different client hosts. It monitors the HTTP, FTP, SSH, SMTP, etc along-with the CPU usage, RAM, Disk Usage, and different process that are being run.
Install Nagios On Ubuntu 20.04
Step 1. First, before you start installing any package on your Ubuntu server, we always recommend making sure that all system packages are updated.
sudo apt update sudo apt upgrade sudo apt install build-essential apache2 php openssl perl make php-gd libgd-dev libapache2-mod-php libperl-dev libssl-dev daemon wget apache2-utils unzip
Step 2. Create User And Group for Nagios.
In order to install Nagios you’ve to create a user and group for it along-with the Apache user with the help of the below commands:
sudo useradd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios sudo usermod -a -G nagcmd www-data
Step 3. Install Nagios Core on Ubuntu.
Now, download the Nagios from the official page or you can get it by the below command through the terminal:
cd /tmp wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz tar -zxvf /tmp/nagios-4.4.5.tar.gz cd /tmp/nagios-4.4.5/
Next, compile Nagios using the following command:
sudo ./configure --with-nagios-group=nagios --with-command-group=nagcmd --with-httpd_conf=/etc/apache2/sites-enabled/ sudo make all sudo make install sudo make install-init sudo make install-config sudo make install-commandmode
Step 4. Configuring Nagios on Ubuntu.
Now we Edit the /usr/local/nagios/etc/objects/contacts.cfg
file and change the email address associated with the nagiosadmin contact definition to the email address you would like to use for receiving alert notification:
sudo nano /usr/local/nagios/etc/objects/contacts.cfg
define contact{ contact_name nagiosadmin ; Short name of user use generic-contact ; Inherit default values from generic-contact template (defined above) alias Nagios Admin ; Full name of user email [email protected] ; <<-- CHANGE THIS TO YOUR EMAIL ADDRESS ****** }
Step 5. Install Nagios Web Interface.
Install the Nagios web interface with the below command:
sudo make install-webconf
Then create a user account as “nagiosadmin” for accessing the Nagios web interface. Make sure to save the password you provided in a safe place or keep in mind as it will be needed later. To do this run the given command:
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin sudo a2enmod cgi
Then, restart the Apache services:
sudo systemctl restart apache2
Step 6. Starting Nagios on Ubuntu.
Double-check the configuration done above by hitting the given command and make sure all configuration pre-checks are okay:
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
And then enable the Nagios services to start at boot:
sudo systemctl enable nagios sudo systemctl start nagios
Step 7. Access Nagios Web Interface.
Now access the Nagios web interface by going following URL in your web browser:
http://your-ip-add-re-ss/nagios/
That’s all you need to do to install Nagios on Ubuntu 20.04 LTS Focal Fossa. I hope you find this quick tip helpful. Don’t forget to share your valuable queries/suggestions in the below comment box & also drop your worthwhile feedback.