This lab goes through the procedure of compiling and installing Nagios Core directly from the source. This is the long way around, but it comes with advantages such as having the latest version of Nagios Core with all the features. A secondary benefit is a greater understanding of the Nagios Core structure, how it is intended to work, and what files are where.
Learning Objectives
Successfully complete this lab by achieving the following learning objectives:
- Download and Compile Nagios Core
Edit the SELinux config file.
sudo vim /etc/selinux/config
Change the line defining the
SELINUX
variable to the following.SELINUX=permissive
Save the changes and exit the editor.
Modify the current mode for SELinux.
sudo setenforce 0
Check the current SELinux mode. Verify we are in permissive mode.
getenforce
Install all necessary prerequisites.
sudo yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
Download the Nagios Core.
wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz
Extract the files from the repository.
tar -xvzf nagios-4.4.3.tar.gz
Navigate to the appropriate directory.
cd nagioscore-nagios-4.4.3
Run the configuration script.
./configure
Compile the necessary files.
sudo make all
- Install Nagios
Create a user and group for Nagios.
sudo make install-groups-users
Add the Nagios user to the Apache group.
sudo usermod -a -G nagios apache
Install the necessary binaries.
sudo make install
Configure Nagios to run as a daemon.
sudo make install-daemoninit
Enable the web server.
sudo systemctl enable httpd.service
Install the Nagios command mode.
sudo make install-commandmode
Install sample files for Nagios.
sudo make install-config
Install Apache configuration files.
sudo make install-webconf
- Configure and Run Nagios
Configure a firewall rule for Nagios.
sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
Reload the firewall.
sudo firewall-cmd --reload
Create a "nagiosadmin" user and remember the password you assign. The password is up to you.
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Start the web server.
sudo systemctl start httpd.service
Start the Nagios service.
sudo systemctl start nagios.service
Check that the web server is running.
sudo systemctl status httpd
Check that Nagios is running
sudo systemctl status nagios
- Add Nagios Plugins and Verify Nagios
Open up a browser and navigate to the public IP address provided in the lab instructions. Attempt to login using
nagiosadmin
and the password you supplied in a previous step.Install necessary prerequisites.
sudo yum install -y gcc glibc glibc-common make gettext automake autoconf wget openssl-devel net-snmp net-snmp-utils epel-release unzip perl-Net-SNMP
Download the plugins.
wget https://github.com/nagios-plugins/nagios-plugins/archive/master.zip
Unzip the file.
unzip master.zip
Nagivate to the appropriate directory.
cd nagios-plugins-master/
Run the
setup
command../tools/setup
Run the
configure
command.sudo ./configure
Compile the necessary files.
sudo make sudo make install
Restart Nagios.
sudo systemctl restart nagios
- Switch back to your browser and refresh it. Click on Hosts in the left-hand menu.