跟踪站点的流量并生成自定义报告
mongol的Python项目详细描述
Authors: | Justin Quick <justquick@gmail.com> |
---|---|
Version: | 0.1 |
pip install mongol==0.1.0
蒙古人是一个网络分析工具,让您跟踪您的网站的流量和生成自定义报告。 它使用mongodb作为数据存储,使用python和pymongo来填充和查询数据库。 它使用标准的wsgi来收集分析信息并提供跟踪gif像素。 定制的分析数据可以扔到服务,然后你可以定制报告跟踪几乎任何你想要的。 这个项目非常适合回答诸如“最受欢迎的十大页面是什么?”“
要求
蒙古语要求pymongo连接到MongoDB实例。 对于serivce,建议与Gevent一起使用,但也可以与Tornado甚至Apache/mod_wsgi一起使用。 以下是建议的要求列表:
sudo pip install pymongo gevent
安装
安装MongoDB。这是他们的quickstart guide。 接下来,下载源代码并安装脚本:
git clone git://github.com/justquick/mongol.git cd mongol sudo python setup.py install
mongol-serve
mongol-serve [address:port]
在可选地址和端口启动服务实例。默认值为0.0.0.0:8000。 此服务托管跟踪gif,但您可以将任何类型的分析数据作为GET参数传递。 唯一需要的两个参数是1)site这是您站点的域,2)url这是您要跟踪的页面的绝对url。 site和url将在浏览器作为跟踪gif所在页发送的HTTP_REFERER中填充。 任何其他GET参数都会存储起来供以后使用。
mongol-report
mongol-report config-file
根据config-filefilename参数中的配置参数从分析数据库生成json报告。 这最好放在cronjob上,以便生成的报告是最新的。 报表文件可以由单独的服务(理想情况下是lighttpd)提供,这样分析服务就不会因为提供报表而阻塞。
配置选项
配置文件包含运行mongol-report时要生成的报表部分。 每个节名将生成一个名为section-name.json的报告文件。 以下是每个部分的选项:
^{tt13}$ - required string. The output directory to store files in (eg ^{tt14}$)
^{tt15}$ - optional string. Time at which to remove older records (eg ^{tt16}$). Mongol is really suited to look at data in the past X amount of time and removes any records that were recorded before then. By default it does not do any limiting.
^{tt17}$ - optional string. Function name to wrap results with creating proper JSONP reports. Defaults to ^{tt18}$.
^{tt19}$ - optional int. Limit the results in the reports. Defaults to ^{tt20}$.
^{tt21}$ - optional string. Order the results. Either ^{tt22}$ for ascending or ^{tt23}$ for descending. Defaults to ^{tt23}$
^{tt25}$ - optional string. The JS source code of the mapping function to use in MongoDB’s map/reduce capabilies. Defaults to
function () { emit({url:this.url, title:this.title}, this.pageviews); }^{tt26}$ - optional string. The JS source code of the reducing function to use in MongoDB’s map/reduce capabilies. Defaults to
function (key, values) { var total = 0; for (var i = 0; i < values.length; i++) { total += values[i]; } return total; }
有关map/reduce的帮助,请查看MongoDB’s MapReduce documentation
待办事项
- Use cookies
- Enable MongoDB clustering support