UnixServerAdmin

Server Administration & Management

tomcat_service.sh

#!/bin/bash
# script for tomcat restart script ##
# tomcat_service.sh #########
export BASE=/usr/local/apache-tomcat/bin
prog=apache-tomcat-7.0.16

stat() {
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
echo Tomcat is running.
else
echo Tomcat is not running.
fi
}

case “$1” in
start)

if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
echo Tomcat seems to be running. Use the restart option.
else
$BASE/startup.sh 2>&1 > /dev/null
fi
stat
;;
stop)
$BASE/shutdown.sh 2>&1 > /dev/null
if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
for pid in `ps auxwww|grep $prog|grep -v grep|tr -s ‘ ‘|cut -d ‘ ‘ -f2`
do
kill -9 $pid 2>&1 > /dev/null
done
fi
stat
;;
restart)

if [ `ps auxwwww|grep $prog|grep -v grep|wc -l` -gt 0 ]
then
for pid in `ps auxwww|grep $prog|grep -v grep|tr -s ‘ ‘|cut -d ‘ ‘ -f2`
do
kill -9 $pid 2>&1 > /dev/null
done
fi
$BASE/startup.sh 2>&1 > /dev/null
stat
;;
status)
stat
;;
*)
echo “Usage: tomcat start|stop|restart|status”
esac

Advertisements

June 16, 2012 Posted by | Shell Script, Tomcat | , | Leave a comment

network_scan.sh

#!/bin/bash
ip=$( ifconfig | grep “192.168” | cut -d: -f2  | awk ‘{print $1}’ )
echo
echo “Current IP Address of the box $ip”
sub=$( echo $ip | awk -F. ‘{print $3}’ )
echo
echo “Subnet used is 192.168.’$sub’.”
echo
echo “Checking for Computers Online on Local Network”
nmap -sP 192.168.$sub.0-255 | grep -v ‘MAC’ | awk ‘{print $2,$3}’

March 27, 2012 Posted by | Shell Script | | Leave a comment

Protected: SYN_Flood Attack Protection

This content is password protected. To view it please enter your password below:

February 6, 2012 Posted by | Firewall, Security, Shell Script, Tips & Tricks | , , , , , | Enter your password to view comments.

Backup_dump.sh

##########################################################
# Database Server Backup #######################################
# backup_dump.sh script #######################################
##########################################################
set -x
set -v
standby=$1
myfirstfile=”ORS`date +’%d-%b-%Y-%H-%M’`.sql”
myfile=”ORS`date +’%d-%b-%Y-%H-%M’`.sql.bz2″

# mysql dump, check, scp and report
mysqldump -uroot -pPASSWORD –all-databases –routines –flush-logs –single-transaction –master-data=2 > /backup/mysqldump/$myfirstfile 2> /backup/mysqldump/ORS_err.txt

cd /backup/mysqldump/
bzip2  $myfirstfile

scp /backup/mysqldump/$myfile backup@$standby:/backup/autobackup/ORSmysql/
scp /backup/mysqldump/$myfile backup@X.X.X.X:/backup/autobackup/ORSmysql/
##########################################################

January 11, 2012 Posted by | MySQL, Shell Script | , | Leave a comment

Backup_script.sh

###################################################################
# Application Server Backup ##############################################
# backup_script.sh script #################################################
###################################################################
#!/bin/sh
set -x
set -v
standby=$1
myfile=”`date ‘+%d-%b-%Y-%H-%M’`.tar.bz2″
BACKUPDIR=/backup/htmldaily/
BACKUPFILE=`date ‘+%d-%b-%Y-%H-%M’`.tar
cd $BACKUPDIR
tar cvf $BACKUPFILE /var/www/html/
bzip2 $BACKUPFILE
cd /backup/htmldaily/

scp /backup/htmldaily/$myfile backup@$standby:/backup/autobackup/htmldaily/
scp /backup/htmldaily/$myfile backup@X.X.X.X:/backup/autobackup/htmldaily/
###################################################################

January 9, 2012 Posted by | Shell Script | | Leave a comment

mysql_replication_slave.sh

mysql -uroot -pPASSWORD  -e “show slave statusG;” | grep Slave >> /REPORTS/mysql_$(date +%d%m%y%H)

echo ” ” >> /REPORTS/mysql_$(date +%d%m%y%H)

mysql -uroot -pPASSWORD  -e “show slave statusG;” | grep Second >> /REPORTS/mysql_$(date +%d%m%y%H)

echo ” ” >> /REPORTS/mysql_$(date +%d%m%y%H)

mysql -uroot -pPASSWORD  -e “show slave statusG;” | grep Last_Error >> /REPORTS/mysql_$(date +%d%m%y%H)

echo ” ” >> /REPORTS/mysql_$(date +%d%m%y%H)

mysql -uroot -pPASSWORD  -e “show slave statusG;” | grep Last_SQL_Error >> /REPORTS/mysql_$(date +%d%m%y%H)

echo ” ” >> /REPORTS/mysql_$(date +%d%m%y%H)

mutt -s “MYSQL REPLICATION STATUS REPORT – IP – 192.168.1.X” info@unixserveradmin.com < /REPORTS/mysql_$(date +%d%m%y%H)

mutt -s “MYSQL REPLICATION STATUS REPORT – IP – 192.168.1.X” unixserv@unixserveradmin.com < /REPORTS/mysql_$(date +%d%m%y%H)

January 3, 2012 Posted by | MySQL, Shell Script | , | 1 Comment

pgsql_backup.sh

##################################################
# pgsql_backup.sh
##################################################
#!/bin/bash
# Location of the backup logfile.
logfile=”/path/to/logfile.log”
# Location to place backups.
backup_dir=”/directory/to/place/backups”
touch $logfile
timeslot=`date +%H-%M`
databases=`psql -h localhost -U postgres -q -c “l” | sed -n 4,/eof/p | grep -v rows) | awk {‘print $1’}`

for i in $databases; do
timeinfo=`date ‘+%T %x’`
echo “Backup and Vacuum complete at $timeinfo for time slot $timeslot on database: $i ” >> $logfile
/server/pgsql/bin/vacuumdb -z -h localhost -U postgres $i >/dev/null 2>&1
/server/pgsql/bin/pg_dump $i -h 127.0.0.1 | gzip > “$backup_dir/postgresql-$i-$timeslot-database.gz”
done
##################################################

December 18, 2011 Posted by | PgSQL, Shell Script | , | Leave a comment

whatismyip.sh

###########################################################
## whatismyip.sh ##
###########################################################
#! /bin/bash

/bin/echo “—————————————” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “External IP: –> `wget http://www.whatismyip.org -O – -o /dev/null` ” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “External IP: Verify –> `wget -q -O – checkip.dyndns.org|sed -e ‘s/.*Current IP Address: //’ -e ‘s/<.*$//’ `” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “Internal IP: –> `ifconfig | grep ‘inet addr:’| grep -v ‘127.0.0.1’ | cut -d: -f2 | awk ‘{ print $1}’`” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo “—————————————-” >> /REPORTS/liveip.log_$(date +%d%m%y)
/bin/echo >> /REPORTS/liveip.log_$(date +%d%m%y)

mutt -s “External Live IP $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/liveip.log_$(date +%d%m%y) unixserv@unixserveradmin.com

December 7, 2011 Posted by | Shell Script, Tips & Tricks | , | Leave a comment

Backup_rsync.sh

###########################################################
## backup_rsync.sh ##
###########################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
###########################################################
## Hi, ##
## The Incremental Backup Report of server is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
###########################################################
#! /bin/bash

/bin/echo “=================================================” > /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP IS STARTED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “BACKUP LOGS ARE AS FOLLOWS:”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync between two directory ###########
#/usr/bin/rsync -avzE  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync between two directory except config.php file ############
#/usr/bin/rsync -avzE –exclude config.php  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
########### Remote Sync Two directory except config.php and *.txt files ###########
/usr/bin/rsync -avzE –exclude config.php –exclude ‘*.txt’  /var/www/html/example/ root@X.X.X.X:/var/www/html/example/ >> /REPORTS/Backup.log_$(date +%d%m%y)
#####################  #####################
/bin/echo “——————————————————–” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP HAS BEEN COMPLETED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “=================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)

mutt -s “REMOTE BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “REMOTE BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

December 6, 2011 Posted by | Shell Script, Tips & Tricks | , , | Leave a comment

How to configure Tomcat to run as a Service

We here is following steps to run Tomcat as a service and create a simple Start/Stop/Restart script, as well as to start Tomcat at boot. Change to the /etc/init.d directory and create a script called ‘tomcat’ as shown below.

# cd /etc/init.d  

# vi tomcat  

——————————————————————–
#!/bin/bash  
# description: Tomcat Start Stop Restart  
# processname: tomcat  
# chkconfig: 234 20 80  
JAVA_HOME=/usr/local/jdk1.6.0_27
export JAVA_HOME  
PATH=$JAVA_HOME/bin:$PATH  
export PATH  
CATALINA_HOME=/usr/local/apache-tomcat-7.0.11
case $1 in  
start)  
sh $CATALINA_HOME/bin/startup.sh  
;;   
stop)     
sh $CATALINA_HOME/bin/shutdown.sh  
;;   
restart)  
sh $CATALINA_HOME/bin/shutdown.sh  
sh $CATALINA_HOME/bin/startup.sh  
;;   
esac      
exit 0
——————————————————————–

The above script is simple and contains all of the basic elements you will need to get going. As you can see, we are simply calling the startup.sh and shutdown.sh scripts located in the Tomcat bin directory (/usr/local/apache-tomcat-7.0.11/bin). You can adjust your script according to your needs and, in subsequent posts, we’ll look at additional examples. CATALINA_HOME is the Tomcat home directory (/usr/local/apache-tomcat-7.0.11)

Now, set the permissions for your script to make it executable:

# chmod 755 /etc/init.d/tomcat  

We now use the chkconfig utility to have Tomcat start at boot time. In my script above, I am using chkconfig: 234 20 80. 234 are the run levels and 20 and 80 are the stop and start priorities respectively. You can adjust as needed.

# chkconfig –add tomcat  

# chkconfig –level 234 tomcat on  

Verify it:

# chkconfig –list tomcat  
tomcat          0:off   1:off   2:on    3:on    4:on    5:off   6:off

December 3, 2011 Posted by | Java, Shell Script, Tips & Tricks, Tomcat | , , , , | Leave a comment

bandwidth.sh

###########################################################
## bandwidth.sh ##
###########################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
###########################################################
## Hi, ##
## The Bndwidth Scan process the server has been completed. ##
## For Bandwidth Scan Report, please check the attached bandwidth Report. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
###########################################################
#! /bin/bash

/bin/echo “=========================================================” > /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “THE Bandwidth Report of virlnx3.Securehostdns.com at $(date)” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “=========================================================” >> /REPORTS/vnstat.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “Bandwidth Report by Day”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “————————–”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/usr/bin/vnstat -u -i eth0
/usr/bin/vnstat -d >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/vnstat.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “Bandwidth Report by Hour”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “—————————”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/usr/bin/vnstat -h >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/vnstat.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “Bandwidth Report by Month”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “—————————–”  >> /REPORTS/vnstat.log_$(date +%d%m%y)
/usr/bin/vnstat -m >> /REPORTS/vnstat.log_$(date +%d%m%y)
/bin/echo “—————————————————” >> /REPORTS/vnstat.log_$(date +%d%m%y)

mutt -s “Bandwidth Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/vnstat.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “Bandwidth Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/vnstat.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

October 18, 2011 Posted by | Security, Shell Script, Tips & Tricks, Unix/Linux | , , , , , , | Leave a comment

load_alert.sh

###########################################################
## load_alert.sh ##
###########################################################
#!/bin/bash
EMAIL=”unixserv@unixserveradmin.com”
SUBJECT=”Alert $(hostname) load average is $L05″
TEMPFILE=”/tmp/$(hostname)”
TOPLOAD=”20″
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 10 CPU consuming processes: |” >> $TEMPFILE
ps aux | head -1 >> $TEMPFILE
ps aux –no-headers | sort -rn +2 | head -20 >> $TEMPFILE
echo “| Top 10 memory-consuming processes: |” >> $TEMPFILE
ps aux –no-headers| sort -rn +3 | head >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Memory and Swap status: |” >> $TEMPFILE
/usr/bin/free -m >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Active network connection: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/bin/netstat -tnup | grep ESTA >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
echo “| Disk Space information: |” >> $TEMPFILE
echo “——————————————-” >> $TEMPFILE
/bin/df -h >> $TEMPFILE
echo “—————–THE END——————-” >> $TEMPFILE
L05=”$(uptime|awk ‘{print $(NF-2)}’|cut -d. -f1)”
if test $L05 -gt $TOPLOAD
then
mail -s “$SUBJECT  $L05” “$EMAIL” < $TEMPFILE
fi
rm -f $TEMPFILE

August 27, 2011 Posted by | Shell Script | | Leave a comment

Excessive mail sent by an user alert for cPanel

If you need a simple script to alert you by mail when a user exceeds a predefined mail rate limit, then check this out.

#######################################################################
#!/bin/bash
mailflag=0
limit=5
mailid=unixserv@unixserveradmin.com
chkdate=`date -d “60 minute ago” +%Y-%m-%d %k`
mailfile=$(mktemp)
for i in `mysql –batch –skip-column-names -e ” use eximstats; select user,email,msgid from sends where
mailtime like ‘$chkdate%’;” | awk ‘{print $1}’ | sort | uniq -c | sort -n | sed ‘s/^ *//’| sed ‘s/ /:/’`
do
k=`echo $i | cut -d ‘:’ -f1`
username=`echo $i | cut -d ‘:’ -f2`
if [ “$k” -gt “$limit” ]
then
mailflag=1
echo -e “nnn Excessive mail sent by user : $username nn” >> $mailfile
echo -e “=========================================” >> $mailfile
echo ”     mailtime           msgid   email   processed       user    size    ip      auth” >> $mailfile
mysql –batch –skip-column-names -e ” use eximstats; select * from sends where mailtime like ‘$chkdate%’ and
user like ‘$username’;” >> $mailfile
echo -e “=========================================” >> $mailfile
fi
done
if [ “$mailflag” == 1 ]
then
cat $mailfile | mail -s “Excessive mail sent by user” $mailid
fi
rm -rf $mailfile

# You need to edit the limit and mailid variables according to your requirement. eg:
limit=300
mailid=unixserv@unixserveradmin.com
#######################################################################

August 9, 2011 Posted by | cPanel, Exim, Shell Script | , , | 1 Comment

disk_space_scan.sh

###########################################################
## disk_space_scan.sh ##
###########################################################
#!/bin/bash

df -h > /REPORTS/msg1.txt

NUM1=$(df -h /dev/sda2 | grep ‘dev’ | cut -c 41-42)

if [ $NUM1 -gt 95 ]; then
mutt -s “Server1-CRITICAL DISK SPACE /usr $(df -h /dev/sda2 | grep ‘dev’ | cut -c 41-43)” unixserv@unixserveradmin.com -c info@unixserveradmin.com  < /REPORTS/msg1.txt
else
echo “Services is NOT RUNNING” > /dev/null
fi

NUM1=$(df -h /dev/sda5 | grep ‘dev’ | cut -c 41-42)

if [ $NUM1 -gt 95 ]; then
mutt -s “Server1-CRITICAL DISK SPACE / $(df -h /dev/sda5 | grep ‘dev’ | cut -c 41-43)”
unixserv@unixserveradmin.com -c info@unixserveradmin.com < /REPORTS/msg1.txt
else
echo “Services is NOT RUNNING” > /dev/null
fi

NUM1=$(df -h /dev/sda7 | grep ‘dev’ | cut -c 41-42)

if [ $NUM1 -gt 95 ]; then
mutt -s “Server1-CRITICAL DISK SPACE /home $(df -h /dev/sda7 | grep ‘dev’ | cut -c 41-43)” unixserv@unixserveradmin.com -c info@unixserveradmin.com < /REPORTS/msg1.txt
else
echo “Services is NOT RUNNING” > /dev/null
fi

NUM1=$(df -h /dev/sdb1 | grep ‘dev’ | cut -c 41-42)

if [ $NUM1 -gt 95 ]; then
mutt -s “Server1-CRITICAL DISK SPACE /var $(df -h /dev/sdb1 | grep ‘dev’ | cut -c 41-43)” unixserv@unixserveradmin.com -c info@unixserveradmin.com < /REPORTS/msg1.txt
else
echo “Services is NOT RUNNING” > /dev/null
fi

August 7, 2011 Posted by | Shell Script | | Leave a comment

How to Restore MySQL database using mysqldump

#!/bin/bash
##################################################
####  MySQL Restore Script , Created By UnixServerAdmin  ####
##################################################

rm -rf /backup/error_mysqldump.txt 2> /dev/null
rm -rf /backup/error_Mysqlzip.txt 2> /dev/null
rm -rf /backup/dblist.txt 2> /dev/null

## MySQL Databse Backup ##

cd /backup/

mysql -u ‘root’ -p -e ‘show databases’ > dblisttemp.txt
sed ‘1d’ dblisttemp.txt > dblist.txt
rm -rf /backup/dblisttemp.txt 2> /dev/null

mkdir /backup/Mysql/`date +%d.%m.%Y`

for database in $(cat /backup/dblist.txt)
do
mysqldump -u ‘root’ -p’pass’ $database > /backup/MySQL/$database.sql 2>> /backup/error_mysqldump.txt
done

cd MySQL/
dumpsize=`du -csh *.sql| tail -1 | cut -f1`

for database in $(cat /backup/dblist.txt)
do
zip -r `date +%d.%m.%Y`/$database.zip $database.sql 2>> /backup/error_Mysqlzip.txt
rm -rf $database.sql
done

May 29, 2011 Posted by | MySQL, Shell Script | , , | 1 Comment

daily_report.sh

#############################################################
## daily_report.sh ##
#############################################################
## Script for Daily Report of Server ##
#############################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Folowing in msg.txt file ##
#############################################################
## Hi, ##
## The Daily Server Report is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
#############################################################
#! /bin/bash

/bin/mkdir /REPORTS 2> /dev/null

/bin/echo ”                                  DAILY SERVER REPORT FOR $(/bin/hostname | tr ‘a-z’ ‘A-Z’)” > /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                             ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                     DATE : $(date)” >> /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “#######################################” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)

/bin/echo “INFRASTRUCTURE UP-TIME REPORT” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/uptime >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “MAIN DOMAINS = $(/bin/cat /etc/domainusers | wc -l)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “TOTAL DOMAINS = $(/bin/ls /var/named/ | wc -l)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SERVER INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hardware Summary” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR [CPU]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR I     Intel Xeon-Westmere 5620-Quadcore [2.4GHz]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PROCESSOR II    Intel Xeon-Westmere 5620-Quadcore [2.4GHz]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PHYSICAL MEMORY [RAM]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 1           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 2           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 3           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 4           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 5           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “RAM slot 6           OEM DDR3 2GB DDR3 [2GB]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “HARD DISK DRIVE [HDD]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 1            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB     RAID” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 2            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB     RAID” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Hard Drive 3            Western Digital WD RE4 WD2003FYYS      SIZE = 1TB [Backup]” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PARTITION & DISK SPACE UTILIZATION REPORT” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/df -hT >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “MEMORY USAGE” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/vmstat -st | tr ‘a-z’ ‘A-Z’ | head  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “CPU STATISTICS & I/O STATISTICS FOR DEVICES, PARTITIONS AND NETWORK FILESYSTEMS (NFS)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/iostat >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “NETWORK & TRAFFIC INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Network Interface :  eth1 (Public)     Uplink speed:         1000 (Mbps)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Server address:   X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Gateway:          X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Netmask:          X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Secondary addresses:   X.X.X.X  to X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                       X.X.X.X  to X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Network Interface : eth0 (Private)     Uplink speed:         1000 (Mbps)” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Server address:    X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Gateway:           X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Netmask:           X.X.X.X” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/etc/init.d/httpd status | grep ‘Total Traffic’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SOFTWARE INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “Operating System” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /proc/version >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “PHP & MYSQL” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/local/bin/php -v   >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
mysql -V  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “USER ACCESS REPORT [CURRENT MONTH] ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/last | grep $(date | cut -c 5-7)| sed s/X.X.X.X/UnixserV/gi >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SERVER REBOOTS” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/usr/bin/last | grep boot >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SHELL ACCESS USER LIST” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /etc/passwd | grep ‘/bin/bash’ | cut -d: -f1 | tr ‘a-z’ ‘A-Z’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “SECURITY ANALYSIS” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
#/usr/bin/nmap -v $(ifconfig eth1 | grep ‘inet addr’ | cut -c 21-34) >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “BACKUP INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/ls -l /disk2/ | cut -c 30-52 | tail -n3 | tr ‘a-z’ ‘A-Z’  >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “DOMAINS INFORMATION” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/cat /etc/httpd/conf/httpd.conf | grep -A1 ‘<VirtualHost’ >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo “This report is generated by the Unixserveradmin.com Security Team” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
/bin/echo ”                                                            ” >> /REPORTS/Daily_Report_$(date +%d%m%y)
#/bin/mv /REPORTS/Daily_Report_$(date +%d%m%y) /REPORTS/Daily_Report_$(date +%d%m%y).txt

mutt -s “SERVER REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Daily_Report_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “SERVER REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Daily_Report_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

May 8, 2011 Posted by | Shell Script | | 3 Comments

backup_remote.sh

#############################################################
## backup_remote.sh ##
#############################################################
## Script for Data Backup Transfer on Remote Server by rsync ##
#############################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
#############################################################
## Hi, ##
## The Backup Report of the  server is attached with this mail. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
#############################################################
## X.X.X.X –> Remote Server IP Address ##
## ssh -p 8765 –> SSH Port No. 8765 ##
#############################################################
#! /bin/bash

/bin/echo “========================================================” > /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP IS STARTED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “BACKUP LOGS ARE AS FOLLOWS:”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/Backup.log_$(date +%d%m%y)
/usr/bin/rsync -avh -e “ssh -p 8765 –delete-after” /disk2/daily X.X.X.X:/disk3/ >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “THE BACKUP HAS BEEN COMPLETED AT $(date)” >> /REPORTS/Backup.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/Backup.log_$(date +%d%m%y)

mutt -s “REMOTE_BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “REMOTE_BACKUP REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/Backup.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

May 7, 2011 Posted by | Shell Script | , , | 5 Comments

clamav_scan.sh

###########################################################
## clamav_scan.sh ##
###########################################################
## Make a Directory /REPORTS ##
## Make a file msg.txt under /REPORTS Directory ##
## Write Following in msg.txt file ##
###########################################################
## Hi, ##
## The ClamAV Scan process of “/home” partition of the server has been completed. ##
## For ClamAV Scan Report, please check the attached clamav Report. ##
## Thanks & Regards, ##
## Unixserveradmin.com Security Team ##
###########################################################
#! /bin/bash

/bin/echo “==========================================================” > /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “THE ClamAV Scan is started at $(date)” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “==========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “ClamAV Update Logs:”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/usr/bin/freshclam >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo ”      ” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “========================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “ClamAV Logs are as follows:”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–”  >> /REPORTS/clamav.log_$(date +%d%m%y)
/usr/bin/clamdscan –remove /home/ >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “——————————————————–” >> /REPORTS/clamav.log_$(date +%d%m%y)

/bin/echo “==================================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “THE ClamAV Scan has been completed at $(date)” >> /REPORTS/clamav.log_$(date +%d%m%y)
/bin/echo “==================================================================” >> /REPORTS/clamav.log_$(date +%d%m%y)

mutt -s “ClamAV Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/clamav.log_$(date +%d%m%y) unixserv@unixserveradmin.com < /REPORTS/msg.txt

mutt -s “ClamAV Scan REPORT $(hostname | tr ‘a-z’ ‘A-Z’)” -a /REPORTS/clamav.log_$(date +%d%m%y) info@unixserveradmin.com < /REPORTS/msg.txt

May 6, 2011 Posted by | Security, Shell Script | , , | 2 Comments

load_scan.sh

###########################################################
## load_scan.sh ##
###########################################################
#!/bin/bash
#This script will send mail alert if load is high in server with w,pstree,mysqladmin,exim queue results

echo “############ SERVER LOAD REPORT ############” > /load.txt

#Enter the Load Average
l=”30″

v=`cat /proc/loadavg |awk ‘{print $1 }’ |cut -d”.” -f1 `

if [ $v -ge $l ]
then

cd /
touch load.txt

#Enter the Text that you needs to dispaly on mail

echo “Please check the Server and reduce the Load” >> /load.txt
echo ”       ” >> /load.txt
echo ”       ” >> /load.txt

echo  “LOAD STATUS RUN ON” `date` >> /load.txt
echo “====================================================================” >> /load.txt
echo “====================================================================” >> /load.txt

echo ” W Results  ” >> /load.txt

echo ”       ” >> /load.txt
echo ”       ” >> /load.txt
w >> /load.txt
echo “====================================================================” >> /load.txt
echo “====================================================================” >> /load.txt

echo “TOP Results” >> /load.txt
echo “====================================================================” >> /load.txt

#pstree -apu >> load.txt
ps -eo pcpu,pid,user,args | sort -k 1 -r | head -20 >> /load.txt
echo “====================================================================” >> /load.txt
echo “====================================================================” >> /load.txt
echo ”       ” >> /load.txt
echo ”       ” >> /load.txt
echo “MYSQLADMIN Results” >> /load.txt
echo “====================================================================” >> /load.txt

echo ”       ” >> /load.txt
echo ”       ” >> /load.txt
mysqladmin proc >> /load.txt

echo “====================================================================” >> /load.txt
echo “====================================================================” >> /load.txt

echo “NETSTAT RESULTS (FOR CHKING DDOS ATTACK..10 HIGH HTTP CONNECTIONS ) ” >>/load.txt

echo >>/load.txt
netstat -plan |grep :80 | awk ‘{print $5}’ |cut -d: -f1 |sort |uniq -c |sort -n |tail -10 >>/load.txt

echo “====================================================================” >> /load.txt
echo “====================================================================” >> /load.txt

echo ”       ” >> /load.txt
echo ”       ” >> /load.txt
echo ”       ” >> /load.txt
echo “Thanks & Regards” >> /load.txt
echo “Unixserveradmin.com Security Team” >> /load.txt

mail -s “!!!Urgent HIGH LOAD Avg=$v in  $HOSTNAME ” unixserv@unixserveradmin.com info@unixserveradmin.com  < /load.txt

>/load.txt

fi
###########################################################

May 5, 2011 Posted by | Shell Script | | 3 Comments

mail_queue.sh

#################################################
# Script for Mail Queue Delete for Exim in cPanel
#################################################
# mail_queue.sh
#################################################
##### Mail Queue Cleaner #####
#!/bin/bash
echo Clearing Mail Queue..
cd /var/spool/exim/input
rm -rf *
exit
#################################################

May 4, 2011 Posted by | Mail, Shell Script | , | 1 Comment