You might be able to set up a null transformation and count the bytes as they go through.
On Fri, Aug 17, 2012 at 5:10 PM, Adam Phelps <a...@opendns.com> wrote: > Ok, those calls in TS_HTTP_TXN_CLOSE_HOOK appear to result in accurate > numbers, but with streaming are no where near as granular as I'd like to > see. For instance a big youtube video may hit the > TS_HTTP_SEND_RESPONSE_HDR_HOOK and TS_HTTP_TXN_CLOSE_HOOK hooks only once > for many 100's of MB of traffic. Is there a way to get more granular > updates via the API? > > Thanks > - Adam > > > On 8/16/12 9:52 PM, Conan wrote: >> >> There are two API: TSHttpTxnClientRespBodyBytesGet >> and TSHttpTxnClientRespHdrBytesGet (can be invoked in >> TS_HTTP_TXN_CLOSE_HOOK in my test). I think their returned value are >> %<pscl> >> and %<pshl>. >> >> Content-Length is larger than transfered length, because user-agent can >> easily abort request. >> >> >> On Fri, Aug 17, 2012 at 10:47 AM, Phil Sorber <p...@omniti.com> wrote: >> >>> Does your plugin handle chunked encoding? >>> >>> On Thu, Aug 16, 2012 at 8:14 PM, Adam Phelps <a...@opendns.com> wrote: >>>> >>>> I'm working on a plugin, one of the functions of which is to accurate >>> >>> track >>>> >>>> how much data is being sent to a given client, both for totals and a >>>> per-UserAgent count. >>>> >>>> This seems to mostly work, but I'm seeing some major discrepancies >>> >>> between >>>> >>>> what the plugin is reporting and what is actually being sent out >>> >>> (measured >>>> >>>> via collectd and iptables) when doing streaming (via youtube). And >>>> these >>>> are major differences, the plugin reports 100GB for an hour of youtube >>>> streaming, where my other counters should closer to 600MB. The 600MB >>> >>> number >>>> >>>> seems about right for this sort of content. >>>> >>>> The method I'm using to track the totals sent are to set a global hook >>> >>> for >>>> >>>> TS_HTTP_SEND_RESPONSE_HDR_HOOK and then get and sum up the >>>> TS_MIME_FIELD_CONTENT_LENGTH header. However with the youtube streaming >>>> this will see much larger numbers for Content-Length than even what is >>>> reported in the ATS log (via %<psql> in logs_xml.config). >>>> >>>> Here's how I'm getting the content length in the hook attached to >>>> TS_HTTP_SEND_RESPONSE_HDR_HOOK: >>>> >>>> if (TSHttpTxnClientRespGet(txnp, &resp_bufp, &resp_loc) != >>>> TS_SUCCESS) { >>>> LOG(LOG_ERROR, >>>> "Error while retrieving resp header\n"); >>>> goto OUT; >>>> } >>>> >>>> /* Lookup the Content-Length field */ >>>> TSMLoc content_len_loc = TSMimeHdrFieldFind(resp_bufp, resp_loc, >>>> TS_MIME_FIELD_CONTENT_LENGTH, >>>> TS_MIME_LEN_CONTENT_LENGTH); >>>> if (!content_len_loc) { >>>> goto OUT; >>>> } >>>> int content_len_val_len; >>>> const char *content_len_val = >>>> TSMimeHdrFieldValueStringGet(resp_bufp, resp_loc, >>>> content_len_loc, 0, >>>> &content_len_val_len); >>>> if (!content_len_val) { >>>> LOG(LOG_ERROR, "Failed to get Content-Length value"); >>>> goto OUT; >>>> } >>>> >>>> This is clearly not working for streaming, is there a better way to get >>> >>> the >>>> >>>> total size of the data being returned to the requesting client? >>>> >>>> - Adam >>> >>> >> >