Alter log level of restart events based on Importance setting

This commit is contained in:
Isaac Connor 2022-01-05 16:49:20 -05:00
parent bfac696fb7
commit bc67493f91
1 changed files with 10 additions and 8 deletions

View File

@ -67,7 +67,7 @@ $ENV{PATH} = '/bin:/usr/bin:/usr/local/bin';
$ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL}; $ENV{SHELL} = '/bin/sh' if exists $ENV{SHELL};
delete @ENV{qw(IFS CDPATH ENV BASH_ENV)}; delete @ENV{qw(IFS CDPATH ENV BASH_ENV)};
logInit(); my $log = logInit();
logSetSignal(); logSetSignal();
my $zm_terminate = 0; my $zm_terminate = 0;
sub TermHandler { sub TermHandler {
@ -114,7 +114,7 @@ while (!$zm_terminate) {
# We can't get the last capture time so can't be sure it's died, it might just be starting up. # We can't get the last capture time so can't be sure it's died, it might just be starting up.
my $startup_time = zmGetStartupTime($monitor); my $startup_time = zmGetStartupTime($monitor);
if (($now - $startup_time) > $Config{ZM_WATCH_MAX_DELAY}) { if (($now - $startup_time) > $Config{ZM_WATCH_MAX_DELAY}) {
Warning( $log->logPrint(ZoneMinder::Logger::WARNING+$monitor->Importance(),
"Restarting capture daemon for $$monitor{Name}, no image since startup. ". "Restarting capture daemon for $$monitor{Name}, no image since startup. ".
"Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}" "Startup time was $startup_time - now $now > $Config{ZM_WATCH_MAX_DELAY}"
); );
@ -133,8 +133,9 @@ while (!$zm_terminate) {
my $image_delay = $now - $capture_time; my $image_delay = $now - $capture_time;
Debug("Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay"); Debug("Monitor $monitor->{Id} last captured $image_delay seconds ago, max is $max_image_delay");
if ($image_delay > $max_image_delay) { if ($image_delay > $max_image_delay) {
Warning('Restarting capture daemon for '.$monitor->{Name}. $log->logPrint(ZoneMinder::Logger::WARNING+$monitor->Importance(),
", time since last capture $image_delay seconds ($now-$capture_time)"); 'Restarting capture daemon for '.$monitor->{Name}.
", time since last capture $image_delay seconds ($now-$capture_time)");
$monitor->control('restart'); $monitor->control('restart');
next; next;
} }
@ -160,10 +161,11 @@ while (!$zm_terminate) {
my $image_delay = $now-$image_time; my $image_delay = $now-$image_time;
Debug("Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay"); Debug("Monitor $monitor->{Id} last analysed $image_delay seconds ago, max is $max_image_delay");
if ($image_delay > $max_image_delay) { if ($image_delay > $max_image_delay) {
Warning("Analysis daemon for $$monitor{Id} $$monitor{Name} needs restarting," $log->logPrint(ZoneMinder::Logger::WARNING+$monitor->Importance(),
." time since last analysis $image_delay seconds ($now-$image_time)"); "daemon for $$monitor{Id} $$monitor{Name} needs restarting,"
$monitor->control('restart'); ." time since last analysis $image_delay seconds ($now-$image_time)");
next; $monitor->control('restart');
next;
} }
} }