温馨提示×

温馨提示×

您好,登录后才能下订单哦!

密码登录×
登录注册×
其他方式登录
点击 登录注册 即表示同意《亿速云用户服务条款》

统计站点访问量

发布时间:2020-07-14 20:06:07 来源:网络 阅读:425 作者:blank614 栏目:安全技术

#!/bin/bash
#write by zhenglong 20150730

#Centos
# http sataistics
 log_path2=/usr/local/apache/logs/access_log
 domain="www.xx.com"
 email="1525356778@qq.com"
 maketime=`date +%d/%b/%Y`
 logdate=`date -d "yesterday" +%Y-%m-%d`
 cat $log_path2|grep $maketime > /usr/local/apache/logs/tmp.log
 log_path=/usr/local/apache/logs/tmp.log

 total_visit=`wc -l ${log_path} | awk '{print $1}'`
 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}

向AI问一下细节

免责声明:本站发布的内容(图片、视频和文字)以原创、转载和分享为主,文章观点不代表本网站立场,如果涉及侵权请联系站长邮箱:is@yisu.com进行举报,并提供相关证据,一经查实,将立刻删除涉嫌侵权内容。

AI