Nagios is a free open source tool to monitor various network devices and servers in a network. It support both Linux and Windows OS and provides intuitive web interface to monitor network resources. When configured it can alert you via Email in case of a network device or server goes down or malfunctions. We will move towards installation and configuration of Nagios Core and NRPE (plugin).
We will install prerequisite libraries by using below mentioned commands.
dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel dnf update -y
Disable the firewall by using following commands.
systemctl stop firewalld.service systemctl disable firewalld.service
Download Nagios from Source:
cd /tmp wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz tar -xvzf nagios-4.4.6.tar.gz
Compile Nagios from Source:
cd nagios-4.4.6/ ./configure make all
Create User And Group:
Following commands will create a user and group “nagios” and add apache user to nagios group.
make install-groups-users usermod -a -G nagios apache
Next step is to install Nagios that was configured and made with commands “./configure” and “make all”
Now Install Daemon files and start httpd service by entering following commands in CLI.
make install-daemoninit systemctl start httpd.service systemctl enable httpd.service systemctl status httpd.service
Install command mode by executing following command.
Now, we will install sample configuration files for Nagios because we will edit sample file as per our desired configuration and Apache web server configuration files by running below commands.
make install-config make install-webconf systemctl restart httpd.service
Create Nagios User Account:
We will create nagiosadmin user account to access nagios web. In other words this web will be used to see alarms. you can create your own username just replace your desired username with nagiosadmin in below mentioned command:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
After executing above command interface will ask you for the password Set the password that you want to access nagios web.
Please start httpd and nagios service.
systemctl start httpd.service systemctl enable httpd.service systemctl status httpd.service systemctl start nagios.service systemctl enable nagios.service systemctl status nagios.service
Nagios is now installed and running in your system for testing the Nagios simply type your machine IP in your web browser like “http://localhost/nagios” provide the username and password that you have set under “create nagios user account”.
Installing The Nagios Plugins (NRPE)
NRPE is a (Nagios Remote Plugin Executor) is a Nagios Agent that we install on remote system to monitor it using scripts because Nagios core execute plugins for monitoring. NRPE allows you to remotely execute Nagios plugins on other machines to monitor that machine’s metrics (CPU Usage, Memory Usage, Disk Space etc.). Please follow below instruction to install NRPE on CentOS 8.
Install the following prerequisites:
yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release yum --enablerepo=powertools,epel install perl-Net-SNMP
dnf install nrpe
Start and Enable NRPE Service:
start and enable nrpe service so that it may start automatically on reboot.
systemctl start nrpe.service systemctl enable nrpe.service systemctl status nrpe.service
you can edit and add plugins and check in nrpe by editing file with nano editor using commnd “nano /etc/nagios/nrpe.cfg”.
You can configure NRPE to add/edit plugins. Nagios will remotely execute those plugins to check the desired check for system health etc.