Skip to content

Instantly share code, notes, and snippets.

@nitinsatish
Last active March 2, 2018 22:25
Show Gist options
  • Save nitinsatish/1662819 to your computer and use it in GitHub Desktop.
Save nitinsatish/1662819 to your computer and use it in GitHub Desktop.
Nagios Installer
#!/bin/bash
echo "Installing nagios-plugin"
cd nagios-plugins*
./configure --with-openssl=/usr/bin --with-mysql=/usr
make
make install
useradd nagios -G script
chown nagios.nagios /usr/local/nagios
chown -R nagios.nagios /usr/local/nagios/libexec
echo "Installing NRPE"
cd ../nrpe-2.12/
./configure --enable-ssl --with-ssl=/usr/bin
make all
make install-plugin
make install-daemon
make install-daemon-config
make install-xinetd
cd ..
cp check_mem.pl check_array /usr/local/nagios/libexec/
chmod -R 755 /usr/local/nagios/libexec/
sed 's/127\.0\.0\.1/& 66.135.38.160/g' /etc/xinetd.d/nrpe >/etc/xinetd.d/nrpe.new
mv /etc/xinetd.d/nrpe.new /etc/xinetd.d/nrpe
echo -e "nrpe \t 5666/tcp \t # nrpe daemon" >>/etc/services
cat nrpe-config >>/usr/local/nagios/etc/nrpe.cfg
echo "Enter domain name : "
read dom
echo "command[check_http]=/usr/local/nagios/libexec/check_http -H $dom -C 30 " >>/usr/local/nagios/etc/nrpe.cfg
df -h
echo "Enter device name of / partition"
read rootp
echo "command[check_root]=/usr/local/nagios/libexec/check_disk -w 20% -c 10% -p $rootp" >>/usr/local/nagios/etc/nrpe.cfg
ps aux |grep mongrel
echo "Enter the start and end port of mongrels"
echo "start : "
read start
echo "end : "
read end
for port in `seq $start $end`
do
echo "adding $port"
echo "command[check_$port]=/usr/local/nagios/libexec/check_tcp -H localhost -p $port" >>/usr/local/nagios/etc/nrpe.cfg
done
service xinetd restart
netstat -at | grep nrpe
echo "Checking nagios check_load"
/usr/local/nagios/libexec/check_nrpe -H localhost -c check_load
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment