Web server error log interception and various code statistics

Source: Internet
Author: User

#/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 "Does want to do $ out" Web_code "Count?" (y/n) (default:n) __ "
Read do
Do=${do:=n}
If ["$do" = "Y"];then
echo "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" |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" |wc-l)
echo "$curday: URL error_400 count: $error _400" >>/home/count.log
ok_200=$ (Awk-f ' ["] ' {print $all} ' $logdir |grep" + "|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 server error log interception and various code statistics

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.