Project

General

Profile

« Previous | Next » 

Revision 1b1c276c

Added by Hamish Coleman almost 17 years ago

  • ID 1b1c276ce1f4e67c6084e58bff7a691656269bf0

Yank new code above old page logic, sort by sequence, simplify shown tree, remove some debug

View differences:

mrtg.cgi
if (defined $hosttype) {
$db->{tree}->{group}->{$group}->{host}->{$hosttype}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{group}->{$group}->{host}->{$hosttype}->{test}->{$test}->{$host}->{$name} = $sequence;
$db->{tree}->{host}->{$hosttype}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{test}->{$test}->{$hosttype}->{$host}->{$name} = $sequence;
$db->{tree}->{group}->{$group}->{host}->{$hosttype}->{test}->{$test}->{$name} = $sequence;
$db->{tree}->{group}->{ALL}->{host}->{$hosttype}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{group}->{ALL}->{test}->{$test}->{$hosttype}->{$host}->{$name} = $sequence;
$db->{tree}->{group}->{$group}->{test}->{$test}->{$hosttype}->{$host}->{$name} = $sequence;
} else {
$db->{tree}->{group}->{$group}->{host}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{host}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{test}->{$test}->{$host}->{$name} = $sequence;
$db->{tree}->{group}->{ALL}->{host}->{$host}->{$test}->{$name} = $sequence;
$db->{tree}->{group}->{ALL}->{test}->{$test}->{$host}->{$name} = $sequence;
$db->{tree}->{group}->{$group}->{test}->{$test}->{$host}->{$name} = $sequence;
}
......
for my $i (sort keys %{$dir}) {
my $val = $dir->{$i};
if (!ref($val)) {
#print "insDoc($parentnode, gLnk(\"S\", \"$i\", \"?page=x&path=$path:$i\"))\n";
#print "insDoc($parentnode, gLnk(\"S\", \"$i\", \"?path=$path:$i\"))\n";
next;
}
my $node = 'n'.$node_next++;
print "$node = insFld($parentnode, gFld(\"$i\", \"?page=x&path=$path:$i\"))\n";
print "$node = insFld($parentnode, gFld(\"$i\", \"?path=$path:$i\"))\n";
emit_tree_one("$node","$path:$i",$val);
}
}
......
for my $i (keys %{$node[0]}) {
my $val = $node[0]->{$i};
if (!ref($val)) {
$targets{$i}++;
$targets{$i}=$val; # set sequence number
} else {
push @node,$val;
}
......
}
# TODO - sort by sequence numbers
for my $i (keys %targets) {
for my $i (sort {$targets{$a} <=> $targets{$b}} keys %targets) {
my $target = $db->{target}->{$i};
# FIXME - what if mtime is undef?
......
);
print br,br,"\n";
}
print "<pre>\n";
print Dumper(\%targets);
print "</pre>\n";
}
sub init_tests(@) {
......
print a({-href=>"?page=treeview",-target=>"_top"}, "Tree (Frames)");
}
my $page = param('page') || 'treenf';
my $this_host = hostname;
my @tests;
my $lists;
if($page eq 'treeview') {
print "Content-type: text/html\n\n";
print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
print "<script>\n";
print "function op() { }\n";
print "</script>\n";
print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
print '<frame src="?page=treemenu" name=treeframe>';
print '<frame src="javascript:parent.op()" name=basefrm>';
print "</frameset>\n";
print "</html>\n";
} elsif($page eq 'list') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
my $guardband = 15; # updates occur this many seconds after predicted gif completion
my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
my $list = param('list');
my $graph = param('graph') || 'day';
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
if ($list) {
print_graph_chooser($graph,$list,$page,'none');
print "<br/>";
print_list($lists,$graph,$list,'basefrm');
}
print end_html;
} elsif($page eq 'treemenu') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
print <<EOF;
<STYLE>
BODY {
background-color: white;}
TD {
font-size: 10pt;
font-family: verdana,helvetica;
text-decoration: none;
white-space:nowrap;}
A {
text-decoration: none;
color: black;}
.specialClass {
font-family:garamond;
font-size:12pt;
color:green;
font-weight:bold;
text-decoration:underline}
</STYLE>
EOF
print '<script src="ua.js"></script>';
print '<script src="ftiens4.js"></script>';
print '<script>';
print_treemenu('frame',$lists);
print '</script>';
print '<DIV style="position:absolute; top:0; left:0;"><TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>Javascript Tree Menu</A></FONT></TD></TR></TABLE></DIV>';
print '<script>initializeDocument()</script>';
print '<NOSCRIPT>A tree for site navigation will open here if you enable JavaScript in your browser.</NOSCRIPT>';
print hr;
print_menutypelist();
print end_html;
} elsif($page eq 'treenf') {
if(defined param('path')) {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)",
-bgcolor=>"white",
......
-onResize=>"if (navigator.family == 'nn4') window.location.reload()" ),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
config_load_file(@config_files);
config_read_filesystem();
maketree();
print <<EOF;
<STYLE>
......
print '<script src="ua.js"></script>';
print '<script src="ftiens4.js"></script>';
print '<script>';
print_treemenu('treenf',$lists);
emit_tree('treenf');
print '</script>';
print <<EOF;
<TABLE cellpadding="0" cellspacing="0" border="0" width="772">
......
A tree for site navigation will open here if you enable JavaScript in your browser.
</NOSCRIPT>
</SPAN>
EOF
print hr;
print_menutypelist();
print <<EOF;
</TD>
</TR>
</TABLE>
......
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
my $list = param('list');
my $path = param('path');
my $graph = param('graph') || 'day';
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
if ($list) {
print_graph_chooser($graph,$list,$page,'none');
if ($path) {
print_graph_chooser($graph,'FIXME','FIXME','none');
print "<br/>";
print_list($lists,$graph,$list,'_self');
emit_path_contents($path,$graph);
}
print <<EOF;
......
EOF
print end_html;
} elsif($page eq 'x') {
} else {
my $page = param('page') || 'treenf';
my @tests;
my $lists;
if($page eq 'treeview') {
print "Content-type: text/html\n\n";
print "<html><head><title>$this_host MRTG Index (V$VERSION)</title></head>\n";
print "<script>\n";
print "function op() { }\n";
print "</script>\n";
print '<frameset cols="200,*">'; # FIXME onresize if navigator.family==nn4
print '<frame src="?page=treemenu" name=treeframe>';
print '<frame src="javascript:parent.op()" name=basefrm>';
print "</frameset>\n";
print "</html>\n";
} elsif($page eq 'list') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
# Time the next update to occur a little while after the next interval completes
my $interval = 300; # 5 min update interval
my $guardband = 15; # updates occur this many seconds after predicted gif completion
my $refresh = $interval + $guardband + $gifdone - time; # predict how long until next update
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
my $list = param('list');
my $graph = param('graph') || 'day';
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
if ($list) {
print_graph_chooser($graph,$list,$page,'none');
print "<br/>";
print_list($lists,$graph,$list,'basefrm');
}
print end_html;
} elsif($page eq 'treemenu') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)", -BGCOLOR=>'#e6e6e6'),
"\n";
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
print <<EOF;
<STYLE>
BODY {
background-color: white;}
TD {
font-size: 10pt;
font-family: verdana,helvetica;
text-decoration: none;
white-space:nowrap;}
A {
text-decoration: none;
color: black;}
.specialClass {
font-family:garamond;
font-size:12pt;
color:green;
font-weight:bold;
text-decoration:underline}
</STYLE>
EOF
print '<script src="ua.js"></script>';
print '<script src="ftiens4.js"></script>';
print '<script>';
print_treemenu('frame',$lists);
print '</script>';
print '<DIV style="position:absolute; top:0; left:0;"><TABLE border=0><TR><TD><FONT size=-2><A style="font-size:7pt;text-decoration:none;color:silver" href="http://www.treemenu.net/" target=_blank>Javascript Tree Menu</A></FONT></TD></TR></TABLE></DIV>';
print '<script>initializeDocument()</script>';
print '<NOSCRIPT>A tree for site navigation will open here if you enable JavaScript in your browser.</NOSCRIPT>';
print hr;
print_menutypelist();
print end_html;
} elsif($page eq 'treenf') {
print header,
start_html(-TITLE=>"$this_host MRTG Index (V$VERSION)",
-bgcolor=>"white",
......
-onResize=>"if (navigator.family == 'nn4') window.location.reload()" ),
"\n";
config_load_file(@config_files);
config_read_filesystem();
maketree();
@tests = init_tests(@config_files);
$lists = init_lists(@tests);
print <<EOF;
<STYLE>
......
print '<script src="ua.js"></script>';
print '<script src="ftiens4.js"></script>';
print '<script>';
emit_tree('treenf');
print_treemenu('treenf',$lists);
print '</script>';
print <<EOF;
<TABLE cellpadding="0" cellspacing="0" border="0" width="772">
......
A tree for site navigation will open here if you enable JavaScript in your browser.
</NOSCRIPT>
</SPAN>
EOF
print hr;
print_menutypelist();
print <<EOF;
</TD>
</TR>
</TABLE>
......
$refresh = $interval if $refresh <= $guardband;
my $expires = gmtime (time + $interval * 2 + $guardband);
my $path = param('path');
my $list = param('list');
my $graph = param('graph') || 'day';
print
"<meta http-equiv=\"expires\" content=\"$expires GMT\">\n",
"<meta http-equiv=\"refresh\" content=$refresh>\n";
if ($path) {
print_graph_chooser($graph,'FIXME',$page,'none');
if ($list) {
print_graph_chooser($graph,$list,$page,'none');
print "<br/>";
emit_path_contents($path,$graph);
print_list($lists,$graph,$list,'_self');
}
print <<EOF;
......
}
}
if ($warnings && param('debug')) {
print "<pre>\n", "$warnings", "</pre>\n";
}
print "<pre>\n";
print Dumper(\$db),"\n";
#emit_tree('treenf');
print "</pre>";
#print "<pre>\n";
#print Dumper(\$db),"\n";
#print "</pre>";

Also available in: Unified diff