#!/usr/bin/perl # copyright Martin Pot 2003 # http://martybugs.net/linux/rrdtool/traffic.cgi # # traffic.cgi my @graphs; my ($name, $descr); # define graphs to display (add/remove as required) push (@graphs, "eth0"); push (@graphs, "ppp0"); # get the server name (or you could hard code some description here) my $svrname = $ENV{'SERVER_NAME'}; # get url parameters my @values = split(/&/, $ENV{'QUERY_STRING'}); foreach my $i (@values) { ($varname, $mydata) = split(/=/, $i); if ($varname eq 'trend') { $name = $mydata; } } if ($name eq '') { $descr = "summary"; } else { $descr = "$name"; } print "Content-type: text/html;\n\n"; print < $svrname network traffic :: $descr $svrname network traffic :: $descr

END ; if ($name eq '') { print "Daily Graphs (5 minute averages)"; print "
"; foreach $graph (@graphs) { print ""; print "
"; } } else { print <
Weekly Graph (30 minute averages)

Monthly Graph (2 hour averages)

Yearly Graph (12 hour averages)
END ; } print <
END ;