First stab at multiquery, give it arguments like testname=startup&tboxes=comet,sleestack

This commit is contained in:
mcafee%netscape.com 2002-01-01 03:13:50 +00:00
Родитель e0d92a5faf
Коммит 351a689dde
1 изменённых файлов: 151 добавлений и 0 удалений

151
webtools/graph/multiquery.cgi Executable file
Просмотреть файл

@ -0,0 +1,151 @@
#!/usr/bin/perl -w
# -*- Mode: perl; indent-tabs-mode: nil -*-
use CGI::Carp qw(fatalsToBrowser);
use CGI::Request;
my $req = new CGI::Request;
my $TBOXES = lc($req->param('tboxes'));
my $TESTNAME = lc($req->param('testname'));
sub make_filenames_list {
my ($dir) = @_;
my @result;
if (-d "$dir") {
chdir "$dir";
while(<*>) {
if( $_ ne 'config.txt' ) {
push @result, $_;
}
}
chdir "../..";
}
return @result;
}
# Print out a list of testnames in db directory
sub print_testnames {
# HTTP header
print "Content-type: text/html\n\n<HTML>\n";
print "<title>multiquery: testnames</title>";
print "<center><h2><b>multiquery: testnames</b></h2></center>";
print "<p><table width=\"100%\">";
print "<tr><td align=center>Select one of the following tests:</td></tr>";
print "<tr><td align=center>\n";
print " <table><tr><td><ul>\n";
my @machines = make_filenames_list("db");
my $machines_string = join(" ", @machines);
foreach (@machines) {
print "<li><a href=multiquery.cgi?&testname=$_>$_</a>\n";
}
print "</ul></td></tr></table></td></tr></table>";
}
# Print out a list of machines in db/<testname> directory, with links.
sub print_machines {
my ($testname) = @_;
# HTTP header
print "Content-type: text/html\n\n<HTML>\n";
print "<title>$TESTNAME machines</title>";
# XXX Testing, this isn't correct yet.
print "<script>\n";
print "function scrape_for_names() {\n";
print "window.location = \"http://www.mocha.com\";\n";
print "}\n";
print "</script>\n";
print "<center><h2><b>$TESTNAME machines:</b></h2></center>";
print "<p><table width=\"100%\">";
print "<tr><td align=center>Select one of the following machines:</td></tr>";
print "<tr><td align=center>\n";
print " <table><tr><td><ul>\n";
my @machines = make_filenames_list("db/$testname");
my $machines_string = join(" ", @machines);
# XXX Testing, this isn't correct yet.
print "<form action=\"multiquery.cgi?testname=$TESTNAME\">\n";
print "<input type=hidden name=\"testname\" value=\"$TESTNAME\">";
@machines = ("comet", "sleestack");
foreach(@machines) {
print "<input type=checkbox name= value=$_>$_<br>\n";
}
#print "<input type=hidden name=\"tboxes\" value=\"comet,openwound\">";
#print "<input type=\"submit\" value=\"submit\">\n";
print "<INPUT TYPE=\"button\" VALUE=\"Submit\" onClick=\"scrape_for_names()\">\n";
print "</form>\n";
print "</ul></td></tr></table></td></tr></table>";
}
sub show_graphs {
# HTTP header
print "Content-type: text/html\n\n<HTML>\n";
print "<title>multiquery: $TESTNAME</title><br>\n";
print "<body>\n";
# JS refresh every 30min
print "<script>setTimeout('location.reload()',1800000);</script>\n";
print "<center><h3>$TESTNAME: $TBOXES</h3></center>\n";
print "<table cellspacing=8>\n";
my @tbox_array = split(",", $TBOXES);
my $i = 0;
while($i < @tbox_array) {
print "<tr>\n";
print "<td>\n";
print "<img src=\"http://tegu.mozilla.org/graph/graph.cgi?tbox=$tbox_array[$i]&testname=$TESTNAME&size=.6&autoscale=1&days=7&avg=1\" alt=\"$tbox_array[$i] $TESTNAME graph\">";
print "</td>\n";
$i++;
if($i < @tbox_array) {
print "<td>\n";
print "<img src=\"http://tegu.mozilla.org/graph/graph.cgi?tbox=$tbox_array[$i]&testname=$TESTNAME&size=.6&autoscale=1&days=7&avg=1\" alt=\"$tbox_array[$i] $TESTNAME graph\">";
print "</td>\n";
$i++;
print "</tr>\n";
}
}
print "</table>\n";
print "</body>\n";
}
# main
{
if(!$TESTNAME) {
print_testnames();
} elsif(!$TBOXES) {
print_machines($TESTNAME);
} else {
show_graphs();
}
}
exit 0;