Script to delete events when 32000 file system limit.
Script to delete events when 32000 file system limit.
Hi,
I had help a few weeks ago as our cameras would stop recording when events reached 32,000. This turned out to be a filesystem limit.
I have set the purge when full when disk >90%
but I need some sort of filter or script to delete say the oldest 1000 events on a camera when events >31000. as some cameras would reach 32,000 a long time before the 800gb drive filled up.
What is the best way.?
If I did a cron job to run a script every few hours what sort of line would I need.
?
some way to detect if events >31000 on camera 1
delete * from Events where Id=1 order by datetime limit 1000;
?
how often does the audit run as would this clean the frames,event folders and jpg files automaticaly later?.
Thanks
Nick
I had help a few weeks ago as our cameras would stop recording when events reached 32,000. This turned out to be a filesystem limit.
I have set the purge when full when disk >90%
but I need some sort of filter or script to delete say the oldest 1000 events on a camera when events >31000. as some cameras would reach 32,000 a long time before the 800gb drive filled up.
What is the best way.?
If I did a cron job to run a script every few hours what sort of line would I need.
?
some way to detect if events >31000 on camera 1
delete * from Events where Id=1 order by datetime limit 1000;
?
how often does the audit run as would this clean the frames,event folders and jpg files automaticaly later?.
Thanks
Nick
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
im sure you can do that but i dont know how, how about you delete footage after 31 days?
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
christ
ok another way as i dont use modect mode change to mocord mode and have a filter to remove all event with a max score of 0
Or wait till you get your solution
ok another way as i dont use modect mode change to mocord mode and have a filter to remove all event with a max score of 0
Or wait till you get your solution
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
What file system are you using on the partition you're storing your events on? Reiserfs is what I use, it's fast, and I've had no problems storing events for as long as there's space for - I've got systems with 1TB and have just finished building two more with 1.6TB each. I'd bet you're using an older file system (ext2 possibly?) and that's where the limit is being imposed.
If you type mount with no options, you can see what file system type is used on each partition in your system.
If you type mount with no options, you can see what file system type is used on each partition in your system.
Hi,
Heres something you can play with.. Its a bit rough, as I just scrubbed it together when I saw your post.
Its a perl script which calls a shell script
You would have to run the script using absolute path names, but you can change it later if it works for you.
ok heres the perl script 1st;
This would run from the monitor ID directory, where all the event directories are;
#!/usr/bin/perl
use strict;
my @list;
my $file;
@list = (`/opt/zm/scripts/prt_list.scr`);
foreach $file ( @list ) {
chomp $file;
print "Deleting Event $file\n";
`/bin/rm -rf $file `;
print "Finished deleting event $file ! \n";
}
See how the @list calls another script from /opt/zm/scripts/prt_list.scr
in the prt_list.scr file is a simple 1 line written as follows
ls -lt | tail -2 | awk '{ printf $9 "\n" }'
Now all you have to do is change the tail -2 to tail -1000 to list only the oldest 1000 events. Also you may have to change the printf $9 to the correct column number which lists the directory event number. In my case it was the ninth column, counting from the left to right.
Heres something you can play with.. Its a bit rough, as I just scrubbed it together when I saw your post.
Its a perl script which calls a shell script
You would have to run the script using absolute path names, but you can change it later if it works for you.
ok heres the perl script 1st;
This would run from the monitor ID directory, where all the event directories are;
#!/usr/bin/perl
use strict;
my @list;
my $file;
@list = (`/opt/zm/scripts/prt_list.scr`);
foreach $file ( @list ) {
chomp $file;
print "Deleting Event $file\n";
`/bin/rm -rf $file `;
print "Finished deleting event $file ! \n";
}
See how the @list calls another script from /opt/zm/scripts/prt_list.scr
in the prt_list.scr file is a simple 1 line written as follows
ls -lt | tail -2 | awk '{ printf $9 "\n" }'
Now all you have to do is change the tail -2 to tail -1000 to list only the oldest 1000 events. Also you may have to change the printf $9 to the correct column number which lists the directory event number. In my case it was the ninth column, counting from the left to right.
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
good call
Matador you seem to be a bit of a demon at this scripting
great stuff
Matador you seem to be a bit of a demon at this scripting
great stuff
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
I don't believe it's possible to change it without a reinstall of the partition (backup data, umount partition, mkreiserfs on the partition, mount it, restore data), but I'm not certain of this at all. A linux expert may be able to tell you for certain. I did considerable research on the file systems before deciding on which to use and discovered that reiserfs really does win out for this application.nickcol wrote:The filesystem is ext3 and using lvm to span the / partition over
3 drives (128gb 400gb 400gb)
Is it possible to change it to Reiserfs without a total reinstall ?.
What I've done on my systems is have a smallish (80 gig) boot drive and then the extra HDs (4 x 400 gig) set up in a RAID-0 array so that they appear to be one drive mounted as /video, then serve the hypertext and cgi documents from there.
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
i use ext3 would reiserfs be better then as the var partition?
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Any one played with ReiserFS version 4 yet???
Last I heard it is stable these days, but I haven't tried myself.
I'm curious if anyone has had experiance with it at all.
IMHO, ReiserFS is much better than ext3. It's a transactional file system that runs much faster than ext3. Just my opinon though
Regards,
Cordel
Last I heard it is stable these days, but I haven't tried myself.
I'm curious if anyone has had experiance with it at all.
IMHO, ReiserFS is much better than ext3. It's a transactional file system that runs much faster than ext3. Just my opinon though
Regards,
Cordel
-
- Posts: 5111
- Joined: Wed Jun 08, 2005 8:07 pm
- Location: Midlands UK
looks like im converted then. Thanks all
James Wilson
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk
Disclaimer: The above is pure theory and may work on a good day with the wind behind it. etc etc.
http://www.securitywarehouse.co.uk