Nagios NRPE

Downloading Nagios Core:

Installing Nagios Core:

Installation is really easy just follow the guide:

When installing nagios on an ubuntu 17.04 server i had to cp /usr/lib/nagios/plugins/check_nrpe /usr/local/nagios/libexec/check_nrpe and apt-get install nagios-nrpe-plugin

Once it's installed, create a host and a service and the commands.

Lets start by making sure nagios sees the files we are going to create for our hosts and services.

vi /usr/local/nagios/etc/nagios.cfg
mkdir /usr/local/nagios/etc/servers/

We will start by creating a template we can use for our hosts, then below we will create the host and then create the services for that host.

vim /usr/local/nagios/etc/servers/hosts.cfg
define host{
name                            linux-box               ; Name of this template
use                             generic-host            ; Inherit default values
check_period                    24x7        
check_interval                  5       
retry_interval                  1       
max_check_attempts              10      
check_command                   check-host-alive
notification_period             24x7    
notification_interval           30      
notification_options            d,r     
contact_groups                  admins  
register                        0                       ; DONT REGISTER THIS - ITS A TEMPLATE

define host{
use                             linux-box                ; Inherit default values from a template
host_name                       linux-server-01		 ; The name we're giving to this server
alias                           Linux Server 01          ; A longer name for the server
address                           ; IP address of Remote Linux host
vim /usr/local/nagios/etc/servers/services.cfg
define service{
use                     generic-service
host_name               linux-server-01
service_description     CPU Load
check_command           check_nrpe!check_load
vi /usr/local/nagios/etc/objects/commands.cfg

The -H will be for the host it will connect to ( defined in the host.cfg, the -c will be the name specified on the remote host inside the /etc/nrpe.cfg

define command{
command_name check_nrpe
command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$

Verify nagios config for errors before restarting.

/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg

Restart the service

service nagios restart

Remote host:

now lets install the NRPE plugins and add a few plugins to the config file.

On Ubuntu:

apt-get install nagios-nrpe-server nagios-plugins-basic

For CentOS:

To view the list of plugins you can install:

yum --enablerepo=epel -y list nagios-plugins*
yum install nrpe nagios-plugins-dns nagios-plugins-load nagios-plugins-swap nagios-plugins-disk nagios-plugins-procs

Now we need to add the nagios server ( and the commands it can execute

vim /etc/nagios/nrpe.cfg
command[check_load]=/usr/local/nagios/libexec/check_load -w 15,10,5 -c 30,25,20


On Ubuntu:

systemctl enable nagios-nrpe-server
systemctl restart nagios-nrpe-server

On Centos:

systemctl enable nrpe
systemctl restart nrpe 

Check in CLI

/usr/local/nagios/libexec/check_nrpe -n -H

Or on older versions

Other NRPE commands:

command[check_ping]=/usr/local/nagios/libexec/check_ping -w 50,50% -c 100,90%
command[check_vda]=/usr/lib64/nagios/plugins/check_disk -w 20% -c 10% -p /dev/vda1
command[check_swap]=/usr/local/nagios/libexec/check_swap -w 10% -c 5%


define service{
use generic-service
host_name media-server
service_description Check Emby
check_command check_tcp!8096