zmfilter disk space BUG discovered - providing fix

Support and queries relating to all previous versions of ZoneMinder
Locked
zherebet
Posts: 31
Joined: Sun Jul 31, 2005 7:38 pm

zmfilter disk space BUG discovered - providing fix

Post 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;
Regards,

Ilya Zherebetskiy
zherebet
Posts: 31
Joined: Sun Jul 31, 2005 7:38 pm

Post by zherebet »

p.s. I find the zmfilter system quite sexy.
Regards,

Ilya Zherebetskiy
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

Thanks zherebet for the report and fix. Awsome and will look into it.

Regards,
Cordel
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post 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?
Rick Hewett
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post 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
zherebet
Posts: 31
Joined: Sun Jul 31, 2005 7:38 pm

Post 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
Regards,

Ilya Zherebetskiy
User avatar
lazyleopard
Posts: 403
Joined: Tue Mar 02, 2004 6:12 pm
Location: Gloucestershire, UK

Post 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.
Rick Hewett
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post 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
subliminal_boy_9
Posts: 14
Joined: Wed Nov 10, 2004 6:32 pm

Re: zmfilter disk space BUG discovered - providing fix

Post 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;
subliminal_boy_9
Posts: 14
Joined: Wed Nov 10, 2004 6:32 pm

Re: zmfilter disk space BUG discovered - providing fix

Post 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;
User avatar
cordel
Posts: 5210
Joined: Fri Mar 05, 2004 4:47 pm
Location: /USA/Washington/Seattle

Post by cordel »

All this changes in 1.22 Most likely as events will be handled differently.
Regards,
Corey
User avatar
zoneminder
Site Admin
Posts: 5215
Joined: Wed Jul 09, 2003 2:07 pm
Location: Bristol, UK
Contact:

Post 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
Locked