Skip to content

Instantly share code, notes, and snippets.

@ohkeenan
Forked from anonymous/gist:4658224
Last active August 29, 2015 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ohkeenan/a808c0ab64dc06b256b9 to your computer and use it in GitHub Desktop.
Save ohkeenan/a808c0ab64dc06b256b9 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Download the required yum packages
yum install -y gcc glibc glibc-common gd gd-devel net-snmp net-snmp-devel net-snmp-utils make xinetd
# Add the Icinga User and Groups
/usr/sbin/useradd -m icinga
# Create the Icinga Directory
mkdir -p /usr/local/icinga/etc
mkdir -p /home/icinga/.ssh
chown -R icinga:icinga /home/icinga
chmod -R go-rwx /home/icinga/.ssh
# Get NRPE 2.15 and Nagios Plugins
mkdir /opt/installs
cd /opt/installs
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.15/nrpe-2.15.tar.gz/download
# Extract
tar -xvf nrpe-2.15.tar.gz
cd nrpe-2.15
./configure --with-ssl --with-nrpe-user=icinga --with-nrpe-group=icinga --with-nagios-user=icinga --with-nagios-group=icinga --libexecdir=/usr/local/icinga/libexec/ --bindir=/usr/local/icinga/bin/
# Make and make install
make && make install && make install-xinetd
# Configure the NRPE Port
echo "nrpe 5666/tcp # nrpe" >> /etc/services
# Add to allowed hosts in case of firewall
echo "nrpe: SERVERIP SERVERDOMAIN" >> /etc/hosts.allow
# Add to CSF if using CSF
csf -a SERVERIP
csf -r
# Download the Nagios Plugins from Nagios-Plugins.com
cd /opt/installs
wget http://www.nagios-plugins.org/download/nagios-plugins-2.0.3.tar.gz
tar -xvf nagios-plugins-2.0.3.tar.gz
cd nagios-plugins-2.0.3
# Configure and Make the install
./configure --prefix=/usr/local/icinga --with-cgiurl=/icinga/cgi-bin --with-nagios-user=icinga --with-nagios-group=icinga
make && make install
# Copy over nrpe.cfg
cp /opt/installs/nrpe-2.15/sample-config/nrpe.cfg /usr/local/icinga/etc/nrpe.cfg
# Need to change the hosts we are allowing check_nrpe calls from
sed -i 's/allowed_hosts=127.0.0.1/allowed_hosts=SERVERIP/g' /usr/local/icinga/etc/nrpe.cfg
sed -i 's/127.0.0.1/127.0.0.1 SERVERIP/g' /etc/xinetd.d/nrpe
sed -i 's/nagios/icinga/g' /etc/xinetd.d/nrpe
# Set Permissions
chown icinga:icinga /usr/local/icinga/etc/nrpe.cfg
# Add Icinga SSH Public Key
echo "YOUR SSH KEY" > /home/icinga/.ssh/authorized_keys
chown icinga:icinga /home/icinga/.ssh/authorized_keys
# Set xinetd to run at boot
chkconfig xinetd on
# Start Xinetd
/etc/init.d/xinetd start
# Sleep a second while xinetd starts
sleep 1
# Test to see if its working - You should get back the NRPE version
/usr/local/icinga/libexec/check_nrpe -H 127.0.0.1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment