AS-Stats/contrib/generate-asinfo.py
Manuel Kasper 05bad2db6b Changes by Steve Colam <steve@colam.co.uk>:
- ...-asstatd.pl now accepts parameters (UDP listen port,
	  sampling rate etc.) on the command line
	
	  ****************************************************
	  * Mind the new command line syntax when upgrading! *
	  * Change your start script accordingly...          *
	  ****************************************************
	
	- hierarchical RRD structure for more efficient storage
	  (one directory per low byte of AS number)
	
	  *********************************************
	  * Use tools/migraterrdfiles.pl to move your *
	  * RRD files when upgrading!                 *
	  *********************************************

	- ...-asstatd.pl now re-reads known links file upon SIGHUP
	
Added contrib/generate-asinfo.py script to generate AS list from WHOIS
data (contributed by Thomas Mangin
<thomas.mangin@exa-networks.co.uk>).

Moved site-specific parameters of www frontend to config.inc.

New flag images from famfamfam.com.

Updated asinfo.txt.
2009-10-10 16:53:25 +00:00

29 lines
677 B
Python
Executable File

#!/usr/bin/env python
# (echo begin; echo verbose; for i in `seq 1 65535`; do echo "AS$i"; done; echo end) | netcat whois.cymru.com 43 | ./generate-asinfo.py > asinfo.txt
import sys
for line in sys.stdin:
try:
asn,country,_,_,data = [_.strip() for _ in line.split('|')]
except ValueError:
continue
if data == '-Private Use AS-':
data = 'Private Use AS'
try:
macro,name = data.split(' ',1)
except:
macro = data
name = data
if not (macro.count('-') or macro.upper() == macro or name.startswith('- ')) or macro == 'UK':
macro = 'UNSPECIFIED'
name = data
if name.startswith('- '):
name = name[2:]
print "%s\t%s\t%s\t%s" % (asn,macro,name,country)