Introduction
Nagios is an open-source monitoring system that allows IT administrators to monitor servers, services, and network infrastructure. It provides real-time alerts for failures or threshold breaches, ensuring high availability and reliability. Nagios supports monitoring of host resources (CPU, memory, disk), network services (HTTP, FTP, SMTP), and custom applications.
Purpose of This Setup
The goal of this setup is to install Nagios Core with a web interface on Ubuntu VM to:
- Monitor the health and performance of servers and services.
- Receive alerts for system failures.
- Provide a centralized dashboard for easy monitoring.
- Gain practical experience with Linux system administration, service monitoring, and web-based dashboards.
1. System Update & Install Prerequisites
sudo apt update
sudo apt install wget unzip curl openssl build-essential libgd-dev libssl-dev \
libapache2-mod-php php-gd php apache2
- Installs build tools, Apache web server, PHP, and required libraries.
2. Download & Extract Nagios Core
cd /tmp
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
sudo tar -zxvf nagios-4.4.6.tar.gz
cd nagios-4.4.6
3. Compile Nagios
sudo ./configure
sudo make all
- Prepares the build environment and compiles Nagios.
4. Create Users & Groups
sudo make install-groups-users
sudo usermod -a -G nagios www-data
- Creates
nagios
user andnagcmd
group. - Adds Apache user
www-data
tonagios
group for web command access.
5. Install Nagios Core
sudo make install
sudo make install-commandmode
sudo make install-config
- Installs Nagios binaries, sets permissions, and copies default configuration files.
6. Install Web Interface
sudo make install-webconf
sudo a2enmod rewrite
sudo a2enmod cgi
sudo systemctl restart apache2
- Installs Nagios web files and enables required Apache modules.
7. Configure Firewall
sudo ufw allow apache
sudo ufw enable
sudo ufw reload
- Allows HTTP traffic to the Nagios web interface.
8. Set Up Web Authentication
sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users linuxhint
-
Username:
linuxhint
- Password: (as entered during command)
- Used to log in to the Nagios web dashboard.
9. Install Nagios Plugins
cd /tmp
sudo wget https://nagios-plugins.org/download/nagios-plugins-2.3.3.tar.gz
sudo tar -zxvf nagios-plugins-2.3.3.tar.gz
cd nagios-plugins-2.3.3
sudo ./configure --with-nagios-user=nagios --with-nagios-group=nagios
sudo make install
- Plugins enable checks for CPU, memory, disk, network, and services.
10. Verify Nagios Configuration
sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- Ensures all configuration files are correct before starting Nagios.
- No errors should appear; check “Total Warnings” and “Total Errors”.
11. Start Nagios
sudo systemctl start nagios
Or manually:
sudo /usr/local/nagios/bin/nagios /usr/local/nagios/etc/nagios.cfg
- Starts Nagios monitoring service.
12. Find VM IP Address
hostname -I
- Example output:
192.168.171.129
- This is the IP to access the Nagios web interface from a browser.
13. Access Nagios Web Interface
Open your browser and go to:
http://<VM-IP>/nagios
Replace
<VM-IP>
with the IP from the previous step.Username:
linuxhint
Password: (as set in htpasswd)
You will see the Nagios Core dashboard with hosts, services, and alerts.
Summary
This setup provides a fully functional Nagios monitoring environment:
- Monitors system metrics, services, and network resources.
- Provides real-time alerts to prevent downtime.
- Web interface allows centralized monitoring and control.
- Prepares users for practical IT monitoring and Linux administration skills.
Motto: “Monitor, Alert, and Maintain — Keeping IT systems healthy and reliable.”
Top comments (0)