[root@emcl ~]# sestatus
SELinux status: enforcing
# disable selinux
[root@emcl ~]# vi /etc/selinux/config
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
SELINUX=disabled
# SELINUXTYPE= can take one of these three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted
[root@emcl ~]# rpm -qa | grep dnf
python3-dnf-plugins-core-4.0.21-3.0.1.el8.noarch
dnf-plugin-spacewalk-2.8.5-11.0.3.module+el8.3.0+20070+f5719e00.noarch
python3-libdnf-0.63.0-3.0.1.el8.x86_64
dnf-4.7.0-4.0.1.el8.noarch
dnf-plugins-core-4.0.21-3.0.1.el8.noarch
python3-dnf-plugin-spacewalk-2.8.5-11.0.3.module+el8.3.0+20070+f5719e00.noarch
libdnf-0.63.0-3.0.1.el8.x86_64
python3-dnf-4.7.0-4.0.1.el8.noarch
python3-dnf-plugin-ulninfo-0.3-2.module+el8.4.0+20142+f119a2fa.noarch
dnf-data-4.7.0-4.0.1.el8.noarch
[root@emcl ~]# dnf install -y gcc glibc glibc-common perl httpd php wget gd gd-devel
[root@emcl ~]# systemctl start httpd
[root@emcl ~]# systemctl enable httpd
Created symlink /etc/systemd/system/multi-user.target.wants/httpd.service → /usr/lib/systemd/system/httpd.service.
[root@emcl ~]# systemctl start httpd
3. download, compile and install Nagios Core
# Navigate to a directory where you want to download Nagios Core
cd /software
# Download the Nagios Core source tarball
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-.tar.gz
# Replace with the actual version number available on the Nagios website. for example
wget -O nagioscore.tar.gz https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz
3_2. Compile and Install Nagios Core:[root@emcl ~]# cd /software/
[root@emcl software]# tar xzf /software/nagioscore-nagios-4.4.3.tar.gz
[root@emcl software]# cd nagioscore-nagios-4.4.3/
# configure the source package and build it.
[root@emcl nagioscore-nagios-4.4.3]# ./configure
Compile and install Nagios
[root@emcl nagioscore-nagios-4.4.3]# make all
# create the Nagios User and Group, and add the Apache user to the Nagios Group
[root@emcl nagioscore-nagios-4.4.3]# make install-groups-users
groupadd -r nagios
useradd -g nagios nagios
[root@emcl nagioscore-nagios-4.4.3]# usermod -a -G nagios apache
# Install init scripts and set permissions
[root@emcl nagioscore-nagios-4.4.3]# make install
[root@emcl nagioscore-nagios-4.4.3]# make install-daemoninit
[root@emcl nagioscore-nagios-4.4.3]# make install-commandmode
[root@emcl nagioscore-nagios-4.4.3]# make install-config
# Install the Apache configuration file
[root@emcl nagioscore-nagios-4.4.3]# make install-webconf
4. Secure Nagios Core
[root@emcl nagioscore-nagios-4.4.3]# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
# dnf install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils
# Navigate to a directory where you want to download Nagios Plugins
[root@emcl nagioscore-nagios-4.4.3]# cd /software/
# Download the Nagios Plugins source tarball
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
# Extract the tarball
[root@emcl software]# tar zxf nagios-plugins-release-2.2.1.tar.gz
5_3. Compile and Install Nagios Plugins:[root@emcl nagios-plugins-release-2.2.1]# cd nagios-plugins-release-2.2.1/
[root@emcl nagios-plugins-release-2.2.1]# ./tools/setup
[root@emcl nagios-plugins-release-2.2.1]# ./configure
[root@emcl nagios-plugins-release-2.2.1]# make
[root@emcl nagios-plugins-release-2.2.1]# make install
/usr/local/nagios/libexec/check_disk -w 20% -c 10%
5_5. Restart Nagios: After making changes to the configuration, restart the Nagios service:[root@emcl nagios-plugins-release-2.2.1]# systemctl restart httpd.service
[root@emcl nagios-plugins-release-2.2.1]# systemctl start nagios.service
Failed to start nagios.service: Unit nagios.service not found.
If you are encountering the error "Failed to start nagios.service: Unit nagios.service not found," it suggests that the Nagios service unit file is not present in the expected location or the service has not been properly installed or configured. Do the following to resolve this problem.
[root@emcl ~]# vi /etc/systemd/system/nagios.service
[Unit]
Description=Nagios
BindTo=network.target
[Install]
WantedBy=multi-user.target
[Service]
User=nagios
Group=nagios
Type=simple
ExecStart=/usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
# Check the status of the Nagios service to see if it is running without issues:
[root@emcl ~]# systemctl start nagios
[root@emcl ~]# systemctl restart nagios
[root@emcl ~]# systemctl status nagios
6. Add firewall rules (or disable firewall): To allow access to Nagios through the firewall, you'll need to add a rule to allow traffic on the port that Nagios is using. By default, Nagios uses port 80 for HTTP and port 443 for HTTPS. Here's how you can add a rule to allow traffic on port 80:
# Add a rule to allow traffic on port 80 (HTTP)
firewall-cmd --zone=public --add-port=80/tcp --permanent
# Reload the firewall to apply the changes
firewall-cmd --reload
http://192.168.56.2/nagios
You should be prompted with the Nagios login screen. Enter the username and password to log in.
The default credentials are often: cd /software
wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.0.2/nrpe-4.0.2.tar.gz
# Unpack the NRPE source code tarball.
[root@emcl software]# cd /software/
[root@emcl software]# tar xzf nrpe-4.0.2.tar.gz
[root@emcl software]# cd nrpe-4.0.2
# Compile and install the NRPE addon.
[root@emcl nrpe-4.0.2]# ./configure
[root@emcl nrpe-4.0.2]# make all
# install the NRPE plugin daemon, and sample config files.
[root@emcl nrpe-4.0.2]# make install-plugin
[root@emcl nrpe-4.0.2]# make install-daemon
[root@emcl nrpe-4.0.2]# make install-config