首页 > Web开发 > 详细

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

时间:2016-05-10 23:36:23      阅读:342      评论: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
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!