add tmpl
This commit is contained in:
21
htdocs/cgi-bin/details.pl
Executable file
21
htdocs/cgi-bin/details.pl
Executable file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/perl
|
||||
|
||||
use strict;
|
||||
use warnings;
|
||||
use Template;
|
||||
use CGI;
|
||||
use CGI::Carp qw(fatalsToBrowser);
|
||||
|
||||
my $cgi = new CGI;
|
||||
my $var = {
|
||||
GRAPH => $cgi->param('graph')
|
||||
};
|
||||
|
||||
my $template = Template->new({
|
||||
INCLUDE_PATH => '/var/www/mrtg/tmpl',
|
||||
INTERPOLATE => 1,
|
||||
});
|
||||
|
||||
$|++;
|
||||
print $cgi->header();
|
||||
$template->process('details.tmpl',$var);
|
46
htdocs/cgi-bin/graph.pl
Executable file
46
htdocs/cgi-bin/graph.pl
Executable file
@ -0,0 +1,46 @@
|
||||
#!/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 = <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);
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user