Revision e3f912fb
Added by Hamish Coleman over 18 years ago
- ID e3f912fb0af68b5eaf10896098aa7eaaa498672c
| mrtg.cgi | ||
|---|---|---|
| my $gifdone = 0; # Scan for newest graph and save info for later
 | ||
| my $warnings;
 | ||
|  | ||
| sub init_tests() {
 | ||
| sub init_tests(@) {
 | ||
| 	my (@config_files) = @_;
 | ||
|  | ||
| 	my $xsize_default = 500;
 | ||
| 	my $testmax=0;
 | ||
| 	my @list;
 | ||
| ... | ... | |
| 					$testnr=$tests{$testname};
 | ||
| 				}
 | ||
|  | ||
| 				$list[$testnr]->{ysize} = $this_ysize;
 | ||
| 				$list[$testnr]->{xsize} = $this_xsize;
 | ||
| 				$list[$testnr]->{title} = $this_title;
 | ||
| 				$list[$testnr]->{ysize} = $this_ysize if $this_ysize;
 | ||
| 				$list[$testnr]->{xsize} = $this_xsize if $this_xsize;
 | ||
| 				$list[$testnr]->{title} = $this_title if $this_title;
 | ||
| 			}
 | ||
| 		}
 | ||
| 		close In;
 | ||
| ... | ... | |
| sub init_lists(@) {
 | ||
| 	my (@tests) = @_;
 | ||
|  | ||
| 	my %lists;
 | ||
| 	my $l;
 | ||
|  | ||
| 	my %hostlist;
 | ||
| 	my %hosttypelist;
 | ||
| 	my %hosttypecount;
 | ||
|  | ||
| 	@{$lists{ALL}}=@tests;
 | ||
| 	@{$l->{ALL}->{ALL}}=@tests;
 | ||
|  | ||
| 	for my $i (0..$#tests) {
 | ||
| 		my $testname = $tests[$i]->{name};
 | ||
|  | ||
| 		# Skip things with no separator in them
 | ||
| 		if ($testname =~ /,/) {
 | ||
| 			1;
 | ||
| 		} else {
 | ||
| 			push @{$lists{'OTHER'}}, $tests[$i];
 | ||
| 		# Do not classify any test with no separators in it
 | ||
| 		if ($testname !~ /,/) {
 | ||
| 			push @{$l->{OTHER}->{OTHER}}, $tests[$i];
 | ||
| 			next;
 | ||
| 		}
 | ||
|  | ||
| 		my ($group,$host,$test) = split ',', $testname;
 | ||
|  | ||
| 		if (defined $group) {
 | ||
| 			push @{$lists{'GROUP:'.$group}}, $tests[$i];
 | ||
| 			push @{$l->{GROUP}->{$group}}, $tests[$i];
 | ||
| 		}
 | ||
| 		if (defined $host) {
 | ||
| 			push @{$lists{'HOST:'.$host}}, $tests[$i];
 | ||
| 			push @{$l->{HOST}->{$host}}, $tests[$i];
 | ||
| 		}
 | ||
| 		if (defined $test) {
 | ||
| 			push @{$lists{'TEST:'.$test}}, $tests[$i];
 | ||
| 			push @{$l->{TEST}->{$test}}, $tests[$i];
 | ||
| 		}
 | ||
|  | ||
| 		# TODO - this needs to have a better way...
 | ||
| ... | ... | |
| 		# "proxy-1" and "proxy-2" would both end up in the
 | ||
| 		# "proxy-" hosttype
 | ||
| 		if ($host =~ m/^(.*[^0-9])(\d+)$/) {
 | ||
| 			my $hosttype = 'TYPE:'.$1.'*';
 | ||
| 			my $hosttype = $1.'*';
 | ||
|  | ||
| 			# count the number of hosts within each type
 | ||
| 			# count each host only once
 | ||
| 			if (!defined $hostlist{$host}) {
 | ||
| 				$hostlist{$host}=1;
 | ||
| 				$hosttypecount{$hosttype}++;
 | ||
| ... | ... | |
|  | ||
| 	for my $i (keys %hosttypelist) {
 | ||
| 		if ($hosttypecount{$i} >1) {
 | ||
| 			push @{$lists{$i}}, @{$hosttypelist{$i}};
 | ||
| 			push @{$l->{TYPE}->{$i}}, @{$hosttypelist{$i}};
 | ||
| 		}
 | ||
| 	}
 | ||
|  | ||
| 	return %lists;
 | ||
|  | ||
| 	return $l;
 | ||
| }
 | ||
|  | ||
| my @tests = init_tests();
 | ||
| my %lists = init_lists(@tests);
 | ||
| my @tests = init_tests(@config_files);
 | ||
| my $lists = init_lists(@tests);
 | ||
|  | ||
| #use Data::Dumper;
 | ||
| #print Dumper(\@tests);
 | ||
| #print Dumper(\$lists);
 | ||
|  | ||
| # FIXME - globals
 | ||
| # Time the next update to occur a little while after the next interval completes
 | ||
| ... | ... | |
|     "\n";
 | ||
|  | ||
| # FIXME - use something that doesnt make "&" into "&" in the <a> tags
 | ||
| # 	you mean, like, a form?.  well, duh!
 | ||
|  | ||
| if (!defined param('list')) {
 | ||
| my @wantlist = split /,/,param('list');
 | ||
|  | ||
| if (!@wantlist) {
 | ||
| 	print table({-width=>"100\%"}, TR(td("Select which list to show")));
 | ||
| 	print "\n<ul>\n";
 | ||
| 	for my $i (sort keys %lists) {
 | ||
| 		print " ".li(a({-href=>$selfurl."list=$i"},"$i"))."\n";
 | ||
| 	print "\n<table border=2 cellpadding=4 cellspacing=0 style=\"margin: 1em 1em 1em 0; background: #f9f9f9; border: 1px #aaa solid; border-collapse: collapse; font-size: 95%;\">\n";
 | ||
| 	print "<tr>\n";
 | ||
| 	for my $i (sort keys %{$lists}) {
 | ||
| 		print "<th>$i</th>\n";
 | ||
| 	}
 | ||
| 	print "</tr><tr>\n";
 | ||
| 	for my $i (sort keys %{$lists}) {
 | ||
| 		print " <td valign=top>\n";
 | ||
| 		for my $j (sort keys %{$lists->{$i}}) {
 | ||
| 			print "  ".a({-href=>$selfurl."list=$i,$j"},"$j")."<br>\n";
 | ||
| 		}
 | ||
| 		print " </td>\n";
 | ||
| 	}
 | ||
| 	print "</ul>\n";
 | ||
| } elsif (!defined $lists{param('list')}) {
 | ||
| 	print "</tr></table>\n";
 | ||
| } elsif (!defined $lists->{$wantlist[0]}->{$wantlist[1]}) {
 | ||
| 	#FIXME
 | ||
| 	print table({-width=>"100\%"}, TR(td("That list is unavailable")));
 | ||
| } else {
 | ||
| 	my @list = @{$lists{param('list')}};
 | ||
| 	my @list = @{$lists->{$wantlist[0]}->{$wantlist[1]}};
 | ||
| 	$selfurl.='list='.param('list').'&';
 | ||
|  | ||
| 	my $graph='day';
 | ||
Also available in: Unified diff
convert internal lists to tree structure, change list display to a table