Skip to main content

Install Nagios Core from Source Along with Plugins

Hands-On Lab

 

Photo of

Training Architect

Length

03:30:00

Difficulty

Intermediate

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.

What are Hands-On Labs?

Hands-On Labs are scenario-based learning environments where learners can practice without consequences. Don't compromise a system or waste money on expensive downloads. Practice real-world skills without the real-world risk, no assembly required.

Install Nagios Core from Source along with Plugins

Introduction

Your company is switching over to Nagios as a monitoring solution. It falls to you to perform the initial install of Nagios Core on your company's server. You have decided to download the source code for Nagios Core and use that to perform the installation directly. All you need to do is download, unpack, compile, install, and configure the Nagios Core.

Solution

  1. Begin by logging in to the lab server using the credentials provided on the hands-on lab page.

    ssh cloud_user@PUBLIC_IP_ADDRESS

Download and Compile Nagios Core

  1. Edit the SELinux config file.

    sudo vim /etc/selinux/config
  2. Change the line defining the SELINUX variable to the following.

    SELINUX=permissive
  3. Save the changes and exit the editor.

  4. Modify the current mode for SELinux.

    sudo setenforce 0
  5. Check the current SELinux mode. Verify we are in permissive mode.

    getenforce
  6. Install all necessary prerequisites.

    sudo yum install -y gcc glibc glibc-common wget unzip httpd php gd gd-devel perl postfix
  7. Download the Nagios Core.

    wget https://github.com/NagiosEnterprises/nagioscore/archive/nagios-4.4.3.tar.gz
  8. Extract the files from the repository.

    tar -xvzf nagios-4.4.3.tar.gz
  9. Navigate to the appropriate directory.

    cd nagioscore-nagios-4.4.3
  1. Run the configuration script.

    ./configure
  2. Compile the necessary files.

    sudo make all

Install Nagios

  1. Create a user and group for Nagios.

    sudo make install-groups-users
  2. Add the Nagios user to the Apache group.

    sudo usermod -a -G nagios apache
  3. Install the necessary binaries.

    sudo make install
  4. Configure Nagios to run as a daemon.

    sudo make install-daemoninit
  5. Enable the web server.

    sudo systemctl enable httpd.service
  6. Install the Nagios command mode.

    sudo make install-commandmode
  7. Install sample files for Nagios.

    sudo make install-config
  8. Install Apache configuration files.

    sudo make install-webconf

Configure and Run Nagios

  1. Configure a firewall rule for Nagios.

    sudo firewall-cmd --zone=public --add-port=80/tcp --permanent
  2. Reload the firewall.

    sudo firewall-cmd --reload
  3. Create a "nagiosadmin" user and remember the password you assign.

    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
  4. Start the web server.

    sudo systemctl start httpd.service
  5. Start the Nagios service.

    sudo systemctl start nagios.service
  6. Check that the web server is running.

    sudo systemctl status httpd
  7. Check that Nagios is running

    sudo systemctl status nagios
  8. 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.

Add Nagios Plugins

  1. 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
  2. Download the plugins.

    wget https://github.com/nagios-plugins/nagios-plugins/archive/master.zip
  3. Unzip the file.

    unzip master.zip
  4. Nagivate to the appropriate directory.

    cd nagios-plugins-master/
  5. Run the setup command.

    ./tools/setup
  6. Run the configure command.

    sudo ./configure
  7. Compile the necessary files.

    sudo make
    sudo make install
  8. Restart Nagios.

    sudo systemctl restart nagios
  9. Switch back to your browser and refresh it. Click on Hosts in the left-hand menu.

Conclusion

Congratulations — you've completed this hands-on lab!