make aud_print add a newline if printing. Tidy up Event Summary updating, using zmDbDo.
This commit is contained in:
parent
1891537e91
commit
152efd0987
|
@ -830,7 +830,7 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
|
|
||||||
# Now delete any old image files
|
# Now delete any old image files
|
||||||
if ( my @old_files = grep { -M > $max_image_age } <$image_path/*.{jpg,gif,wbmp}> ) {
|
if ( my @old_files = grep { -M > $max_image_age } <$image_path/*.{jpg,gif,wbmp}> ) {
|
||||||
aud_print('Deleting '.int(@old_files)." old images\n");
|
aud_print('Deleting '.int(@old_files).' old images');
|
||||||
my $untainted_old_files = join( ';', @old_files );
|
my $untainted_old_files = join( ';', @old_files );
|
||||||
( $untainted_old_files ) = ( $untainted_old_files =~ /^(.*)$/ );
|
( $untainted_old_files ) = ( $untainted_old_files =~ /^(.*)$/ );
|
||||||
unlink( split( /;/, $untainted_old_files ) );
|
unlink( split( /;/, $untainted_old_files ) );
|
||||||
|
@ -858,7 +858,7 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
$res = $deleteLogByRowsSth->execute( $logRows - $Config{ZM_LOG_DATABASE_LIMIT} )
|
$res = $deleteLogByRowsSth->execute( $logRows - $Config{ZM_LOG_DATABASE_LIMIT} )
|
||||||
or Fatal("Can't execute: ".$deleteLogByRowsSth->errstr());
|
or Fatal("Can't execute: ".$deleteLogByRowsSth->errstr());
|
||||||
if ( $deleteLogByRowsSth->rows() ) {
|
if ( $deleteLogByRowsSth->rows() ) {
|
||||||
aud_print('Deleted '.$deleteLogByRowsSth->rows() ." log table entries by count\n");
|
aud_print('Deleted '.$deleteLogByRowsSth->rows().' log table entries by count');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -878,7 +878,7 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
$res = $deleteLogByTimeSth->execute()
|
$res = $deleteLogByTimeSth->execute()
|
||||||
or Fatal("Can't execute: ".$deleteLogByTimeSth->errstr());
|
or Fatal("Can't execute: ".$deleteLogByTimeSth->errstr());
|
||||||
$deleted_rows = $deleteLogByTimeSth->rows();
|
$deleted_rows = $deleteLogByTimeSth->rows();
|
||||||
aud_print("Deleted $deleted_rows log table entries by time\n");
|
aud_print("Deleted $deleted_rows log table entries by time");
|
||||||
} while ( $deleted_rows );
|
} while ( $deleted_rows );
|
||||||
}
|
}
|
||||||
} # end if ZM_LOG_DATABASE_LIMIT
|
} # end if ZM_LOG_DATABASE_LIMIT
|
||||||
|
@ -892,9 +892,8 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
`ArchivedEventDiskSpace`=(SELECT SUM(`DiskSpace`) FROM `Events` WHERE `MonitorId`=`Event_Summaries`.`MonitorId` AND `Archived`=1 AND `DiskSpace` IS NOT NULL)
|
`ArchivedEventDiskSpace`=(SELECT SUM(`DiskSpace`) FROM `Events` WHERE `MonitorId`=`Event_Summaries`.`MonitorId` AND `Archived`=1 AND `DiskSpace` IS NOT NULL)
|
||||||
';
|
';
|
||||||
|
|
||||||
my $eventcounts_sth = $dbh->prepare_cached( $eventcounts_sql );
|
ZoneMinder::Database::zmDbDo($eventcounts_sql);
|
||||||
$eventcounts_sth->execute();
|
aud_print('Finished updating TotalEvents, ArchivedEvents');
|
||||||
$eventcounts_sth->finish();
|
|
||||||
|
|
||||||
my $eventcounts_hour_sql = '
|
my $eventcounts_hour_sql = '
|
||||||
UPDATE `Event_Summaries` INNER JOIN (
|
UPDATE `Event_Summaries` INNER JOIN (
|
||||||
|
@ -904,6 +903,8 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
`Event_Summaries`.`HourEvents` = `E`.`HourEvents`,
|
`Event_Summaries`.`HourEvents` = `E`.`HourEvents`,
|
||||||
`Event_Summaries`.`HourEventDiskSpace` = `E`.`HourEventDiskSpace`
|
`Event_Summaries`.`HourEventDiskSpace` = `E`.`HourEventDiskSpace`
|
||||||
';
|
';
|
||||||
|
ZoneMinder::Database::zmDbDo($eventcounts_hour_sql);
|
||||||
|
aud_print("Finished updating HourEvents");
|
||||||
|
|
||||||
|
|
||||||
my $eventcounts_day_sql = '
|
my $eventcounts_day_sql = '
|
||||||
|
@ -914,6 +915,8 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
`Event_Summaries`.`DayEvents` = `E`.`DayEvents`,
|
`Event_Summaries`.`DayEvents` = `E`.`DayEvents`,
|
||||||
`Event_Summaries`.`DayEventDiskSpace` = `E`.`DayEventDiskSpace`
|
`Event_Summaries`.`DayEventDiskSpace` = `E`.`DayEventDiskSpace`
|
||||||
';
|
';
|
||||||
|
ZoneMinder::Database::zmDbDo($eventcounts_day_sql);
|
||||||
|
aud_print("Finished updating DayEvents");
|
||||||
|
|
||||||
my $eventcounts_week_sql = '
|
my $eventcounts_week_sql = '
|
||||||
UPDATE `Event_Summaries` INNER JOIN (
|
UPDATE `Event_Summaries` INNER JOIN (
|
||||||
|
@ -923,6 +926,8 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
`Event_Summaries`.`WeekEvents` = `E`.`WeekEvents`,
|
`Event_Summaries`.`WeekEvents` = `E`.`WeekEvents`,
|
||||||
`Event_Summaries`.`WeekEventDiskSpace` = `E`.`WeekEventDiskSpace`
|
`Event_Summaries`.`WeekEventDiskSpace` = `E`.`WeekEventDiskSpace`
|
||||||
';
|
';
|
||||||
|
ZoneMinder::Database::zmDbDo($eventcounts_week_sql);
|
||||||
|
aud_print("Finished updating WeekEvents");
|
||||||
|
|
||||||
my $eventcounts_month_sql = '
|
my $eventcounts_month_sql = '
|
||||||
UPDATE `Event_Summaries` INNER JOIN (
|
UPDATE `Event_Summaries` INNER JOIN (
|
||||||
|
@ -932,17 +937,11 @@ FROM `Frames` WHERE `EventId`=?';
|
||||||
`Event_Summaries`.`MonthEvents` = `E`.`MonthEvents`,
|
`Event_Summaries`.`MonthEvents` = `E`.`MonthEvents`,
|
||||||
`Event_Summaries`.`MonthEventDiskSpace` = `E`.`MonthEventDiskSpace`
|
`Event_Summaries`.`MonthEventDiskSpace` = `E`.`MonthEventDiskSpace`
|
||||||
';
|
';
|
||||||
my $eventcounts_hour_sth = $dbh->prepare_cached($eventcounts_hour_sql);
|
ZoneMinder::Database::zmDbDo($eventcounts_month_sql);
|
||||||
my $eventcounts_day_sth = $dbh->prepare_cached($eventcounts_day_sql);
|
aud_print("Finished updating MonthEvents");
|
||||||
my $eventcounts_week_sth = $dbh->prepare_cached($eventcounts_week_sql);
|
|
||||||
my $eventcounts_month_sth = $dbh->prepare_cached($eventcounts_month_sql);
|
|
||||||
$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_week_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
|
|
||||||
$eventcounts_month_sth->execute() or Error("Can't execute: ".$eventcounts_sth->errstr());
|
|
||||||
|
|
||||||
my $storage_diskspace_sth = $dbh->prepare_cached('UPDATE Storage SET DiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=Storage.Id)');
|
ZoneMinder::Database::zmDbDo('UPDATE Storage SET DiskSpace=(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=Storage.Id)');
|
||||||
$storage_diskspace_sth->execute() or Error("Can't execute: ".$storage_diskspace_sth->errstr());
|
aud_print("Finished updating Storage DiskSpace");
|
||||||
|
|
||||||
sleep($Config{ZM_AUDIT_CHECK_INTERVAL}) if $continuous;
|
sleep($Config{ZM_AUDIT_CHECK_INTERVAL}) if $continuous;
|
||||||
};
|
};
|
||||||
|
@ -953,6 +952,7 @@ sub aud_print {
|
||||||
my $string = shift;
|
my $string = shift;
|
||||||
if ( !$continuous ) {
|
if ( !$continuous ) {
|
||||||
print($string);
|
print($string);
|
||||||
|
print "\n";
|
||||||
} else {
|
} else {
|
||||||
Info($string);
|
Info($string);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue