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 restart
test=`/usr/local/nagios/libexec/check_nrpe -H 127.0.0.1`
teststr=”NRPE v2.8.1″
if [ "$test"="$teststr" ] ;then
echo -e “install success!!”
else
echo -e “install error!!!”
fi
Results > Posts Filed Under > scripts
Script for Nagios installation
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 -20 >> $TEMPFILE
echo “| Top 10 memory-consuming processes: |” >> $TEMPFILE
/usr/ucb/ps awux | sort -rn +3 | head >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Memory …
SSH root Login alert.
1. Login to your server and su to root
2. cd /root
3. vi .bashrc
4. Scroll to the end of the file then add the following:
echo ‘ALERT – Root Shell Access (YourserverName) on:’ `date` `who` | mail -s “Alert: Root Access from `who | cut -d”(” -f2 | cut -d”)” -f1`” you@yourdomain.com
Replace YourServerName with the handle for your actual server
Replace you@yourdomain.com with your actual email address
5. Crtl + XÂ then Y