AS-Stats/tools/migraterrdfiles.pl
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

41 lines
817 B
Perl

#!/usr/bin/perl
# This script moves RRD files from the old (pre-v1.3) flat directory structure
# into subdirectories (where the name of each subdirectory is the lower
# byte of the AS number in hex).
use strict;
my $rrdpath = $ARGV[0];
die("Usage: $0 <path to RRD files>\n") if (! -d $rrdpath);
opendir(DIR, $rrdpath);
my @rrdfiles = readdir(DIR);
closedir(DIR);
my $i = 0;
foreach my $rrdfile (@rrdfiles) {
if ($rrdfile =~ /^(\d+).rrd$/) {
my $as = $1;
# calculate new path
my $dirname = "$rrdpath/" . sprintf("%02x", $as % 256);
if (! -d $dirname) {
# need to create directory
mkdir($dirname);
}
my $new_rrdfile = "$dirname/$as.rrd";
rename("$rrdpath/$rrdfile", $new_rrdfile);
$i++;
if ($i % 100 == 0) {
print "$i...";
}
}
}
print "\n\n";
print "$i files moved.\n";