|
|
|
¸®´ª½ºÆÁ Go Unix Power Tools Online Book
Go Bash Guide
|
|
Read No. 116 article |
2002-02-27 22:25:00 |
|
|
|
|
NickName |
Ç®ºñ´© |
Subject |
À¥ µ¥¸ó °¨½Ã ½© |
|
|
¿øº»: http://linux.sarang.net/~darchon/linux/
#!/bin/sh
#
# httpd number checking & logging
# Beom-Seok Park ( darchon at linux dot sarang dot net )
LIMIT=200 #Maxinum httpd number
INTERVAL=60 #Checking interval time (seconds)
LOGDIR=/root/log #Logging directory
LOGFILE=check-$(date +%Y%m%d-%k%M) #Log file name
echo "httpd number checking & logging script"
if [ -x $LOGDIR ];then
while true
do
#NUM=`pstree |grep httpd| tr -d [:alpha:][:blank:][:cntrl:][:punct:]`
NUM=`ps auxw|grep httpd|grep -v grep | wc -l`
if [ $NUM -gt $LIMIT ]; then
echo "current httpd number is $NUM. this is bigger than maximum
$LIMIT. start logging."
echo "print \"pstree\"" > $LOGDIR/$LOGFILE
pstree >> $LOGDIR/$LOGFILE
echo >> $LOGDIR/$LOGFILE
echo "print \"netstat -an |grep ES | awk '{print \$5}' | sort\"" >>
$LOGDIR/$LOGFILE
netstat -an |grep ES | awk '{print $5}' | sort >> $LOGDIR/$LOGFILE
echo "print \"netstat -an |grep ES | awk '{print \$5}' | wc -l\"" >>
$LOGDIR/$LOGFILE
netstat -an |grep ES | awk '{print $5}' | wc -l >> $LOGDIR/$LOGFILE
echo >> $LOGDIR/$LOGFILE
echo "print \"netstat -an |grep SYN\"" >> $LOGDIR/$LOGFILE
netstat -an |grep SYN >> $LOGDIR/$LOGFILE
PID=`ps auxw|grep httpd|grep -v grep |awk '{print $2}'`
if [ "$PID" != "" ]; then
echo >> $LOGDIR/$LOGFILE
for i in $PID; do
echo >> $LOGDIR/$LOGFILE
echo "print \"ls -al /proc/$i |grep cwd\"" >>$LOGDIR/$LOGFILE
ls -al /proc/$i |grep cwd >> $LOGDIR/$LOGFILE
done
else
echo "no httpd" >> $LOGDIR/$LOGFILE
fi
else
echo "current httpd number is $NUM. this is smaller than maximum
$LIMIT."
fi
sleep $INTERVAL
done
else
echo "LOGDIR $LOGDIR does not exist."
exit 0
fi
|
|
Page Loading [ 0.03 Sec ]
SQL Time [ 0 Sec ]
|
|
|