#244: Configure NRPE for Remote Server Monitoring - Rmhibbert/oe2-group-c GitHub Wiki
Link to the ticket: https://rt.dataraster.com/Ticket/Display.html?id=244&results=5193d32cbc6cb93fdb9010ad9c5c5728
Install the NRPE server
install the nagios-nrpe-server
Description: On the DB server download nagios-nrpe-server
Command: sudo apt-get install nagios-nrpe-server
NRPE Server configuration
edit the config file
Description: nano into the config file
Command: sudo nano /etc/nagios/nrpe.cfg
edit the allowed hosts
Description: In the config file add the allowed hosts
Command: allowed_hosts=127.0.0.1,::1,db-c
edit the disk check
Description: In the config file change the command so it checks the correct disk
Command: check_sda1=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/sda1
Restart
Description: Restart the system
Command: sudo systemctl restart nagios-nrpe-server
Nagios Server Configuration
Install plugin
Description: install the nagios-nrpe-plugin package
Command: sudo apt-get install nagios-nrpe-plugin
Create a new host group
Description: Create a Remote Disks host group to put DB-c in
Command:
#create new hostgroup for db nagios_hostgroup { "remote-disks": target => "/etc/nagios4/conf.d/ppt_hostgroups.cfg", mode => "0644", alias => "Remote Disks", members => "db-c", }
Create a new service
Description: create a new service that performs the disk check via NRPE
Command:
nagios_service { "remote-disks":
service_description => "Remote Disks",
hostgroup_name => "remote-disks",
target => "/etc/nagios-plugins/config/check_nrpe.cfg",
check_command => "check_sda1",
max_check_attempts => 3,
retry_check_interval => 1,
normal_check_interval => 5,
check_period => "24x7",
notification_interval => 30,
notification_period => "24x7",
notification_options => "w,u,c",
contact_groups => "admins",
mode => "0644",
}
Create NRPE file structure
On the mgmt server create file structure
Description: change directory to modules
Command: cd /etc/puppetlabs/code/modules
Description: Create files
Command: sudo mkdir -p nrpe/files nrpe/templates nrpe/manifests
Move nrpe file to modules
Description: copy the config file into modules
Command: sudo cp /etc/nagios/nrpe.cfg /etc/puppetlabs/code/modules/nrpe/files
Edit the file
Description: Add the allowed host to the config file
Command: allowed_hosts=127.0.0.1,::1,mgmt-c
Create manifest files
Description: Create the init.pp install.pp service.pp config.pp
Command: sudo touch init.pp
Description: init.pp content
Command: class nrpe {include nrpe::install}
Description: service.pp content
Command:
class nrpe::service { service { "nagios-nrpe-server": ensure => running, hasstatus => true, hasrestart => true, enable => true, require => Class["nrpe::config"], } }
Description: config.pp content
Command:
class nrpe::config { file { "/etc/nagios/nrpe.cfg": ensure => present, source => "puppet:///modules/nrpe/files/npre.cfg", mode => "0444", owner => "root", group => "root", require => Class["nrpe::install"], notify => Class["nrpe::service"], } }
Description: install.pp content
Command:
class nrpe::install { package{"nagios-nrpe-server": ensure=>present } package { 'nagios-nrpe-plugin': ensure => installed, } }
Fixes
syntax issue, add the members as 1 item not separate strings
use the correct target to the ppt_services.cfg on my service
Adding check_nrpe to check command on remote disks service
Add the server names to allowhosts in /etc/nagios/nrpe.cfg
edit the check to sdb1
then
sudo systemctl restart nagios-nrpe-server.service sudo systemctl status nagios-nrpe-server.service
sudo puppet agent --test