Last change
on this file since 270 was 158, checked in by Kris Deugau, 20 years ago |
/branches/stable
Merge all changes from /trunk r141-144 and r146
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Date Rev Author
|
File size:
1.0 KB
|
Rev | Line | |
---|
[117] | 1 | #!/usr/bin/perl
|
---|
| 2 | # ipdb/cgi-bin/freespace.pl
|
---|
| 3 | # Quick hack to calculate aggregate free IP space, and statistic-ify the blocks.
|
---|
| 4 | ###
|
---|
| 5 | # SVN revision info
|
---|
| 6 | # $Date: 2005-02-09 20:53:56 +0000 (Wed, 09 Feb 2005) $
|
---|
| 7 | # SVN revision $Rev: 158 $
|
---|
| 8 | # Last update by $Author: kdeugau $
|
---|
| 9 | ###
|
---|
[158] | 10 | # Copyright (C) 2004,2005 - Kris Deugau
|
---|
[117] | 11 |
|
---|
| 12 | use DBI;
|
---|
[158] | 13 | use MyIPDB;
|
---|
[117] | 14 | use NetAddr::IP;
|
---|
| 15 |
|
---|
[158] | 16 | ($dbh,$errstr) = connectDB_My;
|
---|
[117] | 17 |
|
---|
| 18 | print "Content-type: text/plain\n\n";
|
---|
| 19 |
|
---|
| 20 | $tnumfree = $bigrfree = $bigufree = 0;
|
---|
| 21 |
|
---|
| 22 | # General counts first
|
---|
| 23 | if ($ARGV[0]) {
|
---|
| 24 | $sth = $dbh->prepare("select * from freeblocks where maskbits >= $ARGV[0] order by maskbits desc");
|
---|
| 25 | } else {
|
---|
| 26 | $sth = $dbh->prepare("select * from freeblocks order by maskbits desc");
|
---|
| 27 | }
|
---|
| 28 | $sth->execute;
|
---|
| 29 | while (@data = $sth->fetchrow_array) {
|
---|
| 30 | # cidr,maskbits,city,routed
|
---|
| 31 | $tnumfree++;
|
---|
| 32 | $numfree{"$data[1]"}++;
|
---|
| 33 | }
|
---|
| 34 |
|
---|
| 35 | foreach $size (sort {$a cmp $b} keys %numfree) {
|
---|
| 36 | print "/$size: $numfree{$size}\n";
|
---|
| 37 | }
|
---|
| 38 | print "\n";
|
---|
| 39 |
|
---|
| 40 | for ($i=30; $i>16; $i--) {
|
---|
| 41 | $j = $i-1;
|
---|
| 42 | $numfree{"$j"} += int $numfree{"$i"}/2;
|
---|
| 43 | $numfree{"$i"} -= (int $numfree{"$i"}/2)*2;
|
---|
| 44 | }
|
---|
| 45 |
|
---|
| 46 | foreach $size (sort {$a cmp $b} keys %numfree) {
|
---|
| 47 | print "/$size: $numfree{$size}\n";
|
---|
| 48 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.