my $sloth= param('sloth');
die unless defined $sloth;
$sloth =~ m/^(\d+)$/ or die;
+ $sloth= $1+0;
my $end= $g->{TimeRanges}[$sloth];
- die unless defined $end;
+
+ my $cacheid= "$section!$group!$elem!$sloth!$width!$height";
+ my $cachepath= "cache/$cacheid.png";
my @args= @{ $g->{Args} };
s,\<interval/(\d+)\>, $end/$1 ,ge foreach @args;
unshift @args, qw(--end now --start), "end-${end}s";
- if (param('debug')) {
- print((join "\n",@args),"\n"); exit 0;
- }
- print "Content-Type: image/png\n\n";
-
my $title= $group;
if (length $elem) { $title.= " $elem"; }
$title .= " $g->{Units}" if $g->{Units};
- unshift @args, '-t', $title;
+ unshift @args, '-t', $title, '-w',$width, '-h',$height;
+ unshift @args, qw(-a PNG --full-size-mode);
+
+ if (param('debug')) {
+ print((join "\n",@args),"\n"); exit 0;
+ }
- exec (qw(rrdtool graph - -a PNG --full-size-mode),
- '-w',$width, '-h',$height,
- @args);
+#print STDERR "||| ",(join ' ', map { "'$_'" } @args)." |||\n";
+ exec(qw(sh -ec), <<'END', 'x', $cachepath, @args);
+ p="$1"; shift
+ rrdtool graph "$p" --lazy "$@" >/dev/null
+ printf "Content-Type: image/png\n\n"
+ exec cat "$p"
+END
die $!;
}