Website maintenance: APK Download Accurate statistics

Source: Internet
Author: User

We often see that the return code in the downloaded log is 206, so what is 206?

The server has successfully processed a partial GET request. HTTP download tools such as FlashGet or Thunderbolt are used to implement a breakpoint continuation or to decompose a large document into multiple download segments for download at the same time.

206 refers to the download package is split multiple causes, so if we simple statistics 200 is not enough, we also have to take into account 206 of the situation, and each 206 of the request is part of the package, statistics 206 of the entries can not be accurate.

We write scripts:

That is:

1: The sum of the requested return codes 200 and 206 for the same IP, divided by the size of the single apk package (integer multiples, discard decimal digits) for the number of packets downloaded for that IP.

2: Add the number of all IP download packages, the total number of times to download the package.


Script:

#!/bin/env pythonimport os,sys,re,datetimepasst = datetime.datetime.now ()  -  Datetime.timedelta (minutes=60) curtime2 = passt.strftime ('%y%m%d ') print curtime2 "" "192.168.100.8  - - [20/May/2015:16:17:14 +0800]  "get /images/icon_app_sq.png http/1.0"  206 35899192.168.100.8 - - [20/May/2015:16:17:14 +0800]  "get /images/ icon_app_sq.png http/1.0 " 200 135899192.168.100.48 - - [20/may/2015:16:13:32  +0800]  "get /apk/test/20001/test_20001.apk http/1.0"  200 3245652192.168.100.48  - - [20/May/2015:12:51:46 +0800]  "get /apk/test/20001/test_20001.apk http/ 1.0 " 206 65536" "" "F=open ('/backup/nginxlog/aggday/access.log. ') +curtime2) #p =re.compile (' ([0-9.] +)  .*20/mar/2015:16:[0-2][0-9]+:.*test_20001.apk http/1. [0-1] "  (+)   ([0-9]+)  .* ') p=re.compile (' ([0-9.] +)  .*tEst_20001.apk http/1. [0-1] "  (20[0-9])   ([0-9]+)  .* ') D={}dir={}for line in f:if re.match (p,line)  is not none:ip=re.match (p,line). Group (1)         big= Int (Re.match (p,line). Group (3)) Total=d.get (ip,0) total+=bigd[ip]=totalfor ip,total in d.iteritems (): Num=dir.get (ip,0) num= total/3245000        #3245000   for package size Dir[ip ]=num#print dprint sum (Dir.values ())


This article is from the Linux system maintenance blog, so be sure to keep this source http://linuxadmin.blog.51cto.com/2683824/1653407

Website maintenance: APK Download Accurate statistics

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.