Compare commits

...

7 Commits

5 changed files with 89 additions and 78 deletions

View File

@ -11,18 +11,21 @@ How can I stop ZoneMinder filling up my disk?
--------------------------------------------- ---------------------------------------------
Recent versions of ZoneMinder come with a filter you can use for this purpose already included. Recent versions of ZoneMinder come with a filter you can use for this purpose already included.
The filter is called **PurgeWhenFull** and to find it, choose one of the event counts from the console page, for instance events in the last hour, for one of your monitors. **Note** that this filter is automatically enabled if you do a fresh install of ZoneMinder including creating a new database. If you already have an existing database and are upgrading ZoneMinder, it will retain the settings of the filter (which in earlier releases was disabled by default). So you may want to check if PurgeWhenFull is enabled and if not, enable it. The filter is called **PurgeWhenFull** and to find it, click on the word **Filters** in the header.
**Note** that this filter is automatically enabled if you do a fresh install of ZoneMinder including creating a new database. If you already have an existing database and are upgrading ZoneMinder, it will retain the settings of the filter (which in earlier releases was disabled by default). So you may want to check if PurgeWhenFull is enabled and if not, enable it.
To enable it, go to Web Console, click on any of your Events of any of your monitors. To enable it, go to Web Console, click on the word **Filters** in the UI header.
This will bring up an event listing and a filter window.
In the filter window there is a drop down select box labeled 'Use Filter', that lets your select a saved filter. Select 'PurgeWhenFull' and it will load that filter. In the filter window there is a drop down select box labeled 'Use Filter', that lets you select a saved filter. Select 'PurgeWhenFull' and it will load that filter.
Make any modifications you might want, such as the percentage full you want it to kick in, or how many events to delete at a time (it will repeat the filter as many times as needed to clear the space, but will only delete this many events each time to get there). Make any modifications you might want, such as the percentage full you want it to kick in, or how many events to delete at a time (it will repeat the filter as many times as needed to clear the space, but will only delete this many events each time to get there).
Then click on 'Save' which will bring up a new window. Make sure the 'Automatically delete' box is checked and press save to save your filter. This will then run in the background to keep your disk within those limits. Ensure that the Run filter in background checkbox is checked.
Ensure that the Delete all matches checkbox is checked.
After you've done that, you changes will automatically be loaded into zmfilter within a few minutes. Then click on 'Save'. The filter will immediately begin executing in the background to keep your disk within those limits.
Please note that that this filter will only affect the default storage location. If you have added other storage areas, you must create a PurgeWhenFull filter for each one, and specify the Storage Area as one of the parameters in the filter. You can duplicate the existing PurgeWhenFull filter by using Save As instead of Save.
Check the ``zmfilter.log`` file to make sure it is running as sometimes missing perl modules mean that it never runs but people don't always realize. Check the ``zmfilter.log`` file to make sure it is running as sometimes missing perl modules mean that it never runs but people don't always realize.
@ -46,7 +49,7 @@ Normally an event created as the result of an alarm consists of entries in one o
ZM_RUN_AUDIT: ZM_RUN_AUDIT:
The zmaudit daemon exists to check that the saved information in the database and on the file system match and are consistent with each other. If an error occurs or if you are using 'fast deletes' it may be that database records are deleted but files remain. In this case, and similar, zmaudit will remove redundant information to synchronize the two data stores. This option controls whether zmaudit is run in the background and performs these checks and fixes continuously. This is recommended for most systems however if you have a very large number of events the process of scanning the database and file system may take a long time and impact performance. In this case you may prefer to not have zmaudit running unconditionally and schedule occasional checks at other, more convenient, times. The zmaudit daemon exists to check that the saved information in the database and on the file system match and are consistent with each other. If an error occurs or if you are using 'fast deletes' it may be that database records are deleted but files remain. In this case, and similar, zmaudit will remove redundant information to synchronize the two data stores. This option controls whether zmaudit is run in the background and performs these checks and fixes continuously. This is not recommended for most systems, as zmaudit.pl is very resource intensive.
ZM_AUDIT_CHECK_INTERVAL: ZM_AUDIT_CHECK_INTERVAL:
@ -184,14 +187,27 @@ Once I did this, images started to stream for me.
Lastly, please look for errors created by the zmc processes. If zmc isn't running, then zms will not be able to get an image from it and will exit. Lastly, please look for errors created by the zmc processes. If zmc isn't running, then zms will not be able to get an image from it and will exit.
I have several monitors configured but when I load the Montage view in FireFox why can I only see two? or, Why don't all my cameras display when I use the Montage view in FireFox? I have several monitors configured but when I load the Montage view why can I only see two? or, Why don't all my cameras display when I use the Montage view?
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- --------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
By default FireFox only supports a small number of simultaneous connections. Using the montage view usually requires one persistent connection for each camera plus intermittent connections for other information such as statuses. By default most browsers only support a small number of simultaneous connections to any given server. Using the montage view usually requires one persistent connection for each camera plus intermittent connections for other information such as statuses.
You will need to increase the number of allowed connections to use the montage view with more than a small number of cameras. Certain FireFox extensions such as FasterFox may also help to achieve the same result. In firefox you can increase the limit, but other browsers are not configurable in this way.
To resolve this situation, follow the instructions below: A solution for all browsers is something we call multi-port. We reconfigure apache to operate on ports other than the default of 80(http) or 443(https). You need to pick a range, let's say 30000 to 30010 in order to support 10 cameras. We add lines to your zoneminder apache config file as follows:
Listen 30000
Listen 30001
Listen 30002
Listen 30003
etc
Listen 30010
If you are using virtualhosts, you will have to add these to the VirtualHost directive as well.
Then in ZoneMinder config, Go Options -> Network and set MIN_STREAMING_PORT to 30000. Now when generating urls to stream images from ZoneMinder a port will be appended that is 30000 + MonitorId, so Monitor 1 will stream from 30001 and so on. This will allow Montage to stream from all monitors.
Alternatively if you are in fact using only Firefox, you can increase the limit as follows:
Enter ``about:config`` in the address bar Enter ``about:config`` in the address bar

View File

@ -4,7 +4,7 @@ Filtering Events
Filters allow you to define complex conditions with associated actions in ZoneMinder. Examples could include: Filters allow you to define complex conditions with associated actions in ZoneMinder. Examples could include:
* Send an email each time a new event occurs for a specific monitor * Send an email each time a new event occurs for a specific monitor
* Delete events that are more than 10 days old * Delete events that are more than 10 days old
And many more. And many more.
@ -27,18 +27,16 @@ Here is what the filter window looks like
* Archive all matches: sets the archive field to 1 in the Database for the matched events. * Archive all matches: sets the archive field to 1 in the Database for the matched events.
Think of 'archiving' as grouping them under a special category - you can view archived Think of 'archiving' as grouping them under a special category - you can view archived
events later and also make sure archived events don't get deleted, for example events later and also make sure archived events don't get deleted, for example
* Update used disk space: calculates how much disk space is taken by the event and updates the db record.
.. todo :: * Create video for all matches: ffmpeg will be used to create a video file out of all the stored jpgs if using jpeg storage.
fill in what update used disk space, copy all matches, move all matches do. For the "create video" filter, put in more details on how it works, any dependencies etc. * Email details of all matches: Sends an email to the configured address with details about the event.
The email can be customized as per TBD
* Update used disk space: * Message details of all matches: Uses an email to SMS gateway to send an SMS message for each match.
* Create video for all matches: creates a video file of all the events that match * Execute command on all matches: Allows you to execute any arbitrary command on the matched events. You can use replacement tokens as subsequent arguents to the command, the last argument will be the absolute path to the event, preceeded by replacement arguents. eg: /usr/bin/script.sh %MN% will excecute as /usr/bin/script.sh MonitorName /path/to/event. Please note that urls may contain characters like & that need quoting. So you may need to put quotes around them like /usr/bin/scrupt.sh "%MN%".
* Execute command on all matches: Allows you to execute any arbitrary command on the matched events. You can use replacement tokens as subsequent arguents to the command, the last argument will be the absolute path to the event, preceeded by replacement arguents. eg: /usr/bin/script.sh %MN% will excecute as /usr/bin/script.sh MonitorName /path/to/event. * Delete all matches: Deletes all the matched events
* Delete all matches: Deletes all the matched events. * *E*: Use 'Submit' to 'test' your matching conditions. This will just match and show you what filters match. Use 'Execute' to actually execute the action after matching your conditions. Use 'Save' to save the filter for future use and 'Reset' to clear your settings
* Copy all matches: * Copy all matches: copies the event files to another location, specified in the Copy To dropdown. The other location must be setup in the Storage Tab under options.
* Move all matches: * Move all matches: copies the event files to another location, specified in the Move To dropdown. The other location must be setup in the Storage Tab under options. The files will be delete from the original location.
* Run filter in background: When checked, ZoneMinder will make sure the filter is checked regularly. For example, if you want to be notified of new events by email, you should make sure this is checked. Filters that are configured to run in the background have a “*” next to it.
* Run filter concurrently: Allows this filter to run in its own thread thereby letting other filters run in parallel.
* *F*: Use 'List Matches' to 'test' your matching conditions. This will just match and show you what filters match. Use 'Execute' to actually execute the action after matching your conditions. Use 'Save' to save the filter for future use and 'Reset' to clear your settings * *F*: Use 'List Matches' to 'test' your matching conditions. This will just match and show you what filters match. Use 'Execute' to actually execute the action after matching your conditions. Use 'Save' to save the filter for future use and 'Reset' to clear your settings
@ -55,61 +53,59 @@ Here is what the filter window looks like
If you do this then the subsequent dialog will also allow you specify whether you want this filter automatically applied in order to delete events or upload events via ftp to another server and mail notifications of events to one or more email accounts. Emails and messages (essentially small emails intended for mobile phones or pagers) have a format defined in the Options screen, and may include a variety of tokens that can be substituted for various details of the event that caused them. This includes links to the event view or the filter as well as the option of attaching images or videos to the email itself. Be aware that tokens that represent links may require you to log in to access the actual page, and sometimes may function differently when viewed outside of the general ZoneMinder context. The tokens you can use are as follows. If you do this then the subsequent dialog will also allow you specify whether you want this filter automatically applied in order to delete events or upload events via ftp to another server and mail notifications of events to one or more email accounts. Emails and messages (essentially small emails intended for mobile phones or pagers) have a format defined in the Options screen, and may include a variety of tokens that can be substituted for various details of the event that caused them. This includes links to the event view or the filter as well as the option of attaching images or videos to the email itself. Be aware that tokens that represent links may require you to log in to access the actual page, and sometimes may function differently when viewed outside of the general ZoneMinder context. The tokens you can use are as follows.
* %EI% Id of the event * %EI% Id of the event
* %EN% Name of the event * %EN% Name of the event
* %EC% Cause of the event * %EC% Cause of the event
* %ED% Event description * %ED% Event description
* %ET% Time of the event * %ET% Time of the event
* %EL% Length of the event * %EL% Length of the event
* %EF% Number of frames in the event * %EF% Number of frames in the event
* %EFA% Number of alarm frames in the event * %EFA% Number of alarm frames in the event
* %EST% Total score of the event * %EST% Total score of the event
* %ESA% Average score of the event * %ESA% Average score of the event
* %ESM% Maximum score of the event * %ESM% Maximum score of the event
* %EP% Path to the event * %EP% Path to the event
* %EPS% Path to the event stream * %EPS% Path to the event stream
* %EPI% Path to the event images * %EPI% Path to the event images
* %EPI1% Path to the first alarmed event image * %EPI1% Path to the first alarmed event image
* %EPIM% Path to the (first) event image with the highest score * %EPIM% Path to the (first) event image with the highest score
* %EI1% Attach first alarmed event image * %EI1% Attach first alarmed event image
* %EIM% Attach (first) event image with the highest score * %EI1A% Attach first alarmed event analysis image
* %EV% Attach event mpeg video * %EIM% Attach (first) event image with the highest score
* %MN% Name of the monitor * %EIMA% Attach (first) event analysis image with the highest score
* %MET% Total number of events for the monitor * %EIMOD% Attach event image with object detection objects
* %MEH% Number of events for the monitor in the last hour * %EV% Attach event mpeg video
* %MED% Number of events for the monitor in the last day * %EVM% Attach event mpeg video in phone format
* %MEW% Number of events for the monitor in the last week * %MN% Name of the monitor
* %MEM% Number of events for the monitor in the last month * %MET% Total number of events for the monitor
* %MEA% Number of archived events for the monitor * %MEH% Number of events for the monitor in the last hour
* %MOD% Path to image containing object detection * %MED% Number of events for the monitor in the last day
* %MP% Path to the monitor window * %MEW% Number of events for the monitor in the last week
* %MPS% Path to the monitor stream * %MEM% Number of events for the monitor in the last month
* %MPI% Path to the monitor recent image * %MEA% Number of archived events for the monitor
* %FN% Name of the current filter that matched * %MP% Path to the monitor window
* %FP% Path to the current filter that matched * %MPS% Path to the monitor stream
* %ZP% Path to your ZoneMinder console * %MPI% Path to the monitor recent image
* %FN% Name of the current filter that matched
* %FP% Path to the current filter that matched
* %ZP% Path to your ZoneMinder console
Finally you can also specify a script which is run on each matched event. This script should be readable and executable by your web server user. It will get run once per event and the relative path to the directory containing the event in question. Normally this will be of the form <MonitorName>/<EventId> so from this path you can derive both the monitor name and event id and perform any action you wish. Note that arbitrary commands are not allowed to be specified in the filter, for security the only thing it may contain is the full path to an executable. What that contains is entirely up to you however. Finally you can also specify a script which is run on each matched event. This script should be readable and executable by your web server user. It will get run once per event and the relative path to the directory containing the event in question. Normally this will be of the form <MonitorName>/<EventId> so from this path you can derive both the monitor name and event id and perform any action you wish. Note that arbitrary commands are not allowed to be specified in the filter, for security the only thing it may contain is the full path to an executable. What that contains is entirely up to you however.
Filtering is a powerful mechanism you can use to eliminate events that fit a certain pattern however in many cases modifying the zone settings will better address this. Where it really comes into its own is generally in applying time filters, so for instance events that happen during weekdays or at certain times of the day are highlighted, uploaded or deleted. Additionally using disk related terms in your filters means you can automatically create filters that delete the oldest events when your disk gets full. Be warned however that if you use this strategy then you should limit the returned results to the amount of events you want deleted in each pass until the disk usage is at an acceptable level. If you do not do this then the first pass when the disk usage is high will match, and then delete, all events unless you have used other criteria inside of limits. ZoneMinder ships with a sample filter already installed, though disabled. The PurgeWhenFull filter can be used to delete the oldest events when your disk starts filling up. To use it you should select and load it in the filter interface, modify it to your requirements, and then save it making you sure you check the Delete all matches option. This will then run in the background and ensure that your disk does not fill up with events. Filtering is a powerful mechanism you can use to eliminate events that fit a certain pattern however in many cases modifying the zone settings will better address this. Where it really comes into its own is generally in applying time filters, so for instance events that happen during weekdays or at certain times of the day are highlighted, uploaded or deleted. Additionally using disk related terms in your filters means you can automatically create filters that delete the oldest events when your disk gets full. Be warned however that if you use this strategy then you should limit the returned results to the amount of events you want deleted in each pass until the disk usage is at an acceptable level. If you do not do this then the first pass when the disk usage is high will match, and then delete, all events unless you have used other criteria inside of limits. ZoneMinder ships with a sample filter already installed, though disabled. The PurgeWhenFull filter can be used to delete the oldest events when your disk starts filling up. To use it you should select and load it in the filter interface, modify it to your requirements, and then save it making you sure you check the Delete all matches option. This will then run in the background and ensure that your disk does not fill up with events.
When saving filters, if you want the filter to run in the background make sure you select the "Run filter in background" option. When checked, ZoneMinder will make sure the filter is checked regularly. For example, if you want to be notified of new events by email, you should make sure this is checked. Filters that are configured to run in the background have a "*" next to it in the dropdown.
Saving filters
-----------------
When saving filters, if you want the filter to run in the background make sure you select the "Run filter in background" option. When checked, ZoneMinder will make sure the filter is checked regularly. For example, if you want to be notified of new events by email, you should make sure this is checked. Filters that are configured to run in the background have a "*" next to it.
How filters actually work How filters actually work
-------------------------- --------------------------
It is useful to know how filters actually work behind the scenes in ZoneMinder, in the event you find your filter not functioning as intended: It is useful to know how filters actually work behind the scenes in ZoneMinder, in the event you find your filter not functioning as intended:
* the primary filter processing process in ZoneMinder is a perl file called ``zmfilter.pl`` which retrieves filters from the Filters database table * Each filter set to run in the background will be run in it's own process called ``zmfilter.pl`` which retrieves filters from the Filters database table
* zmfilter.pl runs every FILTER_EXECUTE_INTERVAL seconds (default is 20s, can be changed in Options->System) * zmfilter.pl runs every FILTER_EXECUTE_INTERVAL seconds (default is 20s, can be changed in Options->System)
* in each run, it goes through all the filters which are marked as "Run in Background" and if the conditions match performs the specified action * after each interval the filter will query the database and apply the action to each matching event.
* zmfilter.pl also reloads all the filters every FILTER_RELOAD_DELAY seconds (default is 300s/5mins, can be changed in Options->System) * zmfilter.pl also reloads the filter every FILTER_RELOAD_DELAY seconds (default is 300s/5mins, can be changed in Options->System)
* So if you have just created a new filter, zmfilter will not see it till the next FILTER_RELOAD_DELAY cycle * In previous versions of ZoneMinder filter changes would not take immediate effect, but now the web ui will start/stop/restart filters as appropriate upon editing a filter.
* This is also important if you are using "relative times" like 'now' - see :ref:`relative_caveat`
Relative items in date strings Relative items in date strings

View File

@ -103,18 +103,17 @@ if ( $command eq 'state' ) {
or Fatal("Can't prepare '$sql': ".$dbh->errstr()); or Fatal("Can't prepare '$sql': ".$dbh->errstr());
my $res = $sth->execute($Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID}: ()) my $res = $sth->execute($Config{ZM_SERVER_ID} ? $Config{ZM_SERVER_ID}: ())
or Fatal("Can't execute: ".$sth->errstr()); or Fatal("Can't execute: ".$sth->errstr());
while( my $monitor = $sth->fetchrow_hashref() ) { while ( my $monitor = $sth->fetchrow_hashref() ) {
foreach my $definition ( @{$state->{Definitions}} ) { foreach my $definition ( @{$state->{Definitions}} ) {
if ( $monitor->{Id} =~ /^$definition->{Id}$/ ) { if ( $monitor->{Id} =~ /^$definition->{Id}$/ ) {
$monitor->{NewFunction} = $definition->{Function}; $monitor->{NewFunction} = $definition->{Function};
$monitor->{NewEnabled} = $definition->{Enabled}; $monitor->{NewEnabled} = $definition->{Enabled};
last;
} }
} }
#next if ( !$monitor->{NewFunction} ); next if ! exists $monitor->{NewFunction};
$monitor->{NewFunction} = 'None' $monitor->{NewFunction} = 'None' if !$monitor->{NewFunction};
if ( !$monitor->{NewFunction} ); $monitor->{NewEnabled} = 0 if !$monitor->{NewEnabled};
$monitor->{NewEnabled} = 0
if ( !$monitor->{NewEnabled} );
if ( $monitor->{Function} ne $monitor->{NewFunction} if ( $monitor->{Function} ne $monitor->{NewFunction}
|| $monitor->{Enabled} ne $monitor->{NewEnabled} || $monitor->{Enabled} ne $monitor->{NewEnabled}
) { ) {

@ -1 +1 @@
Subproject commit 0bd63fb464957080ead342db58ca9e01532cf1ef Subproject commit 14292374ccf1328f2d5db20897bd06f99ba4d938

View File

@ -458,22 +458,22 @@ function getAlarmCmdResponse(respObj, respText) {
} }
function cmdDisableAlarms() { function cmdDisableAlarms() {
alarmCmdReq.send(alarmCmdParms+auth_relay+"&command=disableAlarms"); alarmCmdReq.send(alarmCmdParms+'&'+auth_relay+"&command=disableAlarms");
} }
function cmdEnableAlarms() { function cmdEnableAlarms() {
alarmCmdReq.send(alarmCmdParms+auth_relay+"&command=enableAlarms"); alarmCmdReq.send(alarmCmdParms+'&'+auth_relay+"&command=enableAlarms");
} }
function cmdForceAlarm() { function cmdForceAlarm() {
alarmCmdReq.send(alarmCmdParms+auth_relay+"&command=forceAlarm"); alarmCmdReq.send(alarmCmdParms+'&'+auth_relay+"&command=forceAlarm");
if ( window.event ) { if ( window.event ) {
window.event.preventDefault(); window.event.preventDefault();
} }
} }
function cmdCancelForcedAlarm() { function cmdCancelForcedAlarm() {
alarmCmdReq.send(alarmCmdParms+auth_relay+"&command=cancelForcedAlarm"); alarmCmdReq.send(alarmCmdParms+'&'+auth_relay+"&command=cancelForcedAlarm");
if ( window.event ) { if ( window.event ) {
window.event.preventDefault(); window.event.preventDefault();
} }