Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save realtebo/e7288d19155445ba0f33ae7ccc29875f to your computer and use it in GitHub Desktop.
Save realtebo/e7288d19155445ba0f33ae7ccc29875f to your computer and use it in GitHub Desktop.
Install NRPE (to remote host, NOT on the controller)
# Use nrpe on remote host instead of ncpa only if ncpa is not working
# this setup require BOTH nrpe AND plugins
# Use this when on debian 7/8
################
# NRPE #
################
# Execute all as super user !
# Prereq for nrpe
apt install libssl-dev build-essential
# Installing nrpe
cd /tmp
wget -O nrpe-3.2.1.tar.gz https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-3.2.1/nrpe-3.2.1.tar.gz
tar xvf nrpe-*.tar.gz
rm -f nrpe-*.tar.gz
cd nrpe-*
./configure --enable-command-args --with-nagios-user=nagios --with-nagios-group=nagios --with-ssl=/usr/bin/openssl --with-ssl-lib=/usr/lib/x86_64-linux-gnu
make all
make install-groups-users
make install
make install-init
make install-config
# enable incoming traffic for check_nrpe
iptables -I INPUT -p tcp --destination-port 5666 -j ACCEPT
################ IF YOU WANT TO USE UFW ##############
sudo mkdir -p /etc/ufw/applications.d
sudo sh -c "echo '[NRPE]' > /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'title=Nagios Remote Plugin Executor' >> /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'description=Allows remote execution of Nagios plugins' >> /etc/ufw/applications.d/nagios"
sudo sh -c "echo 'ports=5666/tcp' >> /etc/ufw/applications.d/nagios"
sudo ufw allow NRPE
sudo ufw reload
##########################################################
# IMPORTANT
# Open with nano /usr/local/nagios/etc/nrpe.cfg
# and add your ip to list of allowed ips
# enable/run/check service
systemctl enable nrpe.service
systemctl start nrpe.service
systemctl status nrpe.service
# if not available systemctl, simply run
# /etc/init.d/nrpe restart
# cleanout
cd /tmp
rm nrpe-3.2.1 -rf
################################################################
# Plugins #
# Will be installed into /usr/local/nagios/libexec #
################################################################
# Nagios Plugin Prerequisites
apt-get install -y autoconf gcc libc6 libmcrypt-dev make libssl-dev wget bc gawk dc build-essential snmp libnet-snmp-perl gettext
# Nagios Plugin Download
cd /tmp
wget --no-check-certificate -O nagios-plugins.tar.gz https://github.com/nagios-plugins/nagios-plugins/archive/release-2.2.1.tar.gz
tar zxf nagios-plugins.tar.gz
rm nagios-plugins.tar.gz
# Nagios Plugin Installation
cd nagios-plugins-release-2.2.1
./tools/setup
./configure
make
make install
cd /tmp
rm nagios-plugins-release-2.2.1 -rf
#########################
# Starting services #
#########################
# enable/run/check service
systemctl enable nrpe.service
systemctl start nrpe.service
systemctl status nrpe.service
#########################
# Usefull commands #
#########################
# Edit file: nano /usr/local/nagios/etc/nrpe.cfg
# Add custom commands like ...
command[check_root_partition]=/usr/local/nagios/libexec/check_disk -w 10% -c 5% -p / -u GB
# The content of the following script is avaiable as gist:
# search realtebo/chustom_check_mem script for nrpe
command[check_mem]=/usr/local/nagios/libexec/custom_check_mem -w 20% -c 10%
# then give it execution permissions
# sudo chmod a+x /usr/local/nagios/libexec/custom_check_mem
#############################
# How to config the host #
#############################
See `example config for a server without npa`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment