#!/usr/bin/perl use strict; use warnings; use RRDs; use CGI; use CGI::Carp qw(fatalsToBrowser); my $TMPLpath = "/var/www/mrtg/tmpl"; my $cgi = new CGI; my $graph = $cgi->param('graph') || $ARGV[0]; $|++; print $cgi->header(-type => "image/png") unless($ARGV[0]); if($graph) { if(open(RRD,"<$TMPLpath/$graph.tmpl")) { my @rrd = ; close(RRD); chomp(@rrd); my @opts; if($cgi->param('start')) { push @opts,"--start=" . $cgi->param('start'); } if($cgi->param('end')) { push @opts,"--end=" . $cgi->param('end'); } if($cgi->param('width')) { push @opts,"-w ".$cgi->param('width'); } if($cgi->param('height')) { push @opts,"-h ".$cgi->param('height'); } push @opts,@rrd; if($ARGV[0]) { foreach (@rrd) { print $_ . "\n"; } # exit; } RRDs::graph("-",@opts) or die(RRDs::error); } }