Changeset 1217

Show
Ignore:
Timestamp:
30/10/06 15:56:53 (4 years ago)
Author:
janl
Message:
  • munin-cgi-graph: Patch to limit number of concurrent rrdgraph processes
Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/server/munin-cgi-graph.in

    r900 r1217  
    11#!@@PERL@@  -Tw 
    2 # 
    32# 
    43# Copyright (C) 2004 Jimmy Olsen 
     
    5049my $serv  = ""; 
    5150my $dom   = ""; 
     51my $lock  = ""; 
    5252 
    5353my $config = &munin_readconfig ($conffile); 
     
    103103print "\n"; 
    104104 
     105# Try to police the number of concurrent rrdgraph instances.  The 
     106# third value is the default maximum. 
     107 
     108# NOTE: The munin_*lock functions are not exactly ideal for race prone 
     109# locking, they're a bit fuzzy.  A better solution, which would not 
     110# imply a "sleep 1" would be to use semaphores.  See "perldoc perlipc" 
     111# and "man semop". 
     112 
     113my $max_cgi_graph_jobs = &munin_get ($config, "max_cgi_graph_jobs" , 6, $dom); 
     114 
     115until ( $lock ) { 
     116    foreach my $n ( 1 .. $max_cgi_graph_jobs ) { 
     117       if (&munin_getlock ("$config->{rundir}/munin-cgi-graph-$n.lock")) { 
     118           $lock = "munin-cgi-graph-$n.lock"; 
     119           last; 
     120       } 
     121    } 
     122    sleep 1; 
     123} 
    105124 
    106125&graph ($filename); 
     126 
     127munin_removelock($lock); 
    107128 
    108129sub graph