Index: /trunk/cgi-bin/consistency-check.pl
===================================================================
--- /trunk/cgi-bin/consistency-check.pl	(revision 61)
+++ /trunk/cgi-bin/consistency-check.pl	(revision 62)
@@ -65,5 +65,24 @@
 print " done.\n";
 
-print "Done checking master containment.\n\nChecking block-alignment consistency:\n";
+print "Done checking master containment.\n\nChecking pool containment:\n";
+
+$sth = $dbh->prepare("select pool,ip from poolips order by ip");
+$sth->execute;
+while (@data = $sth->fetchrow_array) {
+  $pool = new NetAddr::IP $data[0];
+  $ip = new NetAddr::IP $data[1];
+  print "IP $ip listed with incorrect pool $pool\n"
+    if !$pool->contains($ip);
+}
+$sth = $dbh->prepare("select distinct pool from poolips order by pool");
+$sth->execute;
+while (@data = $sth->fetchrow_array) {
+  $sth2 = $dbh->prepare("select cidr from allocations where cidr='$data[0]'");
+  $sth2->execute;
+  print "Pool $data[0] does not exist in allocations table\n"
+    if (($sth2->fetchrow_array)[0] eq '');
+}
+
+print "Done checking pool containment.\n\nChecking block-alignment consistency:\n";
 
 # Block alignment consistency:  All allocated+free blocks within a master
