遗留问题: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的那些事!!的更多相关文章

  1. BI任务列表

    了解点击流系统和pv/uv的相关计算 关于pv的那些事!! ···············································2014-09-10 homework做了些什 ...

  2. @ConfigurationProperties 配置详解

    文章转自 https://blog.csdn.net/qq_26000415/article/details/78942494 前言新的一年到了,在这里先祝大家新年快乐.我们在上一篇spring bo ...

  3. 网络服务器搭建的那些事(PV QPS Throughput) 转载

    一.前言: 从事后台sever开发的同学,代码开发完成之后,上线之前,总会进行各种黑盒白盒测试,压测.正确性测试... 而测试同学,会给开发同学一份测试报告,需要开发同学进行确认...问题来了,里面好 ...

  4. Pinterest 架构:两年内月 PV 从零到百亿【翻译】

    原文地址 这篇文章,采用 Markdown 方式,写的还是比较实在的,要是有架构图就好了. Pinterest 是图片版的 Twitter,用户把自己感兴趣的东西用图钉(Pins)钉在钉板(PinBo ...

  5. 从100PV到1亿级PV网站架构演变

    如果你对项目管理.系统架构有兴趣,请加微信订阅号"softjg",加入这个PM.架构师的大家庭 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不 ...

  6. 两年内从零到每月十亿 PV 的发展来谈 Pinterest 的架构设计(转)

    原文:Scaling Pinterest - From 0 To 10s Of Billions Of Page Views A Month In Two Years 译文:两年内从零到每月十亿 PV ...

  7. [转载]从100PV到1亿级PV网站架构演变

    原文地址:http://www.uml.org.cn/zjjs/201307172.asp 一个网站就像一个人,存在一个从小到大的过程.养一个网站和养一个人一样,不同时期需要不同的方法,不同的方法下有 ...

  8. 关于Redis的那些事

    1.  MySql+Memcached架构的问题 Memcached采用客户端-服务器的架构,客户端和服务器端的通讯使用自定义的协议标准,只要满足协议格式要求,客户端Library可以用任何语言实现. ...

  9. Pinterest架构:两年内月PV从零到百亿

    Pinterest正经历了指数级曲线般的增长,每隔一个半月就翻番.在这两年里,Pinterest,从 每月PV量0增长到100亿,从两名c创始人和一个工程师成长为四十个工程师,从一台MySQL 服务器 ...

随机推荐

  1. sqlserver 学习

    http://www.cnblogs.com/CareySon/category/411344.html SQL Server查找的最小单位实际上是页.也就是说即使你只查找一行很小的数据,SQL Se ...

  2. VSFTP被动模式

    搞了几个弯路,各种办法都试了. 动静最小的,还是定义端口. 还有虚拟用户,配置太多,只适用于小范围吧.又要pam.d,又要chroot之类的,nologin也必不可少. ~~~~~~~~~ 限制被动模 ...

  3. VC和VS调用Lua设置以及Lua C API使用。

    通过c++调用lua 脚本,    环境VC++6.0    lua  sdk 5.1.4 在调用前先认识几个函数.1.调用lua_open()将创建一个指向Lua解释器的指针.2. luaL_ope ...

  4. [转帖]自动调整TextView字体大小以适应文字长度

    package com.test.android.textview; import android.content.Context; import android.graphics.Paint; im ...

  5. bzoj1898

    这是yhc大牛矩乘论文上的题目,那里面分析得很清楚了这里就说说我一开始错的地方,我一开始处理每个时刻能通过的邻接矩阵的时候把以不能访问的点i为起点和终点的都标记为0了,实际上只能标记以i为终点的边即可 ...

  6. 使用 Chef 管理 Azure 资源

     发布于 2014-07-08 作者 陈 忠岳 Chef 是一款开源的开发运营(DevOps)工具,用以应对 IT 基础设施方面的挑战.微软开放技术有限公司(简称"微软开放技术" ...

  7. C++中关于const的思考

    在学习C++的过程中,经常被什么时候使用const.为什么使用const以及怎么使用const关键字这样的问题所困扰,以下是我对const的使用总结. 1.值替代 使用#define的确单缺点,第一: ...

  8. [转载]css hack

    做前端多年,虽然不是经常需要hack,但是我们经常会遇到各浏览器表现不一致的情况.基于此,某些情况我们会极不情愿的使用这个不太友好的方式来达到大家要求的页面表现.我个人是不太推荐使用hack的,要知道 ...

  9. spring maven pom

    https://spring.io/blog/2009/12/02/obtaining-spring-3-artifacts-with-maven/

  10. C++Primer第5版学习笔记(三)

    C++Primer第5版学习笔记(三) 第四/五章的重难点内容           你可以点击这里回顾第三章内容       因为第五章的内容比较少,因此和第四章的笔记内容合并.       第四章是 ...