Statistics site Traffic

Source: Internet
Author: User

#!/bin/bash
#write by Zhenglong 20150730

#Centos
# http Sataistics
Log_path1=/usr/local/apache/logs/access_log
domain= "Www.xx.com"
email= "[email protected]"
maketime= ' Date +%d/%b/%y '
logdate= ' date-d "Yesterday" +%y-%m-%d '
cat $log _path1|grep $maketime >/usr/local/apache/logs/tmp.log
Log_path=/usr/local/apache/logs/tmp.log

total_visit= ' wc-l ${log_path} | awk ' {print '} '
total_bandwidth= ' awk-v total=0 ' {total+=$10}end{print total/1024/1024} ' ${log_path} '
total_unique= ' awk ' {ip[$1]++}end{print asort (IP)} ' ${log_path} '
ip_pv= ' awk ' {ip[$1]++}end{for (k in IP) {print ip[k],k}} ' ${log_path} | sort-rn | head-20 '
url_num= ' awk ' {url[$7]++}end{for (k in URL) {print url[k],k}} ' ${log_path} | sort-rn | head-20 '
referer= ' awk-v domain= $domain ' $11!~/http:\/\/[^/]* ' "$domain" '/{url[$11]++}end{for (k in URL) {print url[k],k}} ' $ {Log_path} | Sort-rn | Head-20 '
notfound= ' awk ' $9 = = 404 {url[$7]++}end{for (k in URL) {print url[k],k}} ' ${log_path} | sort-rn | head-20 '
spider= ' awk-f ' "" $6 ~/baiduspider/{spider["Baiduspider"]++} $6 ~/googlebot/{spider["Googlebot"]++}end{for (k in Spider) {print k,spider[k]}} ' ${log_path} '
search= ' awk-f ' "' $4 ~/http:\/\/Www\.baidu\.com/{search["Baidu_search"]++} $4 ~/http:\/\/Www\.google\.com/{search["Google_search"]++}end{for (k in search) {print k,search[k]}} ' ${log_path} '
echo-e "overview\nreport generation Time: ' ${maketime} ' \ntotal visits ' ${total_visit} ' \ntotal bandwidth ' ${total_ Bandwidth} ' M\nuv${total_unique}\n\nip Access Statistics\n${ip_pv}\n\nurl access Statistics\n${url_num}\n\nsource Page statistics\n${referer}\n\n404statistics\n${notfound}\n\nthe Spider Statistics\n${spider}\n\nsearch Engine SOURCE Statistics\n${search} "|mail-s" $domain $logdate Log Statistics "${email}

Statistics site Traffic

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.