What is Nagios?
- Nagios is an open-source monitoring system that helps track the health, availability, and performance of networked systems.
- It alerts administrators when issues arise and provides insights to prevent potential failures.
Why We Use It?
- Monitors web server uptime and response times.
- Tracks database performance and alerts on high query load.
- Sends email/SMS alerts when an API fails, ensuring minimal downtime.
- Generates reports on system performance for capacity planning.
This document provides a step-by-step guide to configuring a Nagios server, covering the following tasks:
- Setting up Nagios on the master server
- Installing and configuring the Nagios client on a remote server
- Adding the Nagios client to the master server
- Creating and integrating custom Nagios plugins or services using shell scripts
- Enabling email notifications for alerts
📝 Installing Nagios on Master Server 📝
Step 1: Update System
- sudo apt update -y
Step 2: Install Required Dependencies
sudo apt install -y apache2 nagios-nrpe-plugin php php-gd libgd-dev unzip build-essential libapache2-mod-php libperl-dev libssl-dev daemon wget
Step 3: Create Nagios User & Group
- sudo useradd nagios && sudo groupadd nagios && sudo usermod -aG nagios www-data
Step 4: Download & Install Nagios Core
Step 5: Set Up Apache & Firewall
- sudo a2enmod rewrite cgi
- sudo systemctl restart apache2
Step 6: Install Nagios Plugins
Step 7: Create Admin User for Web Access
- sudo htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
Step 8: Enable & Start Nagios
- sudo systemctl enable nagios
- sudo systemctl start nagios
Step 9: Access Nagios Web Interface
- http://<server-ip>/nagios
📝 Installing Nagios Client (NRPE) on Remote Server 📝
Step 1: Update System
- sudo apt update -y
Step 2: Install NRPE and Nagios Plugins
- sudo apt install -y nagios-nrpe-server nagios-plugins
Step 3: Configure NRPE
- sudo nano /etc/nagios/nrpe.cfg
Find the following line and update with Nagios Server IP
- allowed_hosts=100.100.7.226
Step 4: Restart NRPE Service
- sudo systemctl restart nagios-nrpe-server
- sudo systemctl enable nagios-nrpe-server
📝 Add Client Remote Host in Nagios Server 📝
Step 1: Test NRPE Connection from "Nagios Server"
- /usr/lib/nagios/plugins/check_nrpe -H <nagios-client-ip>
Step 2: Add Client to Nagios Server
- sudo mkdir /usr/local/nagios/etc/servers/
- sudo vim /usr/local/nagios/etc/servers/client.cfg
- cfg_dir=/usr/local/nagios/etc/servers
- sudo /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
- sudo systemctl restart nagios
- http://<server-ip>/nagios
- sudo vim /usr/local/nagios/libexec/check_disk_usage.sh
- chmod +x /usr/local/nagios/libexec/check_disk_usage.sh
- command[check_disk_usage]=/usr/lib/nagios/plugins/check_disk_usage.sh
- sudo vim /usr/local/nagios/etc/objects/commands.cfg
- sudo systemctl restart nagios-nrpe-server
- sudo vim /usr/local/nagios/etc/servers/client.cfg
No comments:
Post a Comment
testing