B / Y / U / S
HOME À¥ È£½ºÆà µµ¸ÞÀÎ ¸Å´º¾ó °í°´Áö¿ø ¼³Á¤Á¤º¸ °èÁ¤½Åû 2024-12-23 Monday 
À¥ È£½ºÆÃ
# °øÁö »çÇ×
# ÀÚÁÖ ¹¯´Â Áú¹®
# Áú¹®°ú ´äº¯
# °¡ÀÔ ¹®ÀÇ
Ä¿¹Â´ÏƼ
# ÀÚÀ¯°Ô½ÃÆÇ
# ¸®´ª½ºÆÁ
# ¾ÆÀÌÅ¥ Å×½ºÆ®
# ³»È¨ ¼Ò°³
# °Ö·¯¸®
# ÀÚ·á½Ç

  ¸®´ª½ºÆÁ  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
Regist Addr [ 192.168.0.2 ] ¸ñ·Ïº¸±â À­±Û ¾Æ·§±Û
Á¤±ÔÇ¥Çö½Ä [ »ó¼¼ °Ë»ö ]
Page Loading [ 0.02 Sec ] SQL Time [ 0 Sec ]

Copyleft 1999-2024 by JSBoard Open Project
Theme Designed by IDOO And follow GPL2

°³ÀÎÁ¤º¸ Ãë±Þ¹æħ ÀÌ¿ë ¾à°ü »çÀÌÆ® ¸Ê ¾îµå¹Î °ü¸®