How to Install NAGIOS in Linux OS.




Below is a step‐by‐step guide to installing Nagios Core on a Linux system (the example below uses Ubuntu/Debian commands). Adjust package names or commands as needed for your specific distribution.


Step 1: Update Your System

Make sure your package list is up to date:

bash
sudo apt-get update sudo apt-get upgrade -y

Step 2: Install Required Dependencies

Install build tools, libraries, and web server components:

bash
sudo apt-get install -y build-essential libgd-dev openssl libssl-dev unzip wget apache2 php libapache2-mod-php

Additional packages may be needed (such as daemon, bc, or gawk) depending on your system.


Step 3: Create Nagios User and Group

Set up a dedicated Nagios user and a command group. Also, add your web server user (typically www-data) to this group:

bash
sudo useradd nagios sudo groupadd nagcmd sudo usermod -a -G nagcmd nagios sudo usermod -a -G nagcmd www-data

Step 4: Download and Compile Nagios Core

  1. Download Nagios Core Source Code
    Change to a temporary directory, download the source, and extract it. (Check Nagios Downloads for the latest version.)

    bash
    cd /tmp wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz tar zxvf nagios-4.4.6.tar.gz cd nagios-4.4.6
  2. Configure, Compile, and Install
    Run the configuration script specifying the command group, compile, and install Nagios:

    bash
    ./configure --with-command-group=nagcmd make all sudo make install sudo make install-init sudo make install-commandmode sudo make install-config sudo make install-webconf

Step 5: Configure the Apache Web Interface

  1. Create a Web Admin Account
    Set a password for the default Nagios web interface user (e.g., nagiosadmin):

    bash
    sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin

    (You’ll be prompted to enter and confirm a password.)

  2. Restart Apache
    Reload the Apache server to apply changes:

    bash
    sudo systemctl restart apache2

Step 6: Install Nagios Plugins

  1. Download Plugins
    Download the latest stable version of the Nagios plugins (verify the latest version at Nagios Plugins):

    bash
    cd /tmp wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz tar zxvf nagios-plugins-2.3.3.tar.gz cd nagios-plugins-2.3.3
  2. Compile and Install Plugins
    Configure with Nagios user and group, compile, and install:

    bash
    ./configure --with-nagios-user=nagios --with-nagios-group=nagios make sudo make install

Step 7: Start and Verify Nagios

  1. Start the Nagios Service
    Start Nagios and enable it to run on boot:

    bash
    sudo systemctl start nagios sudo systemctl enable nagios
  2. Access the Nagios Web Interface
    Open your browser and navigate to:


    http://<your-server-ip>/nagios

    Log in using the username nagiosadmin and the password you set earlier.


Final Notes

  • Firewall: If you’re running a firewall, ensure that HTTP (port 80) is allowed.
  • Customization: After installation, you may customize configuration files located in /usr/local/nagios/etc/.
  • Documentation: For more advanced configuration and troubleshooting, refer to the Nagios Core Documentation.

This guide should give you a working Nagios installation on your Linux machine using the terminal. Enjoy monitoring your systems!

Comments