Changeset 3329

Show
Ignore:
Timestamp:
01/26/10 23:32:30 (2 years ago)
Author:
steve.schnepp
Message:

- added --only-fqn to be able to be compatible with multigraph and nested groups plugins
- added --no-fork to fix first time run

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • people/snide/pre_1.5/master/_bin/munin-fastcgi-graph.in

    r3325 r3329  
    7171while (new CGI::Fast) { 
    7272    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 
    7774   
    7875    if (! &verify_parameters ($dom, $host, $serv, $scale)) { 
     
    9289  
    9390    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"); 
    9592        goto draw; 
    9693    } 
     
    116113 
    117114  draw:   
    118     @stats           = stat ($filename) unless @stats; 
     115    @stats           = stat ($filename); # restat to be sure 
    119116    $last_modified   = strftime ("%a, %d %b %Y %H:%M:%S %Z", localtime ($stats[9])) unless defined($last_modified); 
    120117    # "Expires" has to use last modified time as base: 
     
    122119                                 gmtime($stats[9]+($period{$scale}-($stats[9]%$period{$scale})))) unless defined ($expires); 
    123120     
     121    print "Status: 200\n"; 
    124122    print "Content-Type: image/png\n"; 
     123    print "Content-Length: $stats[7]\n"; 
    125124    print "Expires: ", $expires, "\n"; 
    126125    print "Last-Modified: $last_modified\n"; 
    127126    print "\n"; 
    128      
     127 
    129128    &graph ($filename); 
    130129} 
     
    170169    my $filename = shift; 
    171170 
    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) 
    176174} 
    177175 
     
    294292sub draw_graph { 
    295293    # Draw a new graph - use semaphore to avoid too many concurrent munin-graph calls. 
     294    my $dom  = shift; 
    296295    my $host  = shift; 
    297296    my $serv  = shift; 
     
    305304    $host =~ s{[^\w_\/"'\[\]\(\)\.+=-]}{_}g; $host =~ /^(.+)$/; $host = $1; #" 
    306305 
     306    my $fqn = "root/$dom/$host/$serv"; 
     307 
    307308    my @params = (); 
    308309    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 
    310312    push @params, "--skip-locking", "--skip-stats", "--nolazy"; 
    311313    push @params, "--output-file", $filename; 
     
    330332    my $graph_duration = tv_interval($t0); 
    331333 
    332     print "X-Graph-Duration: $graph_duration\n"; 
    333  
    334334    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"); 
    336336        print "Status: 500\n"; 
    337337        print "Content-Type: image/png\n"; 
     
    339339        return 0; 
    340340    } else { 
     341        print "X-Graph-Duration: $graph_duration\n"; 
    341342        return $ret; 
    342343    } 
  • people/snide/pre_1.5/master/lib/Munin/Master/GraphOld.pm

    r3325 r3329  
    148148my @limit_hosts    = (); 
    149149my @limit_services = (); 
     150my $only_fqn; 
    150151 
    151152my $watermark = "Munin " . $Munin::Common::Defaults::MUNIN_VERSION; 
     
    187188                "host=s"        => \@limit_hosts, 
    188189                "service=s"     => \@limit_services, 
     190                "only-fqn=s"     => \$only_fqn, 
    189191                "config=s"      => \$conffile, 
    190192                "stdout!"       => \$stdout, 
     
    13721374    my $fqn   = munin_get_node_fqn($service); 
    13731375 
     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 
    13741380    # Skip if we've limited services with cli options 
    13751381    return 1 if (@limit_services and ! (grep { ends_with($fqn, $_) } @limit_services));