Package: munin
Version: 1.4.4-1
Severity: normal
Tags: patch

Hi,

when watchin a multigraph page usign cgi-graphing, my apache2 errorlog gets 
clobbed with lines like this:
---snip------------------
[Sun May 23 17:45:15 2010] [error] [client 10.0.50.112] Use of uninitialized 
value $scale in substitution (s///) at /usr/lib/cgi-bin/munin-cgi-graph line 
68., referer: 
https://localhost/munin/mydomain/myhost.mydomain/diskstats_iops/index.html
[Sun May 23 17:45:15 2010] [error] [client 10.0.50.112] Warning: Request for 
graph without specifying scale. Bailing out., referer: 
https://localhost/munin/mydomain/myhost.mydomain/diskstats_iops/index.html
[Sun May 23 17:45:15 2010] [error] [client 10.0.50.112] Premature end of script 
headers: munin-cgi-graph, referer: 
https://localhost/munin/mydomain/myhost.mydomain/diskstats_iops/index.html
---snap------------------

I found out that the number of path elements is different for single-graphs and 
multi-graphs. So for multi-graphs the regexp 

munin-cgi-graph:67: ($serv, $scale) = split /-/, $serv, 2;

does no good, since prior to the assignment, $serv only contains the service 
name and not the needed trailling "/$object-$scale.png"

I attached a patch which slightly changes the assignment in line 66, checks for 
an empty $scale argument and acts like for a single graph request. If it's 
already been set from line 66, it assumes an image request for a multigraph.

Works fine on several of my debian testing systems for single- and multi-graphs 
here.

Cheers
Daniel

-- System Information:
Debian Release: squeeze/sid
  APT prefers testing
  APT policy: (990, 'testing'), (500, 'unstable'), (500, 'stable'), (1, 
'experimental')
Architecture: amd64 (x86_64)

Kernel: Linux 2.6.32-dhr (SMP w/2 CPU cores)
Locale: LANG=en_US.UTF8, LC_CTYPE=en_US.UTF8 (charmap=UTF-8)
Shell: /bin/sh linked to /bin/bash

Versions of packages munin depends on:
ii  munin-common                1.4.4-1      network-wide graphing framework (c

Versions of packages munin recommends:
ii  libdate-manip-perl            6.07-2     module for manipulating dates
ii  munin-node                    1.4.4-1    network-wide graphing framework (n
--- munin-cgi-graph.org 2010-05-23 17:59:21.121176136 +0200
+++ munin-cgi-graph     2010-05-23 18:11:01.645675961 +0200
@@ -63,9 +63,15 @@
 
 my $path = $ENV{PATH_INFO} || "";
 $path =~ s/^\///;
-($dom, $host, $serv) = split /\//, $path;
-($serv, $scale) = split /-/, $serv, 2;
-$scale =~ s/\.png$//;
+($dom, $host, $serv, $scale) = split /\//, $path;
+if ($scale eq "") {
+       # assume classic single-graph image request
+       ($serv, $scale) = split /-/, $serv, 2;
+       $scale =~ s/\.png$//;
+} else { 
+       # assume multi-graph image request
+       $scale =~ s/.*-([a-z]*)\.png$/$1/;
+}
 
 &verify_parameters ($dom, $host, $serv, $scale);
 

Reply via email to