source: branches/dns/cgi-bin/freespace.pl@ 241

Last change on this file since 241 was 146, checked in by Kris Deugau, 20 years ago

/trunk

Update copyright statements

  • Property svn:executable set to *
  • Property svn:keywords set to Date Rev Author
File size: 1.0 KB
Line 
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-01 22:02:39 +0000 (Tue, 01 Feb 2005) $
7# SVN revision $Rev: 146 $
8# Last update by $Author: kdeugau $
9###
10# Copyright (C) 2004,2005 - Kris Deugau
11
12use DBI;
13use MyIPDB;
14use NetAddr::IP;
15
16($dbh,$errstr) = connectDB_My;
17
18print "Content-type: text/plain\n\n";
19
20$tnumfree = $bigrfree = $bigufree = 0;
21
22# General counts first
23if ($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;
29while (@data = $sth->fetchrow_array) {
30 # cidr,maskbits,city,routed
31 $tnumfree++;
32 $numfree{"$data[1]"}++;
33}
34
35foreach $size (sort {$a cmp $b} keys %numfree) {
36 print "/$size: $numfree{$size}\n";
37}
38print "\n";
39
40for ($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
46foreach $size (sort {$a cmp $b} keys %numfree) {
47 print "/$size: $numfree{$size}\n";
48}
Note: See TracBrowser for help on using the repository browser.