In this tutorial we will show you how to install Nagios on CentOS 8. For those of you who didn’t know, Nagios is an open source software that can be used for network and infrastructure monitoring. Nagios will monitor servers, switches, applications and services. It alerts the System Administrator when something went wrong and also alerts back when the issues has been rectified. Resources that can be monitored include CPU, memory and disk space loads, log files, temperature or hardware errors. It can monitor various parameters and problems for services like HTTP, SMTP, DNS, and with the help of plugins it can be highly extended. Nagios core was originally designed to run under Linux, although it should work under most other unices as well.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo’ to the commands to get root privileges. I will show you through the step by step installation Nagios on a CentOS 8 server.
Install Nagios on CentOS 8
Step 1. First of all make sure that all packages are up to date.
sudo dnf update
Step 2. Install required packages and dependencies.
Run the command below to install them:
dnf install gcc glibc glibc-common perl httpd php php-cli wget net-snmp gd gd-devel
Next, create Nagios user and group:
useradd nagios passwd nagios
Now create a groud for nagios setup “nagcmd” and add nagios user to this group. Also add nagios user in apache group:
groupadd nagcmd usermod -a -G nagcmd nagios usermod -a -G nagcmd apache
Step 3. Installing Nagios on CentOS 8.
First, navigate to the Nagios Core downloads page and grab the latest Nagios core source code:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.5.tar.gz tar xzf nagios-4.4.5.tar.gz cd nagios-4.4.5/
Perform below steps to compile the Nagios from the source code:
./configure make all make install make install-groups-users make install-daemoninit make install-commandmode make install-config make install-webconf
We need to setup the password for the user nagiosadmin. This username will be used to access the web interface so it is important to remember the password that you will input here. Set the password running the following command and enter the password twice:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 4. Installing Nagios on CentOS 8.
Before you download and install the Nagios plugins, you need to install the required packages for compiling and building the plugin package:
dnf install gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
Then, download and extract the latest version of the Nagios Plugins:
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz tar zxf nagios-plugins.tar.gz
Move into the extracted directory, compile, build and install the Nagios Plugins:
cd nagios-plugins-release-2.2.1/ ./tools/setup ./configure make make install
Now you need to restart the apache service. Also, start and enable the Nagios service:
systemctl restart httpd.service systemctl start nagios.service systemctl start nagios.service systemctl start nagios.service
Step 5. Configure firewall for Nagios.
If you have firewall running, you need to open port 80 in the firewall:
firewall-cmd --permanent --zone=public --add-port=80/tcp firewall-cmd --reload
Step 6. Accessing Nagios Web Interface.
Finally, you can now access the Nagios web console. Open your web browser and point it to Nagios Core web directory, for example:
http://192.168.1.77/nagios OR https://idroot.us/nagios
When prompted for username and password you will introduce the username “nagiosadmin” and the password that you entered in step 3. In case you forget this password you can modify it by rerunning the htpasswd command in step 3.
Congratulation’s! You have successfully installed Nagios. Thanks for using this tutorial for installting Nagios monitoring tool in CentOS 8 systems. For additional help or useful information, we recommend you to check the official Nagios website.