2014-12-08 18:00:45 +00:00
|
|
|
#!/bin/bash
|
|
|
|
# fetch data files from the opentracker stats output
|
|
|
|
# store them away for later analysis
|
|
|
|
# skvidal
|
2015-05-04 16:26:50 +00:00
|
|
|
base=/srv/web/stats/raw
|
2014-12-08 18:00:45 +00:00
|
|
|
baseurl='http://torrent.fedoraproject.org:6969/stats?mode='
|
|
|
|
date=`date +%Y-%m-%d`
|
|
|
|
hour=`date +%H`
|
2016-12-21 16:09:29 +00:00
|
|
|
wgetcmd="wget --timeout=20 -q -4"
|
2014-12-08 18:00:45 +00:00
|
|
|
#per-torrent stats
|
|
|
|
src="${baseurl}tpbs&format=txt"
|
|
|
|
dest=$base/torrent/$date
|
|
|
|
if [ ! -d $dest ]; then
|
|
|
|
mkdir -p $dest
|
|
|
|
fi
|
2015-05-04 17:19:03 +00:00
|
|
|
$wgetcmd -O $dest/$hour.txt.gz $src
|
2015-05-04 17:26:02 +00:00
|
|
|
gunzip $dest/$hour.txt.gz
|
2014-12-08 18:00:45 +00:00
|
|
|
ln -sf $dest/$hour.txt $base/torrent/current.txt
|
|
|
|
|
|
|
|
|
|
|
|
#totalstats
|
|
|
|
src="${baseurl}everything"
|
|
|
|
dest=$base/everything/$date
|
|
|
|
if [ ! -d $dest ]; then
|
|
|
|
mkdir -p $dest
|
|
|
|
fi
|
2015-05-05 20:18:46 +00:00
|
|
|
$wgetcmd -O $dest/$hour.xml $src
|
2014-12-08 18:00:45 +00:00
|
|
|
ln -sf $dest/$hour.xml $base/everything/current.xml
|
|
|
|
|
|
|
|
|
|
|
|
# generate the json files
|
|
|
|
hourdate=`date +%Y-%m-%d-%H-%M`
|
2015-05-04 16:26:50 +00:00
|
|
|
/usr/local/bin/torrentjsonstats.py $base/torrent/current.txt > /srv/web/stats/hourly/torrent-stats-$hourdate.json
|
2015-05-04 17:10:58 +00:00
|
|
|
ln -sf /srv/web/stats/hourly/torrent-stats-$hourdate.json /srv/web/stats/current-stats.json
|
2014-12-08 18:00:45 +00:00
|
|
|
|
|
|
|
if [ $hour == '12' ]; then
|
2015-05-04 16:26:50 +00:00
|
|
|
/usr/local/bin/torrentjsonstats.py $base/torrent/current.txt > /srv/web/stats/daily/torrent-stats-$date.json
|
2014-12-08 18:00:45 +00:00
|
|
|
fi
|
|
|
|
|