Introduction
NRPE (Nagios Remote Plugin Executor) allows the Nagios Master server to monitor remote Linux Slave servers. This guide explains step-by-step configuration for monitoring and email alert setup.
Part 1: Monitor Slave from Master using NRPE
- Configure NRPE Daemon (Slave Server)
- Open NRPE configuration file:
nano /usr/local/nagios/etc/nrpe.cfg
- Modify allowed_hosts:
allowed_hosts=127.0.0.1,192.168.1.10
- Restart NRPE:
sudo systemctl restart nrpe
- Open NRPE configuration file:
- Verify Connection from Master
/usr/local/nagios/plugins/check_nrpe -H <Slave_IP_Address>
- Define Slave Host on Master
nano /usr/local/nagios/etc/objects/slave.cfg
define host{ use linux-server host_name Slave-Server-01 alias My Remote Linux Host address <Slave_IP_Address> max_check_attempts 5 check_period 24x7 notification_interval 30 notification_period 24x7 contact_groups admins register 1 } - Define Services
# CPU Load define service{ use generic-service host_name Slave-Server-01 service_description CPU Load check_command check_nrpe!check_load } # Current Users define service{ use generic-service host_name Slave-Server-01 service_description Current Users check_command check_nrpe!check_users } # Root Disk Space define service{ use generic-service host_name Slave-Server-01 service_description Root Disk Space check_command check_nrpe!check_disk } - Enable Config & Restart Nagios
nano /usr/local/nagios/etc/nagios.cfg
cfg_file=/usr/local/nagios/etc/objects/slave.cfg
sudo systemctl restart nagios
Part 2: Configure Email Notifications
- Install Mail Service
Nagios requires an MTA like Postfix.
echo "Test" | mail -s "Test Email" user@example.com
- Define Contact (contacts.cfg)
define contact { contact_name shanmugananthan use generic-contact alias shan email shan@example.com service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s service_notification_commands notify-service-by-email host_notification_commands notify-host-by-email } - Add Contact to Group
define contactgroup{ contactgroup_name admins alias Nagios Administrators members nagiosadmin,shanmugananthan } - Apply Contact Group to Host
define host { use linux-server host_name web-server-01 alias Web Server address 192.168.1.10 contact_groups admins } - Verify & Restart
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
sudo systemctl restart nagios
Final Result
- Master monitors Slave using NRPE
- CPU, Users, Disk monitored remotely
- Email alerts configured for failures
- Production-ready Nagios monitoring setup