spacing and quotes, but the main change is using aud_print instead of Info

This commit is contained in:
Isaac Connor 2019-05-06 10:04:53 -04:00
parent 4ecf41f2b4
commit f0e5a435cf
1 changed files with 32 additions and 32 deletions

View File

@ -488,21 +488,21 @@ MAIN: while( $loop ) {
my $monitor_links; my $monitor_links;
foreach my $link ( glob('*') ) { foreach my $link ( glob('*') ) {
next if ( !-l $link ); next if !-l $link;
next if ( -e $link ); next if -e $link;
aud_print( "Filesystem monitor link '$link' does not point to valid monitor directory" ); aud_print("Filesystem monitor link '$link' does not point to valid monitor directory");
if ( confirm() ) { if ( confirm() ) {
( $link ) = ( $link =~ /^(.*)$/ ); # De-taint ( $link ) = ( $link =~ /^(.*)$/ ); # De-taint
my $command = qq`rm "$link"`; my $command = qq`rm "$link"`;
executeShellCommand( $command ); executeShellCommand($command);
$cleaned = 1; $cleaned = 1;
} }
} } # end foreach monitor link
} # end foreach Storage Area } # end foreach Storage Area
if ( $cleaned ) { if ( $cleaned ) {
Debug("Events were deleted, starting again."); Debug('Events were deleted, starting again.');
redo MAIN; redo MAIN;
} }
@ -559,8 +559,8 @@ EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) {
Warning("Event $$Event{Id} is Archived. Taking no further action on it."); Warning("Event $$Event{Id} is Archived. Taking no further action on it.");
next; next;
} }
if ( ! $Event->StartTime() ) { if ( !$Event->StartTime() ) {
Info("Event $$Event{Id} has no start time."); aud_print("Event $$Event{Id} has no start time.");
if ( confirm() ) { if ( confirm() ) {
$Event->delete(); $Event->delete();
$cleaned = 1; $cleaned = 1;
@ -569,7 +569,7 @@ EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) {
} }
if ( ! $Event->EndTime() ) { if ( ! $Event->EndTime() ) {
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
Info("Event $$Event{Id} has no end time and is $age seconds old. deleting it."); aud_print("Event $$Event{Id} has no end time and is $age seconds old. Deleting it.");
if ( confirm() ) { if ( confirm() ) {
$Event->delete(); $Event->delete();
$cleaned = 1; $cleaned = 1;
@ -578,7 +578,7 @@ EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) {
} }
} }
if ( $Event->check_for_in_filesystem() ) { if ( $Event->check_for_in_filesystem() ) {
Debug("Database event $$Event{Id} apparently exists at " . $Event->Path() ); Debug("Database event $$Event{Id} apparently exists at " . $Event->Path());
} else { } else {
if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) { if ( $age > $Config{ZM_AUDIT_MIN_AGE} ) {
aud_print("Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting'); aud_print("Database event '$db_monitor/$db_event' does not exist at " . $Event->Path().' in filesystem, deleting');
@ -587,14 +587,14 @@ EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) {
$cleaned = 1; $cleaned = 1;
} }
} else { } else {
aud_print( "Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.\n" ); aud_print("Database event '".$Event->Path()." monitor:$db_monitor event:$db_event' does not exist in filesystem but too young to delete age: $age > MIN $Config{ZM_AUDIT_MIN_AGE}.");
} }
} # end if exists in filesystem } # end if exists in filesystem
} else { } else {
Debug("Found fs event for id $db_event, $age seconds old at " . $$fs_events{$db_event}->Path()); Debug("Found fs event for id $db_event, $age seconds old at " . $$fs_events{$db_event}->Path());
my $Event = ZoneMinder::Event->find_one( Id=>$db_event ); my $Event = ZoneMinder::Event->find_one( Id=>$db_event );
if ( $Event and ! $Event->check_for_in_filesystem() ) { if ( $Event and ! $Event->check_for_in_filesystem() ) {
Warning("Not found at " . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path() ); Warning('Not found at ' . $Event->Path() . ' was found at ' . $$fs_events{$db_event}->Path());
Warning($Event->to_string()); Warning($Event->to_string());
Warning($$fs_events{$db_event}->to_string()); Warning($$fs_events{$db_event}->to_string());
$$Event{Scheme} = '' if ! defined $$Event{Scheme}; $$Event{Scheme} = '' if ! defined $$Event{Scheme};
@ -622,7 +622,7 @@ EVENT: while ( my ( $db_event, $age ) = each( %$db_events ) ) {
} # foreach db_event } # foreach db_event
} # end foreach db_monitor } # end foreach db_monitor
if ( $cleaned ) { if ( $cleaned ) {
Debug("Have done some cleaning, restarting."); Debug('Have done some cleaning, restarting.');
redo MAIN; redo MAIN;
} }
@ -904,25 +904,25 @@ FROM Frames WHERE EventId=?';
Monitors.MonthEvents = E.MonthEvents, Monitors.MonthEvents = E.MonthEvents,
Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace Monitors.MonthEventDiskSpace = E.MonthEventDiskSpace
`; `;
my $eventcounts_hour_sth = $dbh->prepare_cached( $eventcounts_hour_sql ); my $eventcounts_hour_sth = $dbh->prepare_cached($eventcounts_hour_sql);
my $eventcounts_day_sth = $dbh->prepare_cached( $eventcounts_day_sql ); my $eventcounts_day_sth = $dbh->prepare_cached($eventcounts_day_sql);
my $eventcounts_week_sth = $dbh->prepare_cached( $eventcounts_week_sql ); my $eventcounts_week_sth = $dbh->prepare_cached($eventcounts_week_sql);
my $eventcounts_month_sth = $dbh->prepare_cached( $eventcounts_month_sql ); my $eventcounts_month_sth = $dbh->prepare_cached($eventcounts_month_sql);
$eventcounts_hour_sth->execute( ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); $eventcounts_hour_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
$eventcounts_day_sth->execute( ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); $eventcounts_day_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
$eventcounts_week_sth->execute( ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); $eventcounts_week_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
$eventcounts_month_sth->execute( ) or Error( "Can't execute: ".$eventcounts_sth->errstr() ); $eventcounts_month_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
sleep( $Config{ZM_AUDIT_CHECK_INTERVAL} ) if $continuous; sleep($Config{ZM_AUDIT_CHECK_INTERVAL}) if $continuous;
}; };
Term(); Term();
sub aud_print { sub aud_print {
my $string = shift; my $string = shift;
if ( ! $continuous ) { if ( !$continuous ) {
print( $string ); print($string);
} else { } else {
Info( $string ); Info($string);
} }
} }
@ -932,13 +932,13 @@ sub confirm {
my $yesno = 0; my $yesno = 0;
if ( $report ) { if ( $report ) {
print( "\n" ); print("\n");
} elsif ( $interactive ) { } elsif ( $interactive ) {
print( ", $prompt Y/n/q: " ); print(", $prompt Y/n/q: ");
my $char = <>; my $char = <>;
chomp( $char ); chomp($char);
if ( $char eq 'q' ) { if ( $char eq 'q' ) {
exit( 0 ); exit(0);
} }
if ( !$char ) { if ( !$char ) {
$char = 'y'; $char = 'y';
@ -946,13 +946,13 @@ sub confirm {
$yesno = ( $char =~ /[yY]/ ); $yesno = ( $char =~ /[yY]/ );
} else { } else {
if ( !$continuous ) { if ( !$continuous ) {
print( ", $action\n" ); print(", $action\n");
} else { } else {
Info( $action ); Info($action);
} }
$yesno = 1; $yesno = 1;
} }
return( $yesno ); return $yesno;
} }
sub deleteSwapImage { sub deleteSwapImage {