1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141
|
#!/usr/bin/perl
# -*- mode: Perl -*-
##################################################################
# Multi Router Traffic Grapher: Index Generator
##################################################################
#
# This reads a mrtg.cfg file form std input or cmdline argument
# and it takes a regexp on the cmdline to specify which
# targets to look at.
#
# from this info it produces a router index on std out.
#
##################################################################
# Created by Tobias Oetiker <oetiker@ee.ethz.ch>
# Distributed under the GNU copyleft
#
# $Id: indexmaker,v 2.2 1997/06/12 08:18:29 oetiker Exp $
##################################################################
$regexp = pop @ARGV;
$Title = pop @ARGV;
if (defined($Title) && -f $Title) {
push(@ARGV, $Title);
$Title = "$Title Overview ($regexp)";
}
if (! -f $ARGV[0]) {
print "
USAGE: indexmaker <mrtg.cfg> <title> <regular expression>
This tool will read the contents of the mrtg.cfg file and will
return the HTML code of a webpage contanig the 'daily' graphs
of all the routers whose titles match the regular expression.
NOTE: you have to adjust this tool to your needs as the HTML
contains our logo and our name ...
";
exit ;
}
#slurp the cfg file
while(<>) {
s/\t/ /g; #replace tabs by spac
next if /^\s+$/; #ignore white space
next if /^\s*\#/; #ignore comments
if (/$regexp/i && ! /\[\^\]/ && ! /\[\$\]/ && /^title\[([^\]]+)\]:\s*(.*\S)/i) {
$router=lc($1);
$arg=$2;
$titles{$router} = $arg;
next;
}
if (/^directory\[([^\]]+)\]:\s*(.*\S)/i) {
$arg = $2;
$tmp = lc($1);
$dirs{$tmp} = "$arg/";
}
if ($router && /^pagetop\[([^\]]+)\]:\s*(.*\S)/i) {
next;
}
if ($router && /^\s+(.*?)<\/H1>/) {
$titles{$router} .= " $1";
}
$router = '';
}
print <<ECHO;
<HTML>
<HEAD>
<TITLE>$Title</TITLE>
</HEAD>
<BODY bgcolor=#ffffff>
<TABLE BORDER=0 CELLSPACING=0 CELLPADING=0 WIDTH=100%>
<TR><TD><A HREF="http://www.ethz.ch">
<img border=0 alt="ETH: " src="/eth.199x32.gif"
HEIGHT=32 WIDTH=199></A>
</TD>
<TD ALIGN=RIGHT>
<A HREF="http://www.ethz.ch/">
Swiss Federal Institute of Technology Zurich</A><BR>
<A HREF="http://www.ee.ethz.ch/">
Department of Electrical Engineering</A><BR>
</TD>
</TR>
</TABLE>
<H1>$Title</H1>
ECHO
foreach $router (sort {$titles{$a} cmp $titles{$b}} keys %titles) {
$dirs{$router} = "" if (!defined($dirs{$router}));
$rdir = $dirs{$router};
print <<ECHO;
<P><B><A HREF="$rdir$router.html">$titles{$router}</B><P>
<SMALL><!--#flastmod file="$rdir$router.html" --></SMALL></P>
<IMG BORDER=0 WIDTH=500 HEIGHT=135 SRC="$rdir$router-day.gif"></A>
<HR>
ECHO
}
'$Revision: 2.2 $ ' =~ /Revision: (\S*)/;
$rev=$1;
'$Date: 1997/06/12 08:18:29 $ ' =~ /Date: (\S*)/;
$date=$1;
print <<ECHO;
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR>
<TD WIDTH=63><A ALT="MRTG"
HREF="http://www.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html"><IMG
BORDER=0 SRC="/doc/mrtg/mrtg-l.gif"></A></TD>
<TD WIDTH=25><A ALT=""
HREF="http://www.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html"><IMG
BORDER=0 SRC="/doc/mrtg/mrtg-m.gif"></A></TD>
<TD WIDTH=388><A ALT=""
HREF="http://www.ee.ethz.ch/~oetiker/webtools/mrtg/mrtg.html"><IMG
BORDER=0 SRC="/doc/mrtg/mrtg-r.gif"></A></TD>
</TR>
</TABLE>
<SPACER TYPE=VERTICAL SIZE=4>
<TABLE BORDER=0 CELLSPACING=0 CELLPADDING=0>
<TR VALIGN=top>
<TD WIDTH=88 ALIGN=RIGHT><FONT FACE="Arial,Helvetica" SIZE=2>
$rev-$date</FONT></TD>
<TD WIDTH=388 ALIGN=RIGHT><FONT FACE="Arial,Helvetica" SIZE=2>
<A HREF="http://www.ee.ethz.ch/~oetiker">Tobias Oetiker</A>
<A HREF="mailto:oetiker\@ee.ethz.ch"><oetiker\@ee.ethz.ch></A>
and <A HREF="http://www.bungi.com">Dave Rand</A> <A HREF="mailto:dlr\@bungi.com"><dlr\@bungi.com></A></FONT>
</TD>
</TR>
</TABLE>
</BODY></HTML>
ECHO
|