Changeset 11


Ignore:
Timestamp:
10/25/04 17:28:12 (20 years ago)
Author:
Kris Deugau
Message:

Near-complete rewrite of cgi-bin/consistency-check.pl

  • It works properly now! Woohoo!
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/cgi-bin/consistency-check.pl

    r8 r11  
    8282foreach $master (@masterblocks) {
    8383  print "Master $master:\n";
    84   ($next,undef) = split /\//, $master;
    85   ($last,undef) = split /\//, ($master->broadcast);
     84  $prev = $master;
    8685  $sth = $dbh->prepare("(select network(cidr) as net, broadcast(cidr) as bcast ".
    8786        " from allocations where cidr <<= '$master') union ".
     
    8988        "from freeblocks where cidr <<= '$master') order by net");
    9089  $sth->execute;
     90
    9191  while (@data = $sth->fetchrow_array) {
    92     ($cur,undef) = split /\//, $data[0];
    93     if ($master !~ /$next/) {
    94       ($tmp,undef) = split /\//, $next;
    95       @tmp1 = split /\./, $tmp;
    96       $tmp1[3]++;
    97       if ($tmp1[3] == 256) { $tmp1[3] = 0; $tmp1[2]++; }
    98       $cmp = join '.', @tmp1;
     92    $cur = new NetAddr::IP $data[0];
     93
     94    if ($master->numeric == $prev->numeric) {
     95      # check if cur starts with master
     96      if ($cur->numeric > $prev->numeric) {
     97        print " Gap from start of master $master to first block $cur\n";
     98      } elsif ($cur->numeric < $prev->numeric) {
     99        print " BIG problem!  Current block $cur begins before master $master!\n";
     100      }
    99101    } else {
    100       $cmp = $next;
     102      if ($cur->numeric < ($prev->numeric + 1)) {
     103        print " Block ".$prev->network." overlaps block $cur\n";
     104      } elsif ($cur->numeric > ($prev->numeric + 1)) {
     105        print " Gap between end of block ".$prev->network." and block $cur\n";
     106      }
    101107    }
    102     if ($cur ne $cmp) {
    103       print " Gap from $next to $cur\n";
    104     }
    105     ($next,undef) = split /\//, $data[1];
    106   }
    107   if ($next ne $last) {
    108     print " Gap from $next to end of master at $last\n";
     108
     109    $prev = $cur;
     110    $prev--;
     111
     112  } # while (@data...)
     113
     114  $cur--;
     115  $master--;
     116  if ($cur->numeric ne $master->numeric) {
     117    print " Gap from $cur to end of master at $master\n";
    109118  }
    110119  print "done $master.\n";
Note: See TracChangeset for help on using the changeset viewer.