#!/usr/bin/perl
use DBI;
use CGI qw(:standard);
use tracker;
use tracker_cgi;



$| = 1;

print $tracker::tracker_header;

	
$conn = tracker::conndb();
$sth = $conn->prepare("select distinct switch from switch_ports");
$sth->execute;
while (@row = $sth->fetchrow_array)
        {
        push(@switches,{switch => $row[0]}) 
        }

foreach $hashref (@switches)
	{
	$switch = $hashref->{"switch"};
	$sth = $conn->prepare("select count(port) from switch_ports where switch = " . $conn->quote($switch) . " and " .
				"adminspeed = 100000000 and adminstatus = 1;");
	$sth->execute;
	@row = $sth->fetchrow_array;
	$hashref->{"ports_100meg"} = $row[0];
	}
@sorted = sort {$b->{"ports_100meg"} <=> $a->{"ports_100meg"}} @switches;
print "<table border=1><tr><td>switch</td><td>enabled 100Mb ports</td></tr>\n";
	
foreach $hashref (@sorted)
	{
	print "<tr><td>", $hashref->{"switch"}, "</td><td>", $hashref->{"ports_100meg"}, "</td></tr>\n"
	}
	
print "</table>";
tracker::tracker_end;
$sth->finish;
$conn->disconnect

