关于pv的那些事!!
遗留问题:whid=1969的日志记录是什么意思?
网站站点信息未分配的时候,会用1969去代替站点信息。
PV:页面浏览量(page view),用户每次打开或刷新一次网页即被计算一次.
关于pv的计算,我们首先考虑下最简单的情况:计算易迅网每天的的pv,这个pv不分站点和渠道.
我们打开跳板机,进入75机器的shell目录.
打开shell目录里的siteKeyData_AllSite.sh,开始研究这个文件.
我们注意到这个脚本文件里,有一个getPV函数,我们来看下这个函数.
pv计算规则:
①页面跳转,并且当前页面id合法;
②网站端的,不计无线;
③IFrame内嵌页卡不计入PV;
④外部投放的页卡不计入PV;
⑤符合以上4点的就算做一条pv,pv数加1.
我们根据以上5点,写一个测试脚本vic_AllSite_pv.sh.算一下20140909号的的一天的易迅网的pv量.
#!/bin/bash ## file name: vic_AllSite_pv.sh ## example: ./vic_AllSite_pv.sh #获取当前脚本所在路径
currdir=$(cd "$(dirname "$")"; pwd) #进入脚本所在目录
cd $currdir ## PHP path
PHP_BIN="/usr/local/php/bin/php" ## 显示脚本的正确用法
function showUsage()
{
echo "Usage: sh vic_AllSite_pv.sh [log_file_time]" >&
exit ;
} ## 如果参数为0,则显示该脚本的用法
if [ $# = ]; then
showUsage
fi ## 变量初始化
start_time=`date "+%Y-%m-%d %H:%M:%S.%N"`
if [ $# = ]; then
log_file_time=$
fi ## 处理结果的存储文件名
result_pv_filename="../data_today/""vic_ALLSITE_PV""_""$log_file_time" ## site_key
## warehouseid - 各分站总体数据
## warehouseid_1 - 各分站商品详情页数据 ## get PV
function getPV()
{ log_file_time=$
log_filename="row_data_"$
log_filename=$log_filename"*" awk -v fdate=$log_file_time -v ftype=$period_type -F"\t" '{
## 不是页面跳转或者当前页面id不合法的请求,过滤掉
if($ != || int($) < ) next; ## 不计无线
wh_id = int($);
## if ( (wh_id == ) || (wh_id == ) || (wh_id == ) || (wh_id == ) ) next;
if ( (wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) ) next; ## IFrame内嵌页卡不计入PV
if( (int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ) next; ## 外部投放的页卡不计入PV
if( == $ && !match($, /buy\.(51buy|yixun)\.com/)) next; if((int($) % == ) || match($, /item\.(51buy|yixun)\.com/)) {
pvArr["0_1"] = pvArr["0_1"] + ;
} if((int($) == ) || match($, /buy\.(51buy|yixun)\.com\/cart\.html/)) {
pvArr["0_2"] = pvArr["0_2"] + ;
} if((int($) == ) || (int($) == ) || match($, /buy\.(51buy|yixun)\.com\/order.html/)) {
pvArr["0_3"] = pvArr["0_3"] + ;
} ## key: 分站ID
pvArr[""] = pvArr[""] + ;
} END {
for(key in pvArr)
{
print key"\t"pvArr[key] > "../data_today/""ALLSITE_PV_"ftype"_"fdate
}
}' ../data_today/$log_filename
} ## start execute
getPV $log_file_time ## store result to DB
##${PHP_BIN} -c . -f siteKeyDataStore_AllSite.php $result_pv_filename $result_uv_filename $result_btnuv_filename ## process end time
end_time=`date "+%Y-%m-%d %H:%M:%S.%N"` echo -e "ALLSITE_PV_Data:""["",""$log_file_time""]:""$start_time""~""$end_time"
vic_AllSite_pv.sh
计算结果如下:
0 3430852 //全站一天的pv
0_1 1071985 //商品详情页pv
0_2 76135 //购物车pv
0_3 40871 //下单页pv
全站的pv比较好算,那么各分站的pv又该怎么去算呢.
其实有了前面的基础,分站的计算就比较简单了,我们更改一下脚本.
#!/bin/bash ## file name: vic_Sites_pv.sh ## example: ./vic_Sites_pv.sh #获取当前脚本所在路径
currdir=$(cd "$(dirname "$")"; pwd) #进入脚本所在目录
cd $currdir ## PHP path
PHP_BIN="/usr/local/php/bin/php" ## 显示脚本的正确用法
function showUsage()
{
echo "Usage: sh vic_Sites_pv.sh [log_file_time]" >&
exit ;
} ## 如果参数为0,则显示该脚本的用法
if [ $# = ]; then
showUsage
fi ## 变量初始化
start_time=`date "+%Y-%m-%d %H:%M:%S.%N"`
if [ $# = ]; then
log_file_time=$
fi ## 处理结果的存储文件名
result_pv_filename="../data_today/""vic_SITES_PV""_""$log_file_time" ## site_key
## warehouseid - 各分站总体数据
## warehouseid_1 - 各分站商品详情页数据 ## get PV
function getPV()
{ log_file_time=$
log_filename="row_data_"$
log_filename=$log_filename"*" awk -v fdate=$log_file_time -v ftype=$period_type -F"\t" '{
## 不是页面跳转或者当前页面id不合法的请求,过滤掉
if($ != || int($) < ) next; ## 不计无线
wh_id = int($);
## if ( (wh_id == ) || (wh_id == ) || (wh_id == ) || (wh_id == ) ) next;
if ( (wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) &&
(wh_id != ) ) next; ## IFrame内嵌页卡不计入PV
if( (int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ||
(int($) == ) || (int($) == ) ) next; ## 外部投放的页卡不计入PV
if( == $ && !match($, /buy\.(51buy|yixun)\.com/)) next; if((int($) % == ) || match($, /item\.(51buy|yixun)\.com/)) {
pvArr[$"_1"] = pvArr[$"_1"] + ;
} if((int($) == ) || match($, /buy\.(51buy|yixun)\.com\/cart\.html/)) {
pvArr[$"_2"] = pvArr[$"_2"] + ;
} if((int($) == ) || (int($) == ) || match($, /buy\.(51buy|yixun)\.com\/order.html/)) {
pvArr[$"_3"] = pvArr[$"_3"] + ;
} ## key: 分站ID
pvArr[$] = pvArr[$] + ;
} END {
for(key in pvArr)
{
print key"\t"pvArr[key] > "../data_today/""SITES_PV_"ftype"_"fdate
}
}' ../data_today/$log_filename
} ## start execute
getPV $log_file_time ## store result to DB
##${PHP_BIN} -c . -f siteKeyDataStore_AllSite.php $result_pv_filename $result_uv_filename $result_btnuv_filename ## process end time
end_time=`date "+%Y-%m-%d %H:%M:%S.%N"` echo -e "SITES_PV_Data:""["",""$log_file_time""]:""$start_time""~""$end_time"
计算结果如下:
2001_3 5789
1_3 16977
4001_1 76058
2001 550962
1969_1 22
4001_2 4795
3001 314763
1969_2 1
4001_3 2252
4001 239516
5001 134831
3001_1 93959
3001_2 6710
1001_1 291933
3001_3 3231
5001_1 40875
1001_2 19668
5001_2 2934
1001_3 11163
5001_3 1459
1969 19877
1 1283055
2001_1 181135
1_1 388003
2001_2 10970
1_2 31057
1001 887848
剩下的就是渠道pv数据的计算了.我们另起一章,详细解说.
关于pv的那些事!!的更多相关文章
- BI任务列表
了解点击流系统和pv/uv的相关计算 关于pv的那些事!! ···············································2014-09-10 homework做了些什 ...
- @ConfigurationProperties 配置详解
文章转自 https://blog.csdn.net/qq_26000415/article/details/78942494 前言新的一年到了,在这里先祝大家新年快乐.我们在上一篇spring bo ...
- 网络服务器搭建的那些事(PV QPS Throughput) 转载
一.前言: 从事后台sever开发的同学,代码开发完成之后,上线之前,总会进行各种黑盒白盒测试,压测.正确性测试... 而测试同学,会给开发同学一份测试报告,需要开发同学进行确认...问题来了,里面好 ...
- Pinterest 架构:两年内月 PV 从零到百亿【翻译】
原文地址 这篇文章,采用 Markdown 方式,写的还是比较实在的,要是有架构图就好了. Pinterest 是图片版的 Twitter,用户把自己感兴趣的东西用图钉(Pins)钉在钉板(PinBo ...
- 从100PV到1亿级PV网站架构演变
如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不 ...
- 两年内从零到每月十亿 PV 的发展来谈 Pinterest 的架构设计(转)
原文:Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years 译文:两年内从零到每月十亿 PV ...
- [转载]从100PV到1亿级PV网站架构演变
原文地址:http://www.uml.org.cn/zjjs/201307172.asp 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不同的方法,不同的方法下有 ...
- 关于Redis的那些事
1. MySql+Memcached架构的问题 Memcached采用客户端-服务器的架构,客户端和服务器端的通讯使用自定义的协议标准,只要满足协议格式要求,客户端Library可以用任何语言实现. ...
- Pinterest架构:两年内月PV从零到百亿
Pinterest正经历了指数级曲线般的增长,每隔一个半月就翻番.在这两年里,Pinterest,从 每月PV量0增长到100亿,从两名c创始人和一个工程师成长为四十个工程师,从一台MySQL 服务器 ...
随机推荐
- 菜鸟的ubuntu学习笔记
初识ubuntu感觉这个系统绝对够高大上,简洁的桌面,流畅的操作界面,在加上神秘的终端控制,突然感觉自己的世界真的好渺小,所以我下定决心在接下来的日子里我要告别windows,把ubuntu学好,尝试 ...
- C#事件(Event)学习日记
event 关键字的来由,为了简化自定义方法的构建来为委托调用列表增加和删除方法. 在编译器处理 event 关键字的时候,它会自动提供注册和注销方法以及任何必要的委托类型成员变量. 这些委托成员变量 ...
- UIImageView之我的动画为什么停了?UIImageView, highLighted,animationImages
如果你的动画总是停了!停了!停了!不管你想不想都停,这里有个参考,你可以看看!这只是一种可能性!!! 受最近看到段子影响,画风略诡异,不喜勿喷. 最近在“刻”动画!!! 为什么是“刻”,动画写了3周啊 ...
- Android仿微信SlideView聊天列表滑动删除效果
package com.ryg.slideview; import com.ryg.slideview.MainActivity.MessageItem; //Download by http://w ...
- 修改EditText的光标位置
Android 的 EditText 控件默认获取焦点的时候, 插入光标是在第一个位置的,如果EditText中设置了文本, 这个时候光标是在文本的最前面, 而不是文本的最后. 为了方便用户使用, 需 ...
- Java接口修饰符详解
接口就是提供一种统一的”协议”,而接口中的属性也属于“协议”中的成员.它们是公共的,静态的,最终的常量.相当于全局常量.抽象类是不“完全”的类,相当于是接口和具体类的一个中间层.即满足接口的抽象,也满 ...
- 使用 Chef 管理 Azure 资源
发布于 2014-07-08 作者 陈 忠岳 Chef 是一款开源的开发运营(DevOps)工具,用以应对 IT 基础设施方面的挑战.微软开放技术有限公司(简称"微软开放技术" ...
- Linux Shell编程(29)——函数
和"真正的"编程语言一样, Bash也有函数,虽然在某些实现方面稍有些限制. 一个函数是一个子程序,用于实现一串操作的代码块,它是完成特定任务的"黑盒子". 当 ...
- 成为Web开发人员的7个简单步骤
你想成为一名 Web 开发人员,但现在你面前有这样一个问题,那就是你没有在高科技行业工作的经验.你上了一些课程,也花了时间在个人编码项目上,但是你的简历上关于“经验”的部分仍然不为企业承认.过渡到一个 ...
- Java第一次写的流布局图形界面,留个纪念
package jisuanqi; import java.awt.*; public class MyFrame extends Frame{ //继承Frame类 public MyFrame() ...