Simple Email Notification?
Simple Email Notification?
I want to set up an email notification whenever a new event occurs, but I've found the documentation for filters to be very confusing. Can someone post a simple tutorial (either here or in another post and link to it here) on how to set up a filter and an email notification whenever a new event is registered?
Re: Simple Email Notification?
Okay, so I think I figured out why the simple email settings aren't working on my ZoneMinder installation. I went to the logs and found this:
I noticed in zmfilter.pl, that there were more debug lines that would signal that the email had sent properly but were not being so I added some code to get more detailed output and got the following:
Any ideas on how to fix this?
Code: Select all
02/12/2012 17:48:22.993551 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:22.994980 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-68 (33 - 14 29)']
02/12/2012 17:48:23.005264 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.006794 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-69 (18 - 8 24)']
02/12/2012 17:48:23.016994 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.018351 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-70 (18 - 9 34)']
02/12/2012 17:48:23.028595 zmfilter[20345].INF [Creating notification email]
02/12/2012 17:48:23.030089 zmfilter[20345].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-71 (10 - 5 14)']
Code: Select all
02/12/12 17:50:53.457866 zmfilter[6927].INF [Creating notification email]
02/12/12 17:50:53.459138 zmfilter[6927].INF [Sending notification email 'ZoneMinder: Alarm - Monitor-7-71 (10 - 5 14)']
02/12/12 17:50:53.460039 zmfilter[6927].INF [New Mail Module]
02/12/12 17:50:53.461240 zmfilter[6927].INF [Adding Text]
02/12/12 17:50:53.462243 zmfilter[6927].INF [Adding Attachments]
02/12/12 17:50:53.462770 zmfilter[6927].INF [Sending...]
02/12/12 17:50:53.471051 zmfilter[6927].INF [Can't send email: SMTP mail() command failed:
4.3.0 Temporary system failure. Please try again later.]
Re: Simple Email Notification?
Do you have postfix installed?
After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
Re: Simple Email Notification?
Installing postfix doesn't help, have tried that. Zoneminder has it's own smtp server installed in the ubuntu package. I've confirmed this via telnet. Even if you install postfix, Zoneminder's smtp server has control over port 25.
Re: Simple Email Notification?
Then, remove this package and use postfix...
After more than 15 years, no longer using ZM as surveillance system.
Now in the dark side, using a commercial system...
Re: Simple Email Notification?
Did a fresh install of Zoneminder, postfix and still couldn't get it working. Re-imaged the system and started from scratch one more time because I couldn't be believe that installing postfix wouldn't resolve my issue. The re-image worked and I'm still dumbfounded as to what I had done to the previous image to break Zoneminder's ability to use postfix. Thanks for your replies.
Re: Simple Email Notification?
Hey I have some script that checks for motion events. Here's a version I use but I had to base my auth on something more specific to my needs).
I had to install sendmail and fuss with the /etc/mail/submit.mc:
define(`SMART_HOST', `myisp.smtpserver.com')dnl
MASQUERADE_AS(`mydns.dyndns.org')dnl
which added the following entries to the submit.cf after a make:
DSmyisp.smtpserver.com
DMmydns.dyndns.org
Note that you dont need sendmail running at all if you are only outbounding messages.
Seems to send about 20-30 seconds after an event starts.
#!/bin/bash
# watchcam script v1.0 - Author koolb@hotmail.com
# Copyright Dec 2011
#
# repeatedly watches zmu -l for changes in state for the monitors:
# Id Func State TrgState LastImgTim RdIdx WrIdx LastEvt FrmRate
# 1 3 0 0 1324176081.57 65 65 15505 4.25
# 3 3 0 0 1324176081.65 57 57 15416 5.05
# 4 3 0 0 1324176081.73 1 1 15506 4.30
export APP="Cam Watch"
export RCPT="myemail@hotmail.com"
sbmail()
{
subj=$1
body="${2-$(date)}"
echo -e "$body\n\n" | mail -s "$APP: $subj" $RCPT
}
sbmail Starting
trap "sbmail Ending" HUP ABRT TERM QUIT EXIT
while sudo zmu -l -A $(cat /mysecret/auth)
do usleep 80000
done | perl -ne 'sub smail {
my ($subj, $body, $le) = @_;
my $bodyfn="/tmp/ca.$$";
my $loc = sprintf("$httpfmt\n\n\n", $le);
open(BODY, ">$bodyfn") || die "Cant open email file $bodyfn: $!";
print BODY "$body\n$loc";
close(BODY);
system("mail -s \"$subj\" " . $ENV{"RCPT"} ." < $bodyfn");
print "\n$subj";
}
BEGIN {
@monLE = (0, 0, 0, 0, 0);
@monSt = (0, 0, 0, 0, 0);
$httpfmt=$ENV{"MYZMURI"} . "/index.php?view=event&eid=%d";
}{
($id, $fn, $st, $trig, $lastImgDt, $ri, $wi, $le, $rt) = split;
next if $id == 0;
smail("Monitor $id: Event $le Started at " . localtime,
"$changed from " . $monLE[$id] . " @ " . localtime() ."\n", $le)
if $monLE[$id] ne $le && $st > 0;
smail("Monitor $id: Event $le Ended at " . localtime, "Ended", $le)
if $monSt[$id] ne $st && $st == 0;
$monSt[$id] = $st;
$monLE[$id] = $le;
}'
I had to install sendmail and fuss with the /etc/mail/submit.mc:
define(`SMART_HOST', `myisp.smtpserver.com')dnl
MASQUERADE_AS(`mydns.dyndns.org')dnl
which added the following entries to the submit.cf after a make:
DSmyisp.smtpserver.com
DMmydns.dyndns.org
Note that you dont need sendmail running at all if you are only outbounding messages.
Seems to send about 20-30 seconds after an event starts.
#!/bin/bash
# watchcam script v1.0 - Author koolb@hotmail.com
# Copyright Dec 2011
#
# repeatedly watches zmu -l for changes in state for the monitors:
# Id Func State TrgState LastImgTim RdIdx WrIdx LastEvt FrmRate
# 1 3 0 0 1324176081.57 65 65 15505 4.25
# 3 3 0 0 1324176081.65 57 57 15416 5.05
# 4 3 0 0 1324176081.73 1 1 15506 4.30
export APP="Cam Watch"
export RCPT="myemail@hotmail.com"
sbmail()
{
subj=$1
body="${2-$(date)}"
echo -e "$body\n\n" | mail -s "$APP: $subj" $RCPT
}
sbmail Starting
trap "sbmail Ending" HUP ABRT TERM QUIT EXIT
while sudo zmu -l -A $(cat /mysecret/auth)
do usleep 80000
done | perl -ne 'sub smail {
my ($subj, $body, $le) = @_;
my $bodyfn="/tmp/ca.$$";
my $loc = sprintf("$httpfmt\n\n\n", $le);
open(BODY, ">$bodyfn") || die "Cant open email file $bodyfn: $!";
print BODY "$body\n$loc";
close(BODY);
system("mail -s \"$subj\" " . $ENV{"RCPT"} ." < $bodyfn");
print "\n$subj";
}
BEGIN {
@monLE = (0, 0, 0, 0, 0);
@monSt = (0, 0, 0, 0, 0);
$httpfmt=$ENV{"MYZMURI"} . "/index.php?view=event&eid=%d";
}{
($id, $fn, $st, $trig, $lastImgDt, $ri, $wi, $le, $rt) = split;
next if $id == 0;
smail("Monitor $id: Event $le Started at " . localtime,
"$changed from " . $monLE[$id] . " @ " . localtime() ."\n", $le)
if $monLE[$id] ne $le && $st > 0;
smail("Monitor $id: Event $le Ended at " . localtime, "Ended", $le)
if $monSt[$id] ne $st && $st == 0;
$monSt[$id] = $st;
$monLE[$id] = $le;
}'