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

my ($switch, $module, $port, $dbconn);

$| = 1;

print $tracker::tracker_header;


$_ = param("swport");

if ( /^([.\w-_]*)\s(\d*)\/(\d*)/ )
	{
	($switch,$module,$port) = ($1,$2,$3);
	}
else
	{
	tracker::http_error("Invalid query");
	exit
	}

$dbconn = tracker::conndb() or cgi_die(["Database error"]);
my $query = "select switch, module, port, description, inoctets, adminstatus, " .
	"adminspeed, vlan, " . tracker::timestamp("last_input_increment") .
	"from switch_ports where switch = " . $dbconn->quote($switch) .
	" and module = $module and port = $port;";
my $sth = $dbconn->prepare($query);
$sth->execute or cgi_die(["Database error" . $dbconn->errstr]);

	
tracker::start_swport_table;

while (@row = $sth->fetchrow_array) 
	{
	tracker::swport_row(@row)
	}

tracker::end_table;
tracker::tracker_end;
$dbconn->disconnect

