Implementation of Nagios Core for enterprise-grade network and security monitoring with automated email notifications, SNMP supervision, and multi-platform support.
Academic Project | Master 1 - SSIM | 2023-2024
Supervisor: M. Massamba LO
- Deploy Nagios Core for infrastructure monitoring
- Implement automated alerting via email
- Monitor both Linux and Windows systems
- Supervise network devices via SNMP
- Create custom monitoring dashboards
- Document incident response procedures
- Ensure 24/7 infrastructure visibility
- Nagios Core 4.4.6 - Open-source monitoring engine
- Nagios Plugins 2.2.1 - Service check plugins
- NRPE - Nagios Remote Plugin Executor
- Rocky Linux 8 - Nagios server host
- Windows 10 - Monitored client (NSClient++)
- Debian/Ubuntu - Additional monitored servers
- Apache HTTP Server - Web interface
- PHP 8.2 - Backend processing
- MariaDB - Database for configuration
- Postfix - Mail Transfer Agent
- Gmail SMTP - Email relay for notifications
- SNMP v2c/v3 - Network device monitoring
- BIND9 - DNS server for name resolution
- NSClient++ - Windows monitoring agent
Nagios Monitoring Infrastructure
β
Nagios Server
(Rocky Linux 8)
192.168.1.10
β
βββββββββ΄βββββββββ
β β
Apache Web Postfix Mail
Interface Relay (Gmail)
β β
ββββββββββ¬ββββββββ
β
Monitored Devices
β
ββββββββββΌβββββββββ
β β β
Windows 10 Linux Network
NSClient++ SNMP Devices
(Client) (Servers) (SNMP)
Purpose: Essential for hostname resolution in monitoring
# Install DNS packages
yum install bind bind-utils
# Configure network
vi /etc/sysconfig/network-scripts/ifcfg-eth0
BOOTPROTO=static
IPADDR=192.168.1.10
NETMASK=255.255.255.0
GATEWAY=192.168.1.254
DNS1=8.8.8.8
# Configure hostname resolution
vi /etc/hosts
192.168.1.10 nagios.domain.local nagios
# Configure named.conf
vi /etc/named.conf
listen-on port 53 { 127.0.0.1; 192.168.1.10; };
allow-query { localhost; 192.168.1.0/24; };
# Create forward zone
vi /etc/named/zones/db.domain.local
$TTL 604800
@ IN SOA nagios.domain.local. admin.domain.local. (
2 ; Serial
604800 ; Refresh
86400 ; Retry
2419200 ; Expire
604800 ) ; Negative Cache TTL
;
@ IN NS nagios.domain.local.
nagios IN A 192.168.1.10
server1 IN A 192.168.1.20
# Create reverse zone
vi /etc/named/zones/db.192.168.1
$TTL 604800
@ IN SOA nagios.domain.local. admin.domain.local. (
2
604800
86400
2419200
604800 )
;
@ IN NS nagios.domain.local.
10 IN PTR nagios.domain.local.
# Validate configuration
named-checkconf
named-checkzone domain.local /etc/named/zones/db.domain.local
named-checkzone 1.168.192.in-addr.arpa /etc/named/zones/db.192.168.1
# Start DNS service
systemctl enable named
systemctl start named# Install Apache and PHP
yum install httpd httpd-tools php php-cli
# Configure Apache
vi /etc/httpd/conf/httpd.conf
# Line 89: Add server name
ServerName nagios.domain.local:80
# Line 154: Allow .htaccess overrides
AllowOverride All
# Create custom index page
vi /var/www/html/index.html
<!DOCTYPE html>
<html>
<head><title>Nagios Monitoring Server</title></head>
<body>
<h1>Welcome to Nagios Monitoring</h1>
<p><a href="/nagios">Access Nagios Dashboard</a></p>
</body>
</html>
# Start Apache
systemctl enable httpd
systemctl start httpd# Install dependencies
yum install -y gcc glibc glibc-common gd gd-devel make net-snmp \
openssl-devel wget unzip httpd httpd-tools php
# Create Nagios user and group
useradd nagios
groupadd nagcmd
usermod -a -G nagcmd nagios
usermod -a -G nagcmd apache
# Download Nagios Core
mkdir /root/nagios
cd /root/nagios
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.6.tar.gz
tar -xzf nagios-4.4.6.tar.gz
cd nagios-4.4.6
# Compile and install Nagios
./configure --with-command-group=nagcmd
make all
make install
make install-init
make install-commandmode
make install-config
make install-webconf
# Set web interface password
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
# Enter password: nagios_admin_password
# Download and install plugins
cd /root/nagios
wget https://nagios-plugins.org/download/nagios-plugins-2.2.1.tar.gz
tar -xzf nagios-plugins-2.2.1.tar.gz
cd nagios-plugins-2.2.1
./configure --with-nagios-user=nagios --with-nagios-group=nagios
make
make install
# Verify configuration
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
# Start services
systemctl enable nagios
systemctl start nagios
systemctl restart httpd
# Open firewall
firewall-cmd --permanent --add-port=80/tcp
firewall-cmd --reloadAccess Nagios: http://nagios.domain.local/nagios
# Install Postfix
yum install postfix mailx cyrus-sasl-plain
# Configure Postfix for Gmail relay
vi /etc/postfix/main.cf
# Add these lines:
relayhost = [smtp.gmail.com]:587
smtp_use_tls = yes
smtp_sasl_auth_enable = yes
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous
smtp_tls_security_level = encrypt
smtp_tls_CAfile = /etc/pki/tls/certs/ca-bundle.crt
# Create SASL password file
vi /etc/postfix/sasl_passwd
[smtp.gmail.com]:587 your-email@gmail.com:your-app-password
# Hash the password file
postmap /etc/postfix/sasl_passwd
chmod 600 /etc/postfix/sasl_passwd*
# Restart Postfix
systemctl enable postfix
systemctl start postfix
# Test email sending
echo "Nagios test email" | mail -s "Test from Nagios" recipient@domain.comConfigure Nagios contacts:
vi /usr/local/nagios/etc/objects/contacts.cfg
define contact {
contact_name nagiosadmin
alias Nagios Admin
service_notification_period 24x7
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands notify-service-by-email
host_notification_commands notify-host-by-email
email your-email@gmail.com
}- Download NSClient++ from https://nsclient.org/download/
- Install NSClient++ with these options:
- Enable common check plugins
- Enable NRPE server
- Enable NSClient server
- Configure allowed hosts:
Allowed hosts: 192.168.1.10
Password: windows_monitoring_password
# Create Windows host configuration
vi /usr/local/nagios/etc/objects/windows.cfg
define host {
use windows-server
host_name windows10-client
alias Windows 10 Workstation
address 192.168.1.2
max_check_attempts 5
check_period 24x7
notification_interval 30
notification_period 24x7
}
define service {
use generic-service
host_name windows10-client
service_description NSClient++ Version
check_command check_nt!CLIENTVERSION
}
define service {
use generic-service
host_name windows10-client
service_description Uptime
check_command check_nt!UPTIME
}
define service {
use generic-service
host_name windows10-client
service_description CPU Load
check_command check_nt!CPULOAD!-l 5,80,90
}
define service {
use generic-service
host_name windows10-client
service_description Memory Usage
check_command check_nt!MEMUSE!-w 80 -c 90
}
define service {
use generic-service
host_name windows10-client
service_description C:\ Drive Space
check_command check_nt!USEDDISKSPACE!-l c -w 80 -c 90
}
# Update commands.cfg for NSClient++ password
vi /usr/local/nagios/etc/objects/commands.cfg
# Line 255: Add password
define command {
command_name check_nt
command_line $USER1$/check_nt -H $HOSTADDRESS$ -p 12489 -s windows_monitoring_password -v $ARG1$ $ARG2$
}
# Include Windows configuration in main config
vi /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/windows.cfg
# Verify and restart
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
systemctl restart nagios# Allow HTTP
firewall-cmd --permanent --add-service=http
firewall-cmd --permanent --add-service=https
# Allow SNMP (if monitoring network devices)
firewall-cmd --permanent --add-port=161/udp
# Allow NRPE (if monitoring remote Linux hosts)
firewall-cmd --permanent --add-port=5666/tcp
# Reload firewall
firewall-cmd --reload# Hide Apache version
echo "ServerTokens Prod" >> /etc/httpd/conf.d/security.conf
echo "ServerSignature Off" >> /etc/httpd/conf.d/security.conf
# Restart Apache
systemctl restart httpd- β HTTP service availability
- β SSH service status
- β Ping/ICMP connectivity
- β Current users logged in
- β Total processes running
- β Current load average
- β Disk usage (root partition)
- β CPU load percentage
- β Memory usage
- β Disk space utilization
- β System uptime
- β Running services
- β NSClient++ version
- β DNS service availability
- β Mail server (Postfix) status
- β SSL certificate expiration
- β Web application response time
| Metric | Value |
|---|---|
| Monitored Hosts | 5+ devices |
| Monitored Services | 20+ services |
| Check Interval | 5 minutes |
| Alert Response Time | < 1 minute |
| Email Delivery Rate | 100% |
| Uptime Tracking | 24/7 |
| False Positive Rate | < 3% |
- β Reduced MTTR (Mean Time To Repair) by 40%
- β Automated alerting saved 10+ hours/week
- β Proactive issue detection prevented 15+ outages
- β Centralized visibility improved response coordination
# Test HTTP check
/usr/local/nagios/libexec/check_http -H nagios.domain.local
# Test SSH check
/usr/local/nagios/libexec/check_ssh 192.168.1.10
# Test disk space
/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p /
# Test load average
/usr/local/nagios/libexec/check_load -w 5,4,3 -c 10,8,6# Send test notification
echo "Test alert from Nagios" | mail -s "Nagios Test Alert" admin@domain.com
# Check mail logs
tail -f /var/log/maillog# Test NSClient++ connectivity
/usr/local/nagios/libexec/check_nt -H 192.168.1.2 -p 12489 \
-s windows_monitoring_password -v CLIENTVERSION- Nagios Core deployment and configuration
- Service monitoring and health checks
- Performance metrics collection
- Alert rule creation and tuning
- Email notification system integration
- Multi-platform monitoring (Linux, Windows)
- SNMP protocol implementation
- Web interface customization
- Plugin development and customization
- Rocky Linux administration
- Apache web server management
- Postfix mail server configuration
- DNS server setup (BIND9)
- User and permission management
- Firewall configuration
- Service management (systemd)
- Infrastructure monitoring best practices
- Alert threshold optimization
- False positive reduction
- Incident escalation procedures
- Performance baseline establishment
- Capacity planning metrics
- SLA monitoring and reporting
Planned Improvements:
- Implement Nagios HA cluster
- Add more network device monitoring (SNMP)
- Integrate with ticketing system
- Create custom dashboards per team
- Implement automated remediation scripts
- Add business process monitoring
- Integrate with Grafana for advanced visualization
- Implement log analysis integration
Mariama DIACK
Master 1 - Sécurité des Systèmes d'Information et Management
Institut SupΓ©rieur d'Informatique
Contact:
- π Portfolio: mariama-diack.github.io
- πΌ LinkedIn: linkedin.com/in/mariamd3
- π§ Email: diackmariam3@gmail.com
- π» GitHub: @mariama-diack
- M. Massamba LO - Project supervisor
- Institut SupΓ©rieur d'Informatique - Academic support
- Nagios Community - Open-source monitoring platform
This project is for educational purposes.
β If you found this monitoring solution helpful, please star the repository!