Page 1 of 1

zmfilter disk space BUG discovered - providing fix

Posted: Wed Nov 02, 2005 5:07 am
by zherebet
Gents,

I have a box sitting with the events directory on a completly separate partition. The PurgeWhenFull option was NOT working for some god awful reason - so I investigated.

Turns out that the code that checks dis percentage doesn't check it on the events folder (as it should - see df in web output), it checks it on the zm server directory.

Quick fix:
The code for checking disk percentage (zmfilter.pl:307):

Code: Select all

sub getDiskPercent
{
        my $command = "df .";
        my $df = qx( $command );
        my $space = -1;
        if ( $df =~ /\s(\d+)%/ms )
        {
                $space = $1;
        }
        return( $space );
}
Line 309 should read:

Code: Select all

my $command = "df " . ZM_DIR_EVENTS;

Posted: Wed Nov 02, 2005 5:11 am
by zherebet
p.s. I find the zmfilter system quite sexy.

Posted: Wed Nov 02, 2005 10:14 am
by cordel
Thanks zherebet for the report and fix. Awsome and will look into it.

Regards,
Cordel

Posted: Wed Nov 02, 2005 11:32 am
by lazyleopard
Doesn't zmfilter always run with the events directory as its current directory? Or perhaps a better question is what are the circumstances that cause zmfilter to run with a directory other than the events directory as its current directory?

Posted: Wed Nov 02, 2005 5:29 pm
by zoneminder
zmfilter.pl should be in the events directory when it checks the space on the current disk so it should work as advertised. However making the check explicit would certainly not hurt so I will probably do that as well.

Phil

Posted: Wed Nov 02, 2005 5:39 pm
by zherebet
The check needs to be explicit for the following scenario:

Primary hard drive contains OS + ZM files
Secondary hard drive contains just the events dir, in case of HD failure on the events HD, the system doesn't go down, and vice versa. Therefore if zmfilter.pl doesn't check for space on the second hard drive (or partition slice), then the system will not see that drive fill up.

Cheers,

Ilya

Posted: Thu Nov 03, 2005 1:43 pm
by lazyleopard
zherebet wrote:Primary hard drive contains OS + ZM files
Secondary hard drive contains just the events dir
That's exactly how my system's set up, and I've not had zmfilter.pl mis-behave on the capacity check. I presume the problems only show themselves if the events file system mis-behaves or vanishes.

Posted: Thu Nov 03, 2005 8:16 pm
by cordel
I have events directroy under my /var partition and everything is reporting correctly. Although I haven't tried to setup an events partition.
Regards,
Cordel

Re: zmfilter disk space BUG discovered - providing fix

Posted: Wed Dec 28, 2005 2:29 pm
by subliminal_boy_9
I can duplicate this on my box.

/var/www/localhost/htdocs/events --> is a symlink to /mnt/data/events
/mnt/data = /dev/sdb1, a raid 10 array running on 3Ware controller

OS (root) is on /dev/sda3
OS (boot) is on /dev/sda1
swap is on /dev/sda2

Older versions of ZM dealt with this just fine. The newer PurgeWhenFull filter does not.
zherebet wrote:Gents,

I have a box sitting with the events directory on a completly separate partition. The PurgeWhenFull option was NOT working for some god awful reason - so I investigated.

Turns out that the code that checks dis percentage doesn't check it on the events folder (as it should - see df in web output), it checks it on the zm server directory.

Quick fix:
The code for checking disk percentage (zmfilter.pl:307):

Code: Select all

sub getDiskPercent
{
        my $command = "df .";
        my $df = qx( $command );
        my $space = -1;
        if ( $df =~ /\s(\d+)%/ms )
        {
                $space = $1;
        }
        return( $space );
}
Line 309 should read:

Code: Select all

my $command = "df " . ZM_DIR_EVENTS;

Re: zmfilter disk space BUG discovered - providing fix

Posted: Wed Dec 28, 2005 4:33 pm
by subliminal_boy_9
In addition, I can tell zm that the events dir lives on /mnt/data/events, and still come away with a full disk. Looking into it further now, I'll post what I find.
subliminal_boy_9 wrote:I can duplicate this on my box.

/var/www/localhost/htdocs/events --> is a symlink to /mnt/data/events
/mnt/data = /dev/sdb1, a raid 10 array running on 3Ware controller

OS (root) is on /dev/sda3
OS (boot) is on /dev/sda1
swap is on /dev/sda2

Older versions of ZM dealt with this just fine. The newer PurgeWhenFull filter does not.
zherebet wrote:Gents,

I have a box sitting with the events directory on a completly separate partition. The PurgeWhenFull option was NOT working for some god awful reason - so I investigated.

Turns out that the code that checks dis percentage doesn't check it on the events folder (as it should - see df in web output), it checks it on the zm server directory.

Quick fix:
The code for checking disk percentage (zmfilter.pl:307):

Code: Select all

sub getDiskPercent
{
        my $command = "df .";
        my $df = qx( $command );
        my $space = -1;
        if ( $df =~ /\s(\d+)%/ms )
        {
                $space = $1;
        }
        return( $space );
}
Line 309 should read:

Code: Select all

my $command = "df " . ZM_DIR_EVENTS;

Posted: Wed Dec 28, 2005 5:53 pm
by cordel
All this changes in 1.22 Most likely as events will be handled differently.
Regards,
Corey

Posted: Fri Dec 30, 2005 8:14 pm
by zoneminder
This part hasn't really changed in 1.22.0 and it works fine for here so I'm unsure why it shouldn't work for everyone. The zmfilter scripts cd's to the events directory and then does a 'df .' to get the current device. Unless the events directory is on one partition and the individual camera dires are simlinked elsewhere this should work.

Very odd :?

Phil