Services DevOps DevSecOps Cloud Consulting Infrastructure Automation Managed Services AIOps MLOps DataOps Microservices 🔐 Private AINEW Solutions DevOps Transformation CI/CD Automation Platform Engineering Security Automation Zero Trust Security Compliance Automation Cloud Migration Kubernetes Migration Cloud Cost Optimisation AI-Powered Operations Data Platform Modernisation SRE & Observability Legacy Modernisation Managed IT Services 🔐 Private AI DeploymentNEW Products ✨ ZippyOPS AINEW 🛡️ ArmorPlane 🔒 DevSecOpsAsService 🖥️ LabAsService 🤝 Collab 🧪 SandboxAsService 🎬 DemoAsService Bootcamp 🔄 DevOps Bootcamp ☁️ Cloud Engineering 🔒 DevSecOps 🛡️ Cloud Security ⚙️ Infrastructure Automation 📡 SRE & Observability 🤖 AIOps & MLOps 🧠 AI Engineering 🎓 ZOLS — Free Learning Company About Us Projects Careers Get in Touch

Nagios Installation Guide: Step-by-Step Setup

Nagios Installation: A Step-by-Step Guide

Nagios installation is the first crucial step to setting up a comprehensive monitoring system for your IT infrastructure. This guide will walk you through the process of installing and configuring Nagios, so you can monitor your systems, networks, and applications effectively.

Nagios Installation and configuration on Linux server for monitoring setup

Prerequisites for Nagios Installation

Before beginning the Nagios installation, you need to install the required build dependencies. These are essential packages that support Nagios’ functionality:

sudo yum install gcc glibc glibc-common gd gd-devel make net-snmp openssl-devel xinetd unzip

Also, create a “nagios” user and “nagcmd” group to handle installation commands and permissions:

sudo useradd nagios
sudo groupadd nagcmd
sudo usermod -a -G nagcmd nagios

Once the prerequisites are in place, you can move on to the installation process.

Installing Nagios Core

Navigate to the /opt directory and download the Nagios Core package:

cd /opt
curl -L -O https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz

Once the download is complete, extract the package and enter the extracted folder:

tar xvf nagios-*.tar.gz
cd nagios-*

Next, configure Nagios with the following command to ensure the correct group permissions:

./configure --with-command-group=nagcmd

Compile Nagios using the make command:

make all

Now, run these commands to install Nagios, its components, and configure them for proper functioning:

sudo make install
sudo make install-commandmode
sudo make install-init
sudo make install-config
sudo make install-webconf

To allow external command execution via the Nagios web interface, add the Apache user to the nagcmd group:

sudo usermod -G nagcmd apache

Installing Nagios Plugins

Nagios relies on plugins to perform checks on various services and systems. To install the Nagios Plugins, first, download the plugin archive:

cd /opt
curl -L -O http://nagios-plugins.org/download/nagios-plugins-2.1.1.tar.gz
tar xvf nagios-plugins-*.tar.gz
cd nagios-plugins-*

Configure and compile the plugins using the following commands:

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

Installing NRPE for Remote Monitoring

To monitor remote systems, install the Nagios Remote Plugin Executor (NRPE). Begin by downloading its archive and extracting it:

cd /opt
curl -L -O http://downloads.sourceforge.net/project/nagios/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz
tar xvf nrpe-*.tar.gz
cd nrpe-*

Configure NRPE for remote monitoring:

./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu

Now, build and install NRPE with the following commands:

make all
sudo make install
sudo make install-xinetd
sudo make install-daemon-config

Once NRPE is installed, restart the xinetd service:

sudo service xinetd restart

Configuring Nagios Installation for Monitoring

Organize Nagios Configuration

For a better-organized Nagios installation, uncomment the configuration directory line in nagios.cfg:

sudo vi /usr/local/nagios/etc/nagios.cfg

Uncomment the following line:

cfg_dir=/usr/local/nagios/etc/servers

Create the servers directory where configuration files for each monitored server will be stored:

sudo mkdir /usr/local/nagios/etc/servers

Configure Nagios Contacts

To receive alerts and notifications, change the contact email address in the configuration:

email nagios@localhost  ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******

Add Check_NRPE Command

To monitor remote systems, you need to add the NRPE command to the commands.cfg file:

sudo vi /usr/local/nagios/etc/objects/commands.cfg

Add this configuration:

define command{
    command_name check_nrpe
    command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$
}

Configure Apache for Nagios Web Access

Set up a user for the Nagios web interface by creating a password:

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

If you use a different username, make sure to update the cgi.cfg file with your new user.

Start Nagios Service

Finally, reload the system daemon and start Nagios and Apache:

sudo systemctl daemon-reload
sudo systemctl start nagios.service
sudo systemctl restart httpd.service
sudo chkconfig nagios on

Restrict Access by IP (Optional)

If you want to restrict access to the Nagios web interface, modify the nagios.conf file to allow only specific IP addresses:

sudo vi /etc/httpd/conf.d/nagios.conf

Uncomment and modify these lines:

Order deny,allow
Deny from all
Allow from 127.0.0.1

Save the changes and restart both Nagios and Apache:

sudo systemctl restart nagios.service
sudo systemctl restart httpd.service

Accessing the Nagios Installation Web Interface

After completing the installation, access the Nagios web interface by visiting:

http://nagios_server_public_ip/nagios

Log in using the credentials you created during the setup process.

Conclusion for Nagios Installation

Congratulations! You’ve successfully completed the Nagios installation and configuration. Nagios is a powerful monitoring tool, and with the correct setup, it will help you keep track of your infrastructure’s health and performance.

For more advanced configurations, or if you need help optimizing your IT systems, ZippyOPS offers expert consulting, implementation, and managed services. Our expertise spans DevOps, Cloud solutions, DataOps, AIOps, and more. Let ZippyOPS help you streamline your infrastructure management.

For more information, visit ZippyOPS Services or contact us at sales@zippyops.com.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top