标签:
#/bin/sh
#*********************
# get url error log
#*********************
curday=`date ‘+%Y-%m-%d %H:%M:%S‘`
echo "input log file dir!"
read logdir
Code=`awk -F ‘[ "]+‘ ‘{print $all}‘ $logdir|grep ‘GET‘|grep ‘500‘`
echo "Do you want to do $1 out "Web_Code" count ? (y/n) (default: n) __"
read do
do=${do:=n}
if [ "$do" = "y" ];then
echo "Out put web code in "/home/count.log" file!\n"
error_501=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "501"|wc -l)
echo "$curday:URL error_501 count:$error_501" >>/home/count.log
error_500=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "500"|wc -l)
echo "$curday:URL error_500 count:$error_500" >>/home/count.log
error_404=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "404"|wc -l)
echo "$curday:URL error_404 count:$error_404" >>/home/count.log
error_403=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "403"|wc -l)
echo "$curday:URL error_403 count:$error_403" >>/home/count.log
error_400=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "400"|wc -l)
echo "$curday:URL error_400 count:$error_400" >>/home/count.log
ok_200=$(awk -F ‘[ " ]‘ ‘{print $all}‘ $logdir|grep "200"|wc -l)
echo "$curday:URL OK_200 count:$ok_200" >>/home/count.log
fi
echo $Code >>/home/error.log
sleep 2
echo "exit"
exit 0
标签:
原文地址:http://www.cnblogs.com/zksfyz/p/5479689.html