Last change
on this file since 214 was 142, checked in by Kris Deugau, 20 years ago |
/trunk
Wrap connectDB() function in a "module" so we don't get headaches
tracking password changes (if and when). This change *may* get
merged back to IPDB.pm, but it may not so as to allow the HTTP
username to be the user authenticated at the database level.
|
-
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-01-28 19:04:55 +0000 (Fri, 28 Jan 2005) $
|
---|
7 | # SVN revision $Rev: 142 $
|
---|
8 | # Last update by $Author: kdeugau $
|
---|
9 | ###
|
---|
10 | # Copyright (C) 2004 - Kris Deugau
|
---|
11 |
|
---|
12 | use DBI;
|
---|
13 | use MyIPDB;
|
---|
14 | use NetAddr::IP;
|
---|
15 |
|
---|
16 | ($dbh,$errstr) = connectDB_My;
|
---|
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.