mrtgidx
上传用户:shbosideng
上传日期:2013-05-04
资源大小:1555k
文件大小:2k
- #!/usr/tardis/local/gnu/bin/perl5
- # mrtgidx - generate html index page based on mrtg.cfg
- #
- # Syntax: mrtgidx <pathname-of-mrtg.cfg>
- #
- # v0.1 1996-11 by Axel Dunkel (ad@Dunkel.de)
- #
- # --- start of configuration section ---
- $include_inactive = 1; # include interfaces that are commented out
- # --- eof of configuration section ---
- if ($#ARGV < 0) {
- print "mrtgidx: generate HTML index page based on MRTG config filen";
- print "nUsage: mrtgidx <pathname-of-mrtg.cfg-file>n";
- exit 2;
- }
- while ($line = <>) {
- chop $line;
- if ($line =~ /^(#*).*Title[(S+)]:s*([^:]*):s*(.*)$/) {
- $cmt = $1;
- $itf = $2;
- $title = $3;
- $title_if = $4;
- if ($cmt ne "#" || $include_inactive) {
- if ($itf =~ /(.*).([0-9]+)/) {
- $router{$1,$2} = $title_if;
- $router_f{$1,$2} = $itf;
- $router_n{$1} = $title;
- $active{$1,$2} = $cmt;
- } else {
- print STDERR "Warning: can not interpret : $itfn";
- }
- }
- }
- }
- # print HTML header
- print "<HTML><HEAD><TITLE>MRTG Index</TITLE></HEAD>n";
- print "<BODY>n";
- print "<H1>MRTG - Index</H1>n";
- print "<FONT SIZE=-2>generated by mrtgidx by <A HREF="mailto:ad@dunkel.de">Axel Dunkel</A></FONT>n";
- print "<UL>n";
- foreach $r (sort keys %router_n) {
- print "<P><LI><H2>$r</H2><UL>n";
- foreach $i (0..200) {
- if (defined $router{$r,$i}) {
- print "<LI>";
- if ($active{$r,$i} ne "#") { print "<A HREF="$router_f{$r,$i}.html">"; }
- print "$router{$r,$i}";
- if ($active{$r,$i} ne "#") { print "</a>n"; }
- }
- }
- print "</UL>n";
- }
- print "</UL></BODY></HTML>n";