use CGI qw(:standard escapeHTML);
use Time::Local;
$DDIR="/data/cyrus";
$GRAPH="/cgi-bin/graph_cyrus_db.pl";
$q= new CGI;
print $q->header();
print("<html><head><title>Cyrus Stats</title></head>");
print("<body>");
opendir(DH, $DDIR) or die "Could not find data";
@files = readdir(DH);
closedir(DH);
%hash=();
$n=0;
foreach (@files){
$server = "";
$ds = "";
$n++;
($server, $end) = split /\:/, $_, 2;
($ds,$throwaway) = split /\./,$end,2;
if($ds ne "" && $ds ne ${$hash{"$server"}}[-1]){
push @{$hash{"$server"}}, "$ds";
}
}
print("<table>\n");
foreach $key( sort %hash){
if($hash{$key}){
print("<h2>$key</h2><ul>\n");
}
foreach $service (@{$hash{$key}}){
print("<li><a href=\"$GRAPH?server=$key&service=$service\">$service</a>\n");
}
print("</ul>\n");
}
print("</table>\n");
print("</body></html>");