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