Created
January 28, 2013 19:19
-
-
Save anonymous/4658224 to your computer and use it in GitHub Desktop.
Icinga NRPE bootstrap script
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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.14 and Nagios Plugins | |
mkdir /opt/installs | |
cd /opt/installs | |
wget http://sourceforge.net/projects/nagios/files/nrpe-2.x/nrpe-2.14/nrpe-2.14.tar.gz/download | |
# Extract | |
tar -xvf nrpe-2.14.tar.gz | |
cd nrpe-2.14 | |
./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 | |
# Download the Nagios Plugins from Sourceforge | |
cd /opt/installs | |
wget http://sourceforge.net/projects/nagiosplug/files/latest/download?source=files | |
tar -xvf nagios-plugins-1.4.16.tar.gz | |
cd nagios-plugins-1.4.16 | |
# 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.14/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