Created
February 3, 2022 16:04
-
-
Save sdstrowes/ec202785140cd7d94f33037522db6111 to your computer and use it in GitHub Desktop.
RIR extended stats fetcher
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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