Skip to content

Instantly share code, notes, and snippets.

@sdstrowes
Created February 3, 2022 16:04
Show Gist options
  • Save sdstrowes/ec202785140cd7d94f33037522db6111 to your computer and use it in GitHub Desktop.
Save sdstrowes/ec202785140cd7d94f33037522db6111 to your computer and use it in GitHub Desktop.
RIR extended stats fetcher
#!/usr/bin/env bash
date=date
zcat=zcat
if [[ "$OSTYPE" == "darwin"* ]]; then
date=gdate
zcat=gzcat
fi
while getopts "hd:" arg; do
case $arg in
h)
echo "$0 -d <date>"
exit 1
;;
d)
d=`$date -u --date "$OPTARG"`
;;
esac
done
if [ x"$d" == x ] ; then echo "$0 -d <date>" ; exit 1 ; fi
#echo $d
yyyy=`$date --date "$d" +%Y`
yyyymm=`$date --date "$d" +%Y%m`
yyyymmdd=`$date --date "$d" +%Y%m%d`
url=https://ftp.ripe.net/pub/stats/afrinic/${yyyy}/delegated-afrinic-extended-${yyyymmdd}
echo "AfriNIC: $url"
curl -s $url > afrinic-extended-$yyyymmdd
url=https://ftp.ripe.net/pub/stats/apnic/${yyyy}/delegated-apnic-extended-${yyyymmdd}.gz
echo "APNIC: $url"
curl -s $url | ${zcat} > apnic-extended-$yyyymmdd
url=https://ftp.ripe.net/pub/stats/arin/delegated-arin-extended-${yyyymmdd}
echo "ARIN: $url"
curl -s $url > arin-extended-$yyyymmdd
url=https://ftp.ripe.net/pub/stats/lacnic/delegated-lacnic-extended-${yyyymmdd}
echo "LACNIC: $url"
curl -s $url > lacnic-extended-$yyyymmdd
url=https://ftp.ripe.net/pub/stats/ripencc/${yyyy}/delegated-ripencc-extended-${yyyymmdd}.bz2
echo "RIPE: $url"
curl -s $url | bzcat > ripe-extended-$yyyymmdd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment