Merge pull request #892 from ZoneMinder/zmwatch_cleanup3
improve debugging for analysis check and restart if can't read shared data
This commit is contained in:
commit
951f13c82a
|
@ -133,14 +133,19 @@ while( 1 )
|
||||||
}
|
}
|
||||||
elsif ( $monitor->{Function} ne 'Monitor' )
|
elsif ( $monitor->{Function} ne 'Monitor' )
|
||||||
{
|
{
|
||||||
if ( zmMemVerify( $monitor )
|
# Now check analysis daemon
|
||||||
&& zmMemRead( $monitor, "shared_data:valid" )
|
$restart = 0;
|
||||||
)
|
|
||||||
{
|
|
||||||
# Check we have got an image recently
|
# Check we have got an image recently
|
||||||
my $image_time = zmGetLastReadTime( $monitor );
|
my $image_time = zmGetLastReadTime( $monitor );
|
||||||
next if ( !defined($image_time) ); # Can't read from shared data
|
if ( !defined($image_time) ) {
|
||||||
next if ( !$image_time ); # We can't get the last capture time so can't be sure it's died.
|
# Can't read from shared data
|
||||||
|
$restart = 1;
|
||||||
|
Error( "Error reading shared data for $$monitor{id} $$monitor{Name}\n");
|
||||||
|
} elsif ( !$image_time ) {
|
||||||
|
# We can't get the last capture time so can't be sure it's died.
|
||||||
|
$restart = 1;
|
||||||
|
Error( "Error getting last capture time for $$monitor{id} $$monitor{Name}\n");
|
||||||
|
} else {
|
||||||
|
|
||||||
my $max_image_delay = ( $monitor->{MaxFPS}
|
my $max_image_delay = ( $monitor->{MaxFPS}
|
||||||
&&($monitor->{MaxFPS}>0)
|
&&($monitor->{MaxFPS}>0)
|
||||||
|
@ -152,18 +157,24 @@ while( 1 )
|
||||||
Debug( "Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay\n" );
|
Debug( "Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay\n" );
|
||||||
if ( $image_delay > $max_image_delay )
|
if ( $image_delay > $max_image_delay )
|
||||||
{
|
{
|
||||||
Info( "Restarting analysis daemon for "
|
Info( "Analysis daemon for $$monitor{id} $$monitor{Name} needs restarting,"
|
||||||
.$monitor->{Name}.", time since last analysis $image_delay seconds ($now-$image_time)\n"
|
." time since last analysis $image_delay seconds ($now-$image_time)\n"
|
||||||
);
|
);
|
||||||
|
$restart = 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( $restart )
|
||||||
|
{
|
||||||
|
Info( "Restarting analysis daemon for $$monitor{id} $$monitor{Name}\n");
|
||||||
my $command = "zmdc.pl restart zma -m ".$monitor->{Id};
|
my $command = "zmdc.pl restart zma -m ".$monitor->{Id};
|
||||||
runCommand( $command );
|
runCommand( $command );
|
||||||
}
|
} # end if restart
|
||||||
}
|
} # end if check analysis daemon
|
||||||
}
|
|
||||||
}
|
|
||||||
# Prevent open handles building up if we have connect to shared memory
|
# Prevent open handles building up if we have connect to shared memory
|
||||||
zmMemInvalidate( $monitor );
|
zmMemInvalidate( $monitor );
|
||||||
|
} # end foreach monitor
|
||||||
sleep( $Config{ZM_WATCH_CHECK_INTERVAL} );
|
sleep( $Config{ZM_WATCH_CHECK_INTERVAL} );
|
||||||
}
|
} # end while (1)
|
||||||
Info( "Watchdog exiting\n" );
|
Info( "Watchdog exiting\n" );
|
||||||
exit();
|
exit();
|
||||||
|
|
Loading…
Reference in New Issue