Nagios NRPE
Downloading Nagios Core:
https://www.nagios.org/downloads/nagios-core/thanks/?t=1500128149
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
cfg_file=/usr/local/nagios/etc/servers/hosts.cfg
cfg_file=/usr/local/nagios/etc/servers/services.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 192.168.1.100 ; 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 (192.168.1.100) 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 (192.168.1.101) 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
allowed_hosts=127.0.0.1,192.168.1.101
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 -h 10.1.1.1
Other NRPE commands:
command[check_ping]=/usr/local/nagios/libexec/check_ping 8.8.8.8 -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%
command[check_raid]=/usr/local/nagios/libexec/check_raid
tcp_check
define service{
use generic-service
host_name media-server
service_description Check Emby
check_command check_tcp!8096
}