Added include types and email and message file config.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@361 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
572295f462
commit
182e18af90
|
@ -88,82 +88,9 @@ if ( ZM_OPT_EMAIL )
|
|||
{
|
||||
use Mail::Mailer;
|
||||
|
||||
# The tags you can use in here are as follows
|
||||
# %ZP% - The path to your ZoneMinder console
|
||||
# %MN% - The name of the monitor
|
||||
# %MET% - The total number of events for the monitor
|
||||
# %MEH% - The number of events for the monitor in the last hour
|
||||
# %MED% - The number of events for the monitor in the last day
|
||||
# %MEW% - The number of events for the monitor in the last week
|
||||
# %MEM% - The number of events for the monitor in the last month
|
||||
# %MEA% - The number of archived events for the monitor
|
||||
# %MP% - The path to the monitor window
|
||||
# %MPS% - The path to the monitor stream
|
||||
# %MPI% - The path to the monitor recent image
|
||||
# %EP% - The path to the event
|
||||
# %EPS% - The path to the event stream
|
||||
# %EPI% - The path to the event images
|
||||
# %EPI1% - The path to the first alarmed event image
|
||||
# %EPIM% - The path to the (first) event image with the highest score
|
||||
# %EI% - The id of the event
|
||||
# %EN% - The name of the event
|
||||
# %ET% - The time of the event
|
||||
# %ED% - The duration of the event
|
||||
# %EF% - The number of frames in the event
|
||||
# %EFA% - The number of alarm frames in the event
|
||||
# %EST% - The total score of the event
|
||||
# %ESA% - The average score of the event
|
||||
# %ESM% - The maximum score of the event
|
||||
# %FN% - The name of the current filter that matched
|
||||
# %FP% - The path to the current filter that matched
|
||||
use constant ZM_EMAIL_FORMAT => "<from zmconfig>"; # File containing the contents of the email
|
||||
|
||||
# Change these to suit your own preferences
|
||||
$email_subject = "ZoneMinder: Alarm - %MN%-%EI% (%ESM% - %ESA% %EFA%)";
|
||||
$email_body = "
|
||||
Hello,
|
||||
|
||||
An alarm has been detected on your installation of the ZoneMinder.
|
||||
|
||||
The details are as follows :-
|
||||
|
||||
Monitor : %MN%
|
||||
Event Id : %EI%
|
||||
Duration : %ED%
|
||||
Frames : %EF% (%EFA%)
|
||||
Scores : t%EST% m%ESM% a%ESA%
|
||||
|
||||
This alarm was matched by the %FN% filter and can be viewed at %EPS%
|
||||
|
||||
# %ZP% - The path to your ZoneMinder console
|
||||
# %MN% - The name of the monitor
|
||||
# %MET% - The total number of events for the monitor
|
||||
# %MEH% - The number of events for the monitor in the last hour
|
||||
# %MED% - The number of events for the monitor in the last day
|
||||
# %MEW% - The number of events for the monitor in the last week
|
||||
# %MEM% - The number of events for the monitor in the last month
|
||||
# %MEA% - The number of archived events for the monitor
|
||||
# %MP% - The path to the monitor window
|
||||
# %MPS% - The path to the monitor stream
|
||||
# %MPI% - The path to the monitor recent image
|
||||
# %EP% - The path to the event
|
||||
# %EPS% - The path to the event stream
|
||||
# %EPI% - The path to the event images
|
||||
# %EPI1% - The path to the first alarmed event image
|
||||
# %EPIM% - The path to the (first) event image with the highest score
|
||||
# %EI% - The id of the event
|
||||
# %EN% - The name of the event
|
||||
# %ET% - The time of the event
|
||||
# %ED% - The duration of the event
|
||||
# %EF% - The number of frames in the event
|
||||
# %EFA% - The number of alarm frames in the event
|
||||
# %EST% - The total score of the event
|
||||
# %ESA% - The average score of the event
|
||||
# %ESM% - The maximum score of the event
|
||||
# %FN% - The name of the current filter that matched
|
||||
# %FP% - The path to the current filter that matched
|
||||
|
||||
ZoneMinder
|
||||
";
|
||||
( $email_subject, $email_body ) = ZM_EMAIL_FORMAT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||
}
|
||||
|
||||
my $message_subject;
|
||||
|
@ -172,41 +99,9 @@ if ( ZM_OPT_MESSAGE )
|
|||
{
|
||||
use Mail::Mailer;
|
||||
|
||||
# The tags you can use in here are as follows
|
||||
# The path tags however may be over long for a message
|
||||
# destined for an SMS and will in any case probably not
|
||||
# direct you to a WAP compatible page (yet).
|
||||
# %ZP% - The path to your ZoneMinder console
|
||||
# %MN% - The name of the monitor
|
||||
# %MET% - The total number of events for the monitor
|
||||
# %MEH% - The number of events for the monitor in the last hour
|
||||
# %MED% - The number of events for the monitor in the last day
|
||||
# %MEW% - The number of events for the monitor in the last week
|
||||
# %MEM% - The number of events for the monitor in the last month
|
||||
# %MEA% - The number of archived events for the monitor
|
||||
# %MP% - The path to the monitor window
|
||||
# %MPS% - The path to the monitor stream
|
||||
# %MPI% - The path to the monitor recent image
|
||||
# %EP% - The path to the event
|
||||
# %EPS% - The path to the event stream
|
||||
# %EPI% - The path to the event images
|
||||
# %EPI1% - The path to the first alarmed event image
|
||||
# %EPIM% - The path to the (first) event image with the highest score
|
||||
# %EI% - The id of the event
|
||||
# %EN% - The name of the event
|
||||
# %ET% - The time of the event
|
||||
# %ED% - The duration of the event
|
||||
# %EF% - The number of frames in the event
|
||||
# %EFA% - The number of alarm frames in the event
|
||||
# %EST% - The total score of the event
|
||||
# %ESA% - The average score of the event
|
||||
# %ESM% - The maximum score of the event
|
||||
# %FN% - The name of the current filter that matched
|
||||
# %FP% - The path to the current filter that matched
|
||||
use constant ZM_MESSAGE_FORMAT => "<from zmconfig>"; # File containing the contents of the message
|
||||
|
||||
# Change these to suit your own preferences
|
||||
$message_subject = "ZoneMinder: Alarm - %MN%-%EI%";
|
||||
$message_body = "ZM alarm detected - %ED% secs, %EF%/%EFA% frames, t%EST%/m%ESM%/a%ESA% score.";
|
||||
( $message_subject, $message_body ) = ZM_MESSAGE_FORMAT =~ /subject\s*=\s*"([^\n]*)".*body\s*=\s*"(.*)"/ms;
|
||||
}
|
||||
|
||||
# ==========================================================================
|
||||
|
|
|
@ -69,7 +69,7 @@ my %types =
|
|||
integer => { hint => 'integer', parse => sub { return( int($_[0] =~ /^(\d+)$/ ), $1 ) } },
|
||||
decimal => { hint => 'decimal', parse => sub { return( int($_[0] =~ /^(\d+(?:\.\d+)?)$/ ), $1 ) } },
|
||||
hexadecimal => { hint => 'hexadecimal', parse => sub { return( int($_[0] =~ /^(?:0x)?([0-9a-f]{1,8})$/ ), "0x".$1 ) } },
|
||||
include => { hint => 'local/path/to/file', parse => sub { return( (int($_[0] =~ /^(.*)?$/ ) && -s $1), $1 ) } },
|
||||
include => { hint => 'local/path/to/file', parse => sub { return( (int($_[0] =~ /^(.*)?$/ ) && -e $1), $1 ) } },
|
||||
);
|
||||
|
||||
# Minor hack to get the right values out of configure.
|
||||
|
@ -421,6 +421,14 @@ my @options =
|
|||
help => "This option is used to define the email address that any events that match the appropriate filters will be sent to.",
|
||||
type => $types{email},
|
||||
},
|
||||
{
|
||||
name => "ZM_EMAIL_FORMAT",
|
||||
default => "zmconfig_eml.txt",
|
||||
description => "The format of the email used to send matching event details",
|
||||
requires => [ { name => "ZM_OPT_EMAIL", value => "yes" } ],
|
||||
help => "This option is used to define the file that contains the format of the email that is sent for any events that match the appropriate filters.",
|
||||
type => $types{include},
|
||||
},
|
||||
{
|
||||
name => "ZM_OPT_MESSAGE",
|
||||
default => "no",
|
||||
|
@ -436,10 +444,18 @@ my @options =
|
|||
help => "This option is used to define the short message email address that any events that match the appropriate filters will be sent to.",
|
||||
type => $types{email},
|
||||
},
|
||||
{
|
||||
name => "ZM_MESSAGE_FORMAT",
|
||||
default => "zmconfig_msg.txt",
|
||||
description => "The format of the message used to send matching event details",
|
||||
requires => [ { name => "ZM_OPT_MESSAGE", value => "yes" } ],
|
||||
help => "This option is used to define the file that contains the format of the message that is sent for any events that match the appropriate filters.",
|
||||
type => $types{include},
|
||||
},
|
||||
{
|
||||
name => "ZM_EMAIL_METHOD",
|
||||
default => "sendmail",
|
||||
description => "The method your machine uses to send email",
|
||||
description => "The method your machine uses to send email and messages",
|
||||
requires => [ { name => "ZM_OPT_EMAIL", value => "yes" }, { name => "ZM_OPT_MESSAGE", value => "yes" } ],
|
||||
help => "ZoneMinder needs to know how to send you the notification emails or messages. This option tell it which method to use, generally sendmail will work if configured correctly on your machine, otherwise choose smtp and then give your mail host address in the next option.",
|
||||
type => { hint => 'sendmail|smtp', parse => sub { return( int($_[0] =~ /^(se|sm)/i ), $1 =~ /^se/ ? 'sendmail' : 'smtp' ) } },
|
||||
|
@ -449,13 +465,13 @@ my @options =
|
|||
default => "localhost",
|
||||
description => "The host address of your SMTP mail server",
|
||||
requires => [ { name => "ZM_EMAIL_METHOD", value => "smtp" } ],
|
||||
help => "If you have chosen SMTP as the mthod by which to send notification emails or messages then this option allows you to choose which SMTP server to use to send them. The default of localhost may work if you have the sendmail, exim or a similar daemon running however you may wish to enter your ISP's SMTP mail server here.",
|
||||
help => "If you have chosen SMTP as the method by which to send notification emails or messages then this option allows you to choose which SMTP server to use to send them. The default of localhost may work if you have the sendmail, exim or a similar daemon running however you may wish to enter your ISP's SMTP mail server here.",
|
||||
type => $types{hostname},
|
||||
},
|
||||
{
|
||||
name => "ZM_FROM_EMAIL",
|
||||
default => "",
|
||||
description => "The email address you wish your event notification emails to originate from",
|
||||
description => "The email address you wish your event notifications to originate from",
|
||||
requires => [ { name => "ZM_OPT_EMAIL", value => "yes" }, { name => "ZM_OPT_MESSAGE", value => "yes" } ],
|
||||
help => "The emails or messages that will be sent to you informing you of events can appear to come from a designated email address to help you with mail filtering etc. An address of something like ZoneMinder\@your.domain is recommended.",
|
||||
type => $types{email},
|
||||
|
@ -942,16 +958,24 @@ if ( $reprocess )
|
|||
|| $opt_type == $types{decimal}
|
||||
|| $opt_type == $types{hexadecimal} )
|
||||
{
|
||||
$data =~ s/^(use\s+constant\s+$opt_name\s*=>\s*).*$/$1$opt_value;\t# $opt_desc \(from zmconfig\)/mg;
|
||||
$data =~ s/^(\s*use\s+constant\s+$opt_name\s*=>\s*).*$/$1$opt_value;\t# $opt_desc \(from zmconfig\)/mg;
|
||||
}
|
||||
elsif ( $opt_type == $types{email} )
|
||||
{
|
||||
$opt_value =~ s/\@/\\\@/;
|
||||
$data =~ s/^(use\s+constant\s+$opt_name\s*=>\s*).*$/$1"$opt_value";\t# $opt_desc \(from zmconfig\)/mg;
|
||||
$data =~ s/^(\s*use\s+constant\s+$opt_name\s*=>\s*).*$/$1"$opt_value";\t# $opt_desc \(from zmconfig\)/mg;
|
||||
}
|
||||
elsif ( $opt_type == $types{include} )
|
||||
{
|
||||
open( FILE, "<$opt_value" ) or die( "Can't open option file '$opt_value': $!" );
|
||||
local $/;
|
||||
my $content = <FILE>;
|
||||
$content =~ s/"/\\"/g;
|
||||
$data =~ s/^(\s*use\s+constant\s+$opt_name\s*=>\s*).*$/$1\t# $opt_desc \(from zmconfig\)\n"$content";/mg;
|
||||
}
|
||||
else
|
||||
{
|
||||
$data =~ s/^(use\s+constant\s+$opt_name\s*=>\s*).*$/$1"$opt_value";\t# $opt_desc \(from zmconfig\)/mg;
|
||||
$data =~ s/^(\s*use\s+constant\s+$opt_name\s*=>\s*).*$/$1"$opt_value";\t# $opt_desc \(from zmconfig\)/mg;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue