Event notifications do not work

Forum for questions and support relating to the 1.29.x releases only.
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Event notifications do not work

Post by ngnixtab »

Hi. I have a server running Debian 8. I installed ZM 1.29 according to the instructions of the wiki. Everything works great, except for sending e-mail notifications about events. Mail I also set up the following wiki. Sending mail from the console, but that's it. The wiki indicates need to make changes to the file /usr/bin/zmfilter.pl Prompt, please, that I need to change in my file? And what other steps need to be taken?

My /usr/bin/zmfilter.pl
https://gist.github.com/anonymous/ebd45 ... 8e2b81d92f
(edited by asker to reduce post length - pointed to gist above instead of paste)
User avatar
knight-of-ni
Posts: 2404
Joined: Thu Oct 18, 2007 1:55 pm
Location: Shiloh, IL

Re: Event notifications do not work

Post by knight-of-ni »

The Wiki is entirely community based. We encourage our user base to contribute to it as often as they are willing.
Unfortunately, due to so many hands in the cookie jar, it can be a bit disorganized, there can be more than one article on the same topic, and many are not maintained.

Consequently, when you said you followed the wiki, I had no idea exactly which wiki article you followed. It would be very helpful if you confirmed exactly which article you followed.

Do you mean this one?
https://wiki.zoneminder.com/How_to_get_ ... Zoneminder

Looking at the history, it appears to be written by Asker, which is good because he is active in the forum and can answer your questions. The changes mentioned in that article to zmfilter.pl already appear to be in our master branch. You might be better off waiting for 1.30.0 release, which is just around the corner.

I'll let asker know you've got a question, but in the meantime, we will need to see how you populated the fields under Options -> Email. Simply telling us you did it right, is not particularly helpful. You need to show us, preferably via screenshot. You should also enable Debug and inspect your ZoneMinder logs for errors related to zmfilter.
Visit my blog for ZoneMinder related projects using the Raspberry Pi, Orange Pi, Odroid, and the ESP8266
All of these can be found at https://zoneminder.blogspot.com/
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

hi, please confirm that you are indeed using https://wiki.zoneminder.com/How_to_get_ ... Zoneminder.
Also how did you test your email is working - please post the exact command.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Re: Event notifications do not work

Post by ngnixtab »

Thanks for your answer. I use this command for testing

echo "Test message" | mail -s Test targetemail@example.com

I have configured msmtp and mutt. For example, I can receive messages from my backup script after successful execution of the backup task. Mail working correctly.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

Okay, so then you are not following the wiki link knnniggett or I pointed to right (as that is only for ssmtp) ?
a) So which wiki are you following? Please post the link
b) Look at your syslog -- are there any logs related to mail sending?
c) Please respond to knniggett's request on posting a screenshot of your Options->Email.

Please be very specific in your response so we know what exactly is going on.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Re: Event notifications do not work

Post by ngnixtab »

I used this wiki page https://wiki.zoneminder.com/How_to_get_ ... Zoneminder

And I could not understand what I must to change in zmfilter.pl I tried several times to make changes, but none option does not work. I do not understand the code enough to understand what the problem is, unfortunately.

Fragments of syslog:

Jul 9 06:52:56 debian rsyslogd: [origin software="rsyslogd" swVersion="8.4.2" x-pid="607" x-info="http://www.rsyslog.com"] rsyslogd was HUPed
Jul 9 06:52:56 debian rsyslogd0: action 'action 17' resumed (module 'builtin:ompipe') [try http://www.rsyslog.com/e/0 ]
Jul 9 06:52:56 debian rsyslogd-2359: action 'action 17' resumed (module 'builtin:ompipe') [try http://www.rsyslog.com/e/2359 ]
Jul 9 06:55:01 debian CRON[8687]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Jul 9 06:55:52 debian zmdc[1650]: INF [Starting pending process, zmfilter.pl]
Jul 9 06:55:52 debian zmdc[8689]: INF ['zmfilter.pl' started at 16/07/09 06:55:52]
Jul 9 06:55:52 debian zmdc[1650]: INF ['zmfilter.pl' starting at 16/07/09 06:55:52, pid = 8689]
Jul 9 06:55:53 debian zmdc[1650]: ERR ['zmfilter.pl' exited abnormally, exit status 9]
Jul 9 07:00:01 debian zmdc[1650]: INF [Starting pending process, zmc -m 3]
Jul 9 07:00:01 debian zmdc[1650]: INF ['zmc -m 3' starting at 16/07/09 07:00:01, pid = 8699]
Jul 9 07:00:01 debian zmdc[8699]: INF ['zmc -m 3' started at 16/07/09 07:00:01]
Jul 9 07:00:01 debian undef[8699]: INF [No Server ID or Name specified in config. Not using Multi-Server Mode.]
Jul 9 07:00:01 debian zmc[8699]: ERR [Bogus number of lines return from query, 0 returned for query select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = 3.]
Jul 9 07:00:01 debian zmc[8699]: ERR [Can't use query result: ]
Jul 9 07:00:01 debian zmdc[1650]: INF ['zmc -m 3' exited normally]
Jul 9 07:05:01 debian CRON[8707]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)
Jul 9 07:05:53 debian zmdc[1650]: INF [Starting pending process, zmfilter.pl]
Jul 9 07:05:53 debian zmdc[8710]: INF ['zmfilter.pl' started at 16/07/09 07:05:53]
Jul 9 07:05:53 debian zmdc[1650]: INF ['zmfilter.pl' starting at 16/07/09 07:05:53, pid = 8710]
Jul 9 07:05:54 debian zmdc[1650]: ERR ['zmfilter.pl' exited abnormally, exit status 9]
Jul 9 07:09:01 debian CRON[8717]: (root) CMD ( [ -x /usr/lib/php5/sessionclean ] && /usr/lib/php5/sessionclean)
Jul 9 07:10:01 debian zmdc[1650]: INF [Starting pending process, zmc -m 3]
Jul 9 07:10:01 debian zmdc[8750]: INF ['zmc -m 3' started at 16/07/09 07:10:01]
Jul 9 07:10:01 debian zmdc[1650]: INF ['zmc -m 3' starting at 16/07/09 07:10:01, pid = 8750]
Jul 9 07:10:01 debian undef[8750]: INF [No Server ID or Name specified in config. Not using Multi-Server Mode.]
Jul 9 07:10:01 debian zmc[8750]: ERR [Bogus number of lines return from query, 0 returned for query select Id, Name, ServerId, Type, Function+0, Enabled, LinkedMonitors, Device, Channel, Format, V4LMultiBuffer, V4LCapturesPerFrame, Protocol, Method, Host, Port, Path, Options, User, Pass, Width, Height, Colours, Palette, Orientation+0, Deinterlacing, RTSPDescribe, Brightness, Contrast, Hue, Colour, EventPrefix, LabelFormat, LabelX, LabelY, LabelSize, ImageBufferCount, WarmupCount, PreEventCount, PostEventCount, StreamReplayBuffer, AlarmFrameCount, SectionLength, FrameSkip, MotionFrameSkip, AnalysisFPS, AnalysisUpdateDelay, MaxFPS, AlarmMaxFPS, FPSReportInterval, RefBlendPerc, AlarmRefBlendPerc, TrackMotion, SignalCheckColour, Exif from Monitors where Id = 3.]
Jul 9 07:10:01 debian zmc[8750]: ERR [Can't use query result: ]
Jul 9 07:10:01 debian zmdc[1650]: INF ['zmc -m 3' exited normally]
Jul 9 07:15:01 debian CRON[8863]: (root) CMD (command -v debian-sa1 > /dev/null && debian-sa1 1 1)

May be, I configured wrong filters for events? Screenshots attached
Attachments
email.png
email.png (71.82 KiB) Viewed 11195 times
mailme.png
mailme.png (18.98 KiB) Viewed 11265 times
Last edited by ngnixtab on Sun Jul 10, 2016 9:27 am, edited 1 time in total.
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Re: Event notifications do not work

Post by ngnixtab »

In zmfilter log was errors "Can't send email: SMTP mail() command failed: : sender address must contain a domain". I added in e-mail options domain (just root@mydebian.com) and no more errors in log but still no notifications in my email.
Attachments
noerrlog.png
noerrlog.png (27.84 KiB) Viewed 11262 times
errorlog.png
errorlog.png (70.16 KiB) Viewed 11262 times
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

Can you post your zmfilter.pl into a github gist ? https://gist.github.com
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

Thanks - also can you confirm if you are using msmtp or ssmtp ? My guide was for ssmtp. You mentioned msmtp earlier.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Re: Event notifications do not work

Post by ngnixtab »

I using msmtp because ssmtp do not work on my Debian 8, unfortunately. Also I using mutt. I can send email-message from console using command "mail" or using command "msmtp".
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

Okay, I just set up ssmtp again (I am using ZM 1.30, but should be the same for 1.29) and verified it works

Since your command line is working, the chances of something being wrong in your ZM Email settings is high. Note that my notes below are for ssmtp not msmtp (no idea about msmtp)

a) Please make sure you restart ZM after making mail changes

a) You do _not_ have to change anything in zmfilter.pl --> ZM has implemented the changes. My wiki article was pre 1.29. I've edited/corrected the wiki.

Here are my ZM email settings --> I've circled the important parts:

Image

Please make sure you have the correct values set and also have checked the "new mail modules checkbox"

b) Here are my ssmtp settings with gmail SMTP (I have no idea of msmtp but if its similar, you probably have something similar, plus since your command line is working, you should not need to fiddle with it) (emails have been changed)

Code: Select all

root@homeserver:/home/pp# cat /etc/ssmtp/revaliases 

root:pp@gmail.com:smtp.gmail.com:587
www-data:pp@gmail.com:smtp.gmail.com:587

cat /etc/ssmtp/ssmtp.conf

Code: Select all

root=pp@gmail.com
mailhub=smtp.gmail.com:587
hostname=localhost
RewriteDomain=gmail.com
UseSTARTTLS=YES
UseTLS=YES
AuthUser=pp@gmail.com
AuthPass=something
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
ngnixtab
Posts: 7
Joined: Sat Jul 09, 2016 3:43 am

Re: Event notifications do not work

Post by ngnixtab »

Once again, I checked all the settings according to your advice, but nothing new has happened. Then I did the following:
1. Uninstalled msmtp
2. Installed ssmpt
3. Set ssmpt like your files

Configure the event filter as follows:

Alarm frames -> greater than or equal to -> 1
Email details of all matches -> checked
Run in background -> checked

Restart ZM, I began to observe. In the logs ZM began to appear with red line errors from zmfilter:

Can't send e-mail: SMTP Failed to connect to mail server: Connection refused at /usr/bin/zmfilter.pl line 1181.

I opened zmfilter.pl in nano and go to line 1181. There are was

1179 ### Send the Message
1180 MIME::Lite->send( "smtp", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
1181 $mail->send();

I went back to your instructions on the wiki and copied the line from there. I got so:

### Send the Message
#MIME::Lite->send( "sendmail", $Config{ZM_EMAIL_HOST}, Timeout=>60 );
#$mail->send();
$mail->send('sendmail','/usr/sbin/ssmtp',$Config{ZM_EMAIL_ADDRESS});

That is, I brought to the configuration as described in your instruction. After these steps event notification works!

From all this I conclude that your article, asker, in the wiki is absolutely correct, but it is absolutely necessary to set up ssmtp. Thank you! And excuse me for my bad english, it's not my native language.
User avatar
asker
Posts: 1553
Joined: Sun Mar 01, 2015 12:12 pm

Re: Event notifications do not work

Post by asker »

Ah yes, it looks like this ssmtp change was _not_ added in 1.29 but after it ! So correct, you do need to apply the change. Glad it worked out.
I no longer work on zmNinja, zmeventnotification, pyzm or mlapi. I may respond on occasion based on my available time/interest.

Please read before posting:
How to set up logging properly
How to troubleshoot and report - ES
How to troubleshoot and report - zmNinja
ES docs
zmNinja docs
Simpler
Posts: 76
Joined: Mon Nov 02, 2015 12:40 am

Re: Event notifications do not work

Post by Simpler »

I just run into this same problem after upgrading from 1.29.0 to 1.30.0 on Linux Mint 17.2 (based on Ubuntu 14.04).

I've been beating my head against a wall all day trying to figure this out until I ran across this post.

The message that I was getting in the logs with ZoneMinder 1.30.0 was:
Can't send email: SMTP Failed to connect to mail server: Connection refused at /usr/bin/zmfilter.pl line 918.

After I edited line 918 from

Code: Select all

            $mail->send();
to

Code: Select all

            $mail->send('sendmail','/usr/sbin/ssmtp',$Config{ZM_EMAIL_ADDRESS});
and restarting zoneminder, I was miraculously able to get notifications.

The wiki at https://wiki.zoneminder.com/How_to_get_ ... Zoneminder says that this is no longer needed with 1.30.0, but this is incorrect.

Thank you so much for posting this.
Locked