NRPE (Nagios Remote Plugin Executor) allows the Nagios Master server to monitor services on remote Linux servers (Slave).
NRPE configuration file location depends on installation type. Usually:
/usr/local/nagios/etc/nrpe.cfg
Open the file:
nano /usr/local/nagios/etc/nrpe.cfg
Find and edit allowed_hosts:
allowed_hosts=127.0.0.1,192.168.1.10
Add your Nagios Master IP address.
Restart NRPE service:
sudo systemctl restart nrpe
Run this command from Nagios Master server:
/usr/local/nagios/plugins/check_nrpe -H <Slave_IP_Address>
This verifies communication between Master and Slave.
Create file:
/usr/local/nagios/etc/objects/slave.cfg
Add the following configuration:
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
}
Add service definitions in the same file:
# Check CPU Load
define service{
use generic-service
host_name Slave-Server-01
service_description CPU Load
check_command check_nrpe!check_load
}
# Check Current Users
define service{
use generic-service
host_name Slave-Server-01
service_description Current Users
check_command check_nrpe!check_users
}
# Check Root Disk Space
define service{
use generic-service
host_name Slave-Server-01
service_description Root Disk Space
check_command check_nrpe!check_disk
}
check_nrpe sends the request from Master to Slave.
check_load, check_users, check_disk are commands executed on Slave.
Edit main configuration file:
/usr/local/nagios/etc/nagios.cfg
Add:
cfg_file=/usr/local/nagios/etc/objects/slave.cfg
Restart Nagios:
sudo systemctl restart nagios
Nagios uses a Mail Transfer Agent like Postfix or Sendmail.
Test email:
echo "Test" | mail -s "Test Email" user@example.com
Edit contacts.cfg:
/usr/local/nagios/etc/objects/contacts.cfg
Add:
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
}
define contactgroup{
contactgroup_name admins
alias Nagios Administrators
members nagiosadmin,shanmugananthan
}
define host {
use linux-server
host_name web-server-01
alias Web Server
address 192.168.1.10
contact_groups admins
}
Verify configuration:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Restart Nagios:
sudo systemctl restart nagios