Changeset 3329
- Timestamp:
- 01/26/10 23:32:30 (2 years ago)
- Files:
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
people/snide/pre_1.5/master/_bin/munin-fastcgi-graph.in
r3325 r3329 71 71 while (new CGI::Fast) { 72 72 my $path = $ENV{PATH_INFO} || ""; 73 $path =~ s/^\///; 74 ($dom, $host, $serv) = split /\//, $path, 3; 75 ($serv, $scale) = split /-/, $serv, 2; 76 $scale =~ s/\.png$//; 73 ($dom, $host, $serv, $scale) = $path =~ m#^/(.*)/([^/]+)/(\w+)-(\w+)\.png#; ## avoid bug in vim 77 74 78 75 if (! &verify_parameters ($dom, $host, $serv, $scale)) { … … 92 89 93 90 if ($no_cache or (! &graph_usable ($filename, $time) )) { 94 next unless draw_graph_or_complain($ host, $serv, $TIMES{$scale}, $filename, "$config->{logdir}/munin-cgi-graph.log");91 next unless draw_graph_or_complain($dom, $host, $serv, $TIMES{$scale}, $filename, "$config->{logdir}/munin-cgi-graph.log"); 95 92 goto draw; 96 93 } … … 116 113 117 114 draw: 118 @stats = stat ($filename) unless @stats;115 @stats = stat ($filename); # restat to be sure 119 116 $last_modified = strftime ("%a, %d %b %Y %H:%M:%S %Z", localtime ($stats[9])) unless defined($last_modified); 120 117 # "Expires" has to use last modified time as base: … … 122 119 gmtime($stats[9]+($period{$scale}-($stats[9]%$period{$scale})))) unless defined ($expires); 123 120 121 print "Status: 200\n"; 124 122 print "Content-Type: image/png\n"; 123 print "Content-Length: $stats[7]\n"; 125 124 print "Expires: ", $expires, "\n"; 126 125 print "Last-Modified: $last_modified\n"; 127 126 print "\n"; 128 127 129 128 &graph ($filename); 130 129 } … … 170 169 my $filename = shift; 171 170 172 open (my $GRAPH, '<', $filename) 173 or die "Warning: Could not open picture file \"$filename\" for reading: $!\n"; 174 print while (<$GRAPH>); 175 close ($GRAPH); 171 open (GRAPH_PNG_FILE, '<', $filename) or die "Warning: Could not open picture file \"$filename\" for reading: $!\n"; 172 print while (<GRAPH_PNG_FILE>); 173 close (GRAPH_PNG_FILE) 176 174 } 177 175 … … 294 292 sub draw_graph { 295 293 # Draw a new graph - use semaphore to avoid too many concurrent munin-graph calls. 294 my $dom = shift; 296 295 my $host = shift; 297 296 my $serv = shift; … … 305 304 $host =~ s{[^\w_\/"'\[\]\(\)\.+=-]}{_}g; $host =~ /^(.+)$/; $host = $1; #" 306 305 306 my $fqn = "root/$dom/$host/$serv"; 307 307 308 my @params = (); 308 309 push @params, @$scale; 309 push @params, "--host", $host, "--service", $serv; 310 push @params, "--host", $host, "--only-fqn", $fqn; 311 push @params, "--no-fork"; # FastCgi forks for us 310 312 push @params, "--skip-locking", "--skip-stats", "--nolazy"; 311 313 push @params, "--output-file", $filename; … … 330 332 my $graph_duration = tv_interval($t0); 331 333 332 print "X-Graph-Duration: $graph_duration\n";333 334 334 if (! -f $ret) { 335 ::logger ("Warning: Could not draw graph \"$host-$serv-$scale.png\": $ret");335 ::logger("Warning: Could not draw graph \"$host-$serv-$scale.png\": $ret"); 336 336 print "Status: 500\n"; 337 337 print "Content-Type: image/png\n"; … … 339 339 return 0; 340 340 } else { 341 print "X-Graph-Duration: $graph_duration\n"; 341 342 return $ret; 342 343 } people/snide/pre_1.5/master/lib/Munin/Master/GraphOld.pm
r3325 r3329 148 148 my @limit_hosts = (); 149 149 my @limit_services = (); 150 my $only_fqn; 150 151 151 152 my $watermark = "Munin " . $Munin::Common::Defaults::MUNIN_VERSION; … … 187 188 "host=s" => \@limit_hosts, 188 189 "service=s" => \@limit_services, 190 "only-fqn=s" => \$only_fqn, 189 191 "config=s" => \$conffile, 190 192 "stdout!" => \$stdout, … … 1372 1374 my $fqn = munin_get_node_fqn($service); 1373 1375 1376 # Skip if we've limited services with the omnipotent cli option only-fqn 1377 return 1 if ($only_fqn and ! ends_with($fqn, $only_fqn)); 1378 DEBUG "[DEBUG] $fqn is in ($only_fqn)\n"; 1379 1374 1380 # Skip if we've limited services with cli options 1375 1381 return 1 if (@limit_services and ! (grep { ends_with($fqn, $_) } @limit_services));
