Last change
on this file since 343 was 306, checked in by Kris Deugau, 19 years ago |
/branches/stable
Added combineblocks.pl, tweaked it to more accurately deal with
the updated alloctypes.
|
-
Property svn:executable
set to
*
-
Property svn:keywords
set to
Date Rev Author
|
File size:
1.5 KB
|
Line | |
---|
1 | #!/usr/bin/perl
|
---|
2 | # ipdb/cgi-bin/combineblocks.pl
|
---|
3 | # Quick hack to clean up mangled deallocations
|
---|
4 | ###
|
---|
5 | # Revision info
|
---|
6 | # $Date: 2006-01-19 19:07:39 +0000 (Thu, 19 Jan 2006) $
|
---|
7 | # SVN revision $Rev: 306 $
|
---|
8 | # Last update by $Author: kdeugau $
|
---|
9 | ###
|
---|
10 |
|
---|
11 | use strict;
|
---|
12 | use warnings;
|
---|
13 | #use CGI::Carp qw(fatalsToBrowser);
|
---|
14 | use DBI;
|
---|
15 | #use CommonWeb qw(:ALL);
|
---|
16 | use MyIPDB;
|
---|
17 | #use POSIX qw(ceil);
|
---|
18 | use NetAddr::IP;
|
---|
19 |
|
---|
20 | #use Sys::Syslog;
|
---|
21 |
|
---|
22 | my $null = new NetAddr::IP "255.255.255.255/32";
|
---|
23 |
|
---|
24 | my @fbtypes;
|
---|
25 |
|
---|
26 | my ($dbh,$ret) = connectDB_My;
|
---|
27 | initIPDBGlobals($dbh);
|
---|
28 | my $sth;
|
---|
29 |
|
---|
30 | # Get the types of freeblocks
|
---|
31 | $sth = $dbh->prepare("select distinct routed from freeblocks");
|
---|
32 | $sth->execute;
|
---|
33 | while (my @data = $sth->fetchrow_array) {
|
---|
34 | push @fbtypes, @data;
|
---|
35 | }
|
---|
36 |
|
---|
37 | foreach my $type (@fbtypes) {
|
---|
38 |
|
---|
39 | my $i=0;
|
---|
40 | my @compacted;
|
---|
41 |
|
---|
42 | my $sth = $dbh->prepare("select cidr from freeblocks where routed='$type'");
|
---|
43 | $sth->execute;
|
---|
44 | while (my @data = $sth->fetchrow_array) {
|
---|
45 | my $temp = new NetAddr::IP $data[0];
|
---|
46 | @compacted = $temp->compact(@compacted);
|
---|
47 | $i++;
|
---|
48 | }
|
---|
49 |
|
---|
50 | #print $compacted[0];
|
---|
51 | my $numcomp = @compacted;
|
---|
52 | #print " $numcomp";
|
---|
53 |
|
---|
54 | if ($i == $numcomp) {
|
---|
55 | print "No compactable blocks for type $type ($i free)\n";
|
---|
56 | next;
|
---|
57 | }
|
---|
58 | print "Type $type: $i free blocks to start, $numcomp to finish\n";
|
---|
59 |
|
---|
60 | $sth = $dbh->prepare("select cidr from freeblocks where cidr << ?");
|
---|
61 | foreach my $cip (@compacted) {
|
---|
62 | $sth->execute("$cip");
|
---|
63 | if ($sth->rows > 0) {
|
---|
64 | print " $cip combines from:\n";
|
---|
65 | while (my @data = $sth->fetchrow_array) {
|
---|
66 | print " $data[0]\n";
|
---|
67 | }
|
---|
68 | # } else {
|
---|
69 | # print " $cip does not compact\n";
|
---|
70 | }
|
---|
71 | }
|
---|
72 |
|
---|
73 | } # each @fbtype
|
---|
74 |
|
---|
75 | finish($dbh);
|
---|
Note:
See
TracBrowser
for help on using the repository browser.