On Tue, Nov 03, 2009 at 10:32:18AM +0100, Valentin Vidic wrote:
> After enabling munin-cgi-graph generator and doing a page reload
> apache2 error logs start filling up with with the following error:
>
> [Tue Nov 03 10:10:10 2009] [error] [client 1.2.3.4] Use of uninitialized
> value $ifmodsec in numeric lt (<) at /usr/lib/cgi-bin/munin-cgi-graph line
> 301., referer: http://webhost/domain/host.domain-processor.html
>
> It looks like the parameters passed to modified function are not correct.
> I think this is fixed in munin SVN and should be backported to Debian
> package.
It seems the whole if-modified-since logic was wrong since it was
returning 304 all the time after the first page load. New patch fixes
this making sure the graphs get regenerated once every 5 minutes.
--
Valentin
--- munin-cgi-graph.orig 2009-11-12 14:21:09.000000000 +0100
+++ munin-cgi-graph 2009-11-12 16:01:39.000000000 +0100
@@ -76,10 +76,12 @@
{
my @sstats = stat ($filename);
my $slast_modified = strftime ("%a, %d %b %Y %H:%M:%S %Z", localtime ($sstats[9]));
+ my $expires = $sstats[9] + $period{$scale} - $sstats[9] % $period{$scale};
if (defined $ENV{HTTP_IF_MODIFIED_SINCE} and
- !&modified (gmtime(time+($period{$scale}-($time%$period{$scale}))),
- $sstats[9]-1)) {
+ !&modified ($ENV{HTTP_IF_MODIFIED_SINCE}, $sstats[9]-1) and
+ $expires > $time)
+ {
print "Status: 304\n";
print "Content-Type: image/png\n";
print "Expires: ", strftime ("%a, %d %b %Y %H:%M:%S GMT", gmtime(time+($period{$scale}-($time%$period{$scale})))), "\n";
@@ -250,7 +252,7 @@
if (-f $filename) {
my @stats = stat (_);
- my $expire = ($stats[9] - $time%$period{$scale}+$period{$scale})-$time;
+ my $expire = ($stats[9] - $stats[9]%$period{$scale}+$period{$scale})-$time;
#print STDERR "Expires in: $expire\n";
if ($expire >= 0) {