Changeset 8241 for lang/perl/App-MadEye
- Timestamp:
- 03/21/08 13:01:33 (9 months ago)
- Location:
- lang/perl/App-MadEye/trunk/lib/App/MadEye
- Files:
-
- 2 modified
-
Plugin/Worker/Simple.pm (modified) (2 diffs)
-
Util.pm (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
lang/perl/App-MadEye/trunk/lib/App/MadEye/Plugin/Worker/Simple.pm
r8016 r8241 12 12 13 13 my $timeout = $self->config->{config}->{task_timeout} or die "missing task_timeout"; 14 timeout $timeout, "watching $args->{target} $args->{plugin}", sub { 14 15 my $error = timeout $timeout, "watching $args->{target} $args->{plugin}", sub { 15 16 if ( my $message = $args->{plugin}->is_dead( $args->{target} ) ) { 16 17 $context->add_result( … … 21 22 } 22 23 }; 24 25 if ($error) { 26 $context->add_result( 27 plugin => $args->{plugin}, 28 target => $args->{target}, 29 message => $error, 30 ); 31 } 23 32 24 33 $context->log( debug => "finished $args->{target} by $args->{plugin}" ); -
lang/perl/App-MadEye/trunk/lib/App/MadEye/Util.pm
r8234 r8241 4 4 use base qw/Exporter/; 5 5 6 our @EXPORT = qw/timeout get_schema_from_pod snmp_session/;6 our @EXPORT = qw/timeout get_schema_from_pod context snmp_session/; 7 7 8 8 use Sys::Syslog qw/:DEFAULT/; … … 13 13 use Net::SNMP; 14 14 15 sub context () { App::MadEye->context } 16 15 17 sub timeout($$&) { ## no critic. 16 18 my ( $secs, $msg, $code ) = @_; 17 App::MadEye->context->log(debug => "run timer: '$msg', $secs");; 19 20 context->log(debug => "run timer: '$msg', $secs");; 21 18 22 my $last_alarm = 0; 23 my $err; 19 24 eval { 20 25 local $SIG{ALRM} = sub { die "Time out error: $msg" }; … … 23 28 my $start_time = gettimeofday(); 24 29 $code->(); 25 App::MadEye->context->log('debug' => "stopwatch: " . (gettimeofday() - $start_time));30 context->log('debug' => "stopwatch: " . (gettimeofday() - $start_time)); 26 31 }; 27 32 if ($@) { 28 my$err = $@;29 App::MadEye->context->log('error' => $err); 30 warn $err;33 $err = $@; 34 35 context->log('error' => $err); 31 36 } 32 37 alarm $last_alarm; # restore 38 39 return $err; 33 40 } 34 41
![(please configure the [header_logo] section in trac.ini)](/share/chrome/site/your_project_logo.png)