my ($section, $group, $elem, $basis, $args) = @_;
$basis->{Args}= $args;
$basis->{Slower}= 0 unless exists $basis->{Slower};
-
+ $basis->{TimeRanges} ||= \@timeranges;
$graphs{$section,$group,$elem}= $basis;
if (!exists $group_elems{$section,$group}) {
# new group then
$site =~ s/^([-.0-9a-z]+)_//;
my $us= $1; # all very well but we ignore it
my $newsite= $news_name_map{$site,$inout};
- next if $newsite eq '-';
$site= $newsite if defined $newsite;
+ next if $site eq '-';
graph_of_group("News", $site, $inout,
{
- Slower => 1,
- Units => '[art/s]'
+ Units => '[art/s]',
+ TimeRanges => [ map { $_*86400 } qw(1 7 31), 366, 366*3 ]
}, $inout eq 'out' ?
[
(map { "DEF:$_=$src:$_:AVERAGE" }
"AREA:rejected#f00:rej:STACK",
"AREA:duplicate#000:dupe:STACK",
"AREA:refused#aaa:unw:STACK",
+ "CDEF:kb_accepted_smooth=kb_accepted,<interval/60>,TREND",
"LINE:kb_duplicate#ff0:kb dupe",
- "LINE:kb_accepted#008:kb",
+ "LINE:kb_accepted_smooth#008:~kb",
]);
}
my $g= $graphs{$section,$group,$elem};
die unless $g;
- my @args= @{ $g->{Args} };
-
my $width= num_param('w',370,100,1600);
my $height= num_param('h',200,100,1600);
my $sloth= param('sloth');
die unless defined $sloth;
$sloth =~ m/^(\d+)$/ or die;
- my $end= $timeranges[$sloth];
- die unless defined $end;
+ $sloth= $1+0;
+ my $end= $g->{TimeRanges}[$sloth];
+
+ 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;
-
- exec (qw(rrdtool graph - -a PNG --full-size-mode),
- '-w',$width, '-h',$height,
- @args);
+ 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;
+ }
+
+#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 $!;
}