eldy / AWStats

AWStats Log Analyzer project (official sources)
https://www.awstats.org
364 stars 121 forks source link

Feature Request: Support for other GeoIP2 databases? #199

Closed AnthonyBe closed 3 years ago

AnthonyBe commented 3 years ago

I'm wondering if anyone is working on, or if it is even viable, plugin modules for:

  1. the other free Maxmind GeoLite2 database (GeoLite2 ASN), or
  2. the GeoIP2 commercial databases?

Commercial: Anonymous IP, Connection Type, Domain, ISP https://www.maxmind.com/en/geoip2-databases https://dev.maxmind.com/geoip/geoip2/downloadable

visualperception commented 3 years ago

using the following you can generate an ASN geoip.dat file from the free geoip2 files

https://github.com/sherpya/geolite2legacy

AnthonyBe commented 3 years ago

using the following you can generate an ASN geoip.dat file from the free geoip2 files

https://github.com/sherpya/geolite2legacy

Oh cool! Thank you so much for sharing that. I'll check it out!

AnthonyBe commented 3 years ago

Thanks @visualperception - works perfectly.

For the record in case anyone else wants to use this (I'm running on Windows):

  1. I'm using curl to download GeoLite2-ASN-CSV.zip from Maxmind's permalink
  2. Then using geolite2legacy to convert the downloaded file into the GeoIPASNum.dat format that AWStats can use.

I've got the following in a script scheduled to run weekly: NOTE: in script below, YOUR_LICENSE_KEY needs to be replaced by your Maxmind license key (this is free version)

curl "https://download.maxmind.com/app/geoip_download?edition_id=GeoLite2-ASN-CSV&license_key=YOUR_LICENSE_KEY&suffix=zip" --output GeoLite2-ASN-CSV.zip

python geolite2legacy.py -i GeoLite2-ASN-CSV.zip -o GeoIPASNum.dat 

geolite2legacy is in Python. I'm using Python 3.9.1 for Windows. You will need to install ipaddr Python module