Archives

Script for Nagios installation

script for Nagios installation
#!/bin/bash
dir=/usr/local/nagios
wget http://osdn.dl.sourceforge.net/sourceforge/nagios/nagios-3.0.6.tar.gz
wget http://osdn.dl.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.11.tar.gz
mkdir -p $dir
grep -i “red hat” /etc/issue>/dev/null2>&1
if [ `echo $? ` = 0 ];then
useradd nagios
else
groupadd nagios
useradd -G nagios nagios
fi
tar xzf nagios-plugins-1.4.11.tar.gz
cd nagios-plugins-1.4.11
./configure –prefix=/usr/local/nagios –enable-redhat-pthread-workaround
make
make install
cd ..
tar xzf nagios-3.0.6.tar.gz
cd nagios-3.0.6
./configure –prefix=/usr/local/nagios
make install
make install-init
make install-config
make install-commandmode
make install-webconf
# make sure xinetd is installed.
echo ” nrpe      5666/tcp      #nrpe” >> /etc/services
chown -R nagios.nagios /usr/local/nagios
service xinetd [...]

Automated Ftp script.

This will find all files inside the /root/remote/ and rename it to .done
and uploads them one by one.
#!/bin/bash
ls /root/remote/*.txt > /root/remote/files
cd /root/remote
for i in `ls *.txt`;do mv “$i” “`basename $i .txt`.done”; done
for f in *.done; do
ftp  -inv test.com<<ENDFTP
user username password
cd test
lcd /root/remote
put $f
bye
ENDFTP
done

Load Alert script for Sun Solaris.

#!/bin/bash
EMAIL=”linu@pearlin.info”
SUBJECT=”Alert $(hostname) load average is $L05″
TEMPFILE=”/tmp/$(hostname)”
echo “Load average Crossed allowed limit.” >> $TEMPFILE
echo “Hostname: $(hostname)” >> $TEMPFILE
echo “Local Date & Time : $(date)” >> $TEMPFILE
echo “| Uptime status: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/usr/bin/uptime >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Top 20 CPU consuming processes: |” >> $TEMPFILE
/usr/ucb/ps auwx | sort -rn +2 | head [...]