Changeset 461

Show
Ignore:
Timestamp:
21/11/04 00:17:47 (7 years ago)
Author:
jimmyo
Message:

Added per-plugin timeouts, contributed by Chan Wilson (SF#881044).

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • trunk/ChangeLog

    • Property cvs2svn:cvs-rev changed from 1.178 to 1.179
    r460 r461  
    2626    * The node now changes dir to /, to make sure it's in a directory 
    2727      readable by all users. 
     28        * Added per-plugin timeouts, contributed by Chan Wilson (SF#881044). 
    2829 
    2930  - Plugins 
  • trunk/node/munin-node.in

    • Property cvs2svn:cvs-rev changed from 1.16 to 1.17
    r429 r461  
    2121# 
    2222# $Log$ 
     23# Revision 1.17  2004/11/20 23:17:47  jimmyo 
     24# Added per-plugin timeouts, contributed by Chan Wilson (SF#881044). 
     25# 
    2326# Revision 1.16  2004/11/16 20:00:42  jimmyo 
    2427# License cleanups. 
     
    136139my $paranoia= 0; 
    137140my @ignores = (); 
    138 my %sconf   = (); 
    139 my $timeout = 10; 
     141my %sconf   = ('timeout' => 10); 
    140142my $caddr   = ""; 
    141143 
     
    239241  elsif (($1 eq "timeout") and defined $2) 
    240242  { 
    241       $timeout = $2; 
     243      $sconf{'timeout'} = $2; 
    242244  } 
    243245} 
     
    407409    {  
    408410      print ("# timeout pid $child - killing...");  
    409       logger ("Plugin timeout ($timeout seconds): $text (pid $child)"); 
     411      logger ("Plugin timeout: $text (pid $child)"); 
    410412      kill (-1, $child); sleep 2;  
    411413      kill (-9, $child); 
     
    421423  if ($services{$service} and ($caddr eq "" or &has_access ($service))) { 
    422424    my $child = 0; 
     425    my $timeout = get_var (\%sconf, $service, 'timeout'); 
     426    $timeout = $sconf{'timeout'}  
     427        unless defined $timeout and $timeout =~ /^\d+$/; 
    423428 
    424429    if ($child = open (CHILD, "-|")) { 
     
    556561  print "# munin node at $FQDN\n"; 
    557562  local $SIG{ALRM} = sub { logger ("Connection timed out."); die "timeout" }; 
    558   alarm($timeout); 
     563  alarm($sconf{'timeout'}); 
    559564  while( <STDIN> ){ 
    560     alarm($timeout); 
     565    alarm($sconf{'timeout'}); 
    561566    chomp; 
    562567    if (m/^list\s*([0-9a-zA-Z\.\-]+)?/) { 
     
    691696            $sconf->{$service}{'host_name'} = $1; 
    692697        } 
     698        elsif (/^\s*timeout\s+(\d+)\s*$/) 
     699        { 
     700            $sconf->{$service}{'timeout'} = $1; 
     701            print "DEBUG: $service: setting timeout to $1\n" 
     702                if $DEBUG; 
     703        } 
    693704        elsif (/^\s*(allow)\s+(.+)\s*$/ or /^\s*(deny)\s+(.+)\s*$/) 
    694705        { 
     
    960971=cut 
    961972 
    962 # vim:syntax=perl 
     973# vim:syntax=perl ts=8