Skip to content

Instantly share code, notes, and snippets.

@grigorescu
Last active February 17, 2020 16:40
Show Gist options
  • Save grigorescu/3179eb8ada4c6d4e154b to your computer and use it in GitHub Desktop.
Save grigorescu/3179eb8ada4c6d4e154b to your computer and use it in GitHub Desktop.
Bro script to measure March Madness video streaming.
# Calculates metrics on March Madness video streaming, including
# unique IPs, total HTTP requests, and total bytes downloaded.
# Sample output:
#
# fields ts ts_delta app uniq_hosts hits bytes
# types time interval string count count count
# 1395331457.824587 900.000000 march-madness 4 569 164589761
# 1395332324.854514 900.000000 march-madness 17 1917 704801124
@load misc/app-stats
module AppStats;
event HTTP::log_http(rec: HTTP::Info)
{
if ( rec?$host && rec?$referrer && rec?$uri && rec?$response_body_len )
{
if ( /http:\/\/www.ncaa.com\/march-madness-live\/game\// in rec$referrer &&
/plugin=aasp-3/ in rec$uri )
{
SumStats::observe("apps.bytes", [$str="march-madness"], [$num=rec$response_body_len]);
SumStats::observe("apps.hits", [$str="march-madness"], [$str=cat(rec$id$orig_h)]);
}
}
}
@irctrakz
Copy link

lol, so awesome!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment