Nagios is one of the best open-source monitoring tools for monitoring the services and applications running on Windows and Linux operating systems.
Nagios can monitor services such as HTTP, FTP, SSH, SMTP, etc., and system metrics such as CPU load, memory, disk usage, logged-in users, running processes, etc.
Here, we will see how to install Nagios on Ubuntu 22.04.
Prerequisites
Though the Nagios package is available in the Ubuntu repository, we will compile it from the source. So, install the below packages for compiling Nagios.
Create a user and group for Nagios. Then add the nagios and apache user (www-data) to the part of the nagcmd group to execute external commands via Nagios web interface.
sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios
sudo usermod -a -G nagcmd www-data
Install Nagios Core on Ubuntu 22.04
First, download the latest version of Nagios core from the official website.
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar -zxvf nagios-4.4.6.tar.gz
cd nagios-4.4.6/
Then, execute the below commands to compile the Nagios from the source code.
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
You can find Nagios’s configuration files under the /usr/local/nagios/etc directory, and the default configuration should work fine.
Next, install the Nagios web interface with the below command.
sudo make install-webconf
The Nagios web interface is password protected by default and you will need to create a user account (nagiosadmin) to access the Nagios web interface. So, use the below command to create a user account for Nagios web interface.
Change the email address field to receive the alerts.
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] ;
Install Nagios Plugins on Ubuntu 22.04
To monitor a system, you will need to install Nagios plugins. So, download the Nagios plugins from the official website.
wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
tar -zxvf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3/
Then, compile and install the Nagios plugins.
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make
sudo make install
Start Nagios Monitoring Tool
Now, it’s time to start the Nagios service. Before starting the service, verify the Nagios configuration files.