From bf6312a8ecb0162e9d00579af0b3f23ad41fc3aa Mon Sep 17 00:00:00 2001 From: Isaac Connor Date: Tue, 21 Nov 2017 23:56:05 -0500 Subject: [PATCH] put back zma --- scripts/zmwatch.pl.in | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/scripts/zmwatch.pl.in b/scripts/zmwatch.pl.in index 393d8fe90..c1a2d78e7 100644 --- a/scripts/zmwatch.pl.in +++ b/scripts/zmwatch.pl.in @@ -55,6 +55,7 @@ use constant START_DELAY => 30; # To give everything else time to start @EXTRA_PERL_LIB@ use ZoneMinder; +use ZoneMinder::Storage; use POSIX; use DBI; use autouse 'Data::Dumper'=>qw(Dumper); @@ -175,6 +176,14 @@ while( 1 ) { # Prevent open handles building up if we have connect to shared memory zmMemInvalidate( $monitor ); # Close our file handle to the zmc process we are about to end } # end foreach monitor + my $diskspace_sql = 'UPDATE Storage SET DiskSpace =(SELECT SUM(DiskSpace) FROM Events WHERE StorageId=? AND DiskSpace IS NOT NULL)'; + my $diskspace_sth = $dbh->prepare_cached( $sql ) + or Fatal( "Can't prepare '$sql': ".$dbh->errstr() ); + foreach my $Storage ( ZoneMinder::Storage->find() ) { + Error("Updating disk space for $$Storage{Name}"); + $diskspace_sth->execute( $$Storage{Id} ) or Error( "Can't execute: ".$diskspace_sth->errstr() ); + } + $diskspace_sth->finish(); sleep( $Config{ZM_WATCH_CHECK_INTERVAL} ); } # end while (1)