Changeset d75bc41ea17e2fac447a58bb98a98fcf5a465160

Show
Ignore:
Timestamp:
01/02/09 19:30:32 (5 years ago)
Author:
Mark Harrison <mark@omniti.com>
git-committer:
Mark Harrison <mark@omniti.com> 1230924632 +0000
git-parent:

[ac12e51369119edd57d0699062ab00ae200ac562]

git-author:
Mark Harrison <mark@omniti.com> 1230924632 +0000
Message:

Implement a timeout for sluggish checks

git-svn-id: https://labs.omniti.com/resmon/trunk@153 8c0face9-b7db-6ec6-c4b3-d5f7145c7d55

Files:

Legend:

Unmodified
Added
Removed
Modified
Copied
Moved
  • lib/Resmon/Config.pm

    r7b9e8bc rd75bc41  
    88  my $self = bless { 
    99    configfile => $filename, 
    10     modstatus => '' 
     10    modstatus => '', 
     11    # Defaults 
     12    timeout => 10 
    1113  }, $class; 
    1214  open(CONF, "<$filename") || return undef; 
     
    7577        next; 
    7678      } 
     79      elsif(/\s*TIMEOUT\s+(\d+)\s*;\s*/) { 
     80        $self->{timeout} = $1; 
     81        next; 
     82      } 
    7783      else { 
    7884        die "Syntax Error on line $line\n"; 
  • resmon

    r021df69 rd75bc41  
    126126      # Otherwise, run the check 
    127127      if (!$check_rv) { 
     128        eval { 
     129          local $SIG{ALRM} = sub { die "alarm\n" }; 
     130          local $SIG{CHLD} = 'IGNORE'; 
     131          alarm $config->{timeout}; 
    128132          if($coderef) { 
    129             eval { ($check_rv, $check_mess) = $coderef->($monobj); }
     133            ($check_rv, $check_mess) = $coderef->($monobj)
    130134          } else { 
    131             eval { ($check_rv, $check_mess) = $monobj->handler(); }
     135            ($check_rv, $check_mess) = $monobj->handler()
    132136          } 
    133           # Store the last status for use by fresh_status_msg later 
    134           # Also converts old style status messages 
    135           ($check_rv, $check_mess) = 
    136             Resmon::Module::set_status($monobj, $check_rv, $check_mess); 
     137          alarm 0; 
     138        }; 
     139        # Store the last status for use by fresh_status_msg later 
     140        # Also converts old style status messages 
     141        ($check_rv, $check_mess) = 
     142          Resmon::Module::set_status($monobj, $check_rv, $check_mess); 
    137143      } 
    138144      my $checkstat = $@; 
     
    146152        $results->{state} = 'BAD'; 
    147153        $results->{message} = "Bad module or problem running handler code."; 
     154        if ($checkstat eq "alarm\n") { 
     155          $results->{message} = "Check timeout"; 
     156        } 
    148157      } else { 
    149158        $results->{state} = $check_rv; 
  • resmon.conf.sample

    r9e46345 rd75bc41  
    22PORT 81; 
    33STATUSFILE /var/run/resmon-status.txt; 
     4TIMEOUT 10; 
    45 
    56# Resmon health check. Shows the hostname, svn revision, and any problems with