码迷,mamicode.com
首页 > Web开发 > 详细

web服务器错误日志截取及各类代码统计

时间:2016-05-10 23:37:14      阅读:236      评论:0      收藏:0      [点我收藏+]

标签:

#/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

 

web服务器错误日志截取及各类代码统计

标签:

原文地址:http://www.cnblogs.com/zksfyz/p/5479689.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!