motioneye-project / motioneye

A web frontend for the motion daemon.
GNU General Public License v3.0
3.98k stars 652 forks source link

sendmail is clogging up, email notification stops #256

Open fireheadman opened 8 years ago

fireheadman commented 8 years ago

Not sure what is causing this.... I have noticed the past 2 days notifications have stopped. when I look at the system, I see sendmail clogged up

pi@webcam01:~ $ ps aux | grep sendmail | wc -l 58

Some of the output: (I get over 50+ a day I have stop/start to make it work)

pi@webcam01:~ $ ps aux|grep motion
root       368  0.0  0.0   1912   396 ?        Ss   10:28   0:00 sh -c /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" start 1; /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf 'smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL>' 'motion_start' '1' '2016-07-19T10:28:10' '5'  &
root       371  0.1  1.2  19892 11776 ?        S    11:27   0:02 /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf 'smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL> motion_start 2 2016-07-19T11:27:01 5
root       404  1.4  2.2  58116 21720 ?        Ssl  Jul18  10:57 /usr/bin/python /usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf
root       466  0.0  1.4  18376 13920 ?        S    10:28   0:01 /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL> motion_start 1 2016-07-19T10:28:10 5
root       752  0.0  1.3  27512 12732 ?        S    Jul18   0:00 /usr/bin/python /usr/local/bin/meyectl startserver -c /etc/motioneye/motioneye.conf

Another MAJOR issue I see with this output is my usename/password being in plain text.... Wish there was a way to keep this private? I have already performed a chmod 600 on /etc/motioneye/thread-*.conf

fireheadman commented 8 years ago

Was looking at the sendmail.py script. I was under the impression the actual "sendmail" program was being called out.... it looks like you have python doing the email work.

2016-07-19 12:01:58: [sendmail]     INFO: email sent
2016-07-19 12:04:55: [sendmail]     INFO: email sent
2016-07-19 12:13:37: [sendmail]     INFO: email sent
2016-07-19 12:25:30: [sendmail]     INFO: email sent
2016-07-19 12:25:43: [sendmail]    ERROR: timeout waiting for the media listing process to finish
2016-07-19 12:25:45: [sendmail]     INFO: email sent
2016-07-19 12:52:05: [sendmail]    ERROR: timeout waiting for the media listing process to finish
2016-07-19 12:52:07: [sendmail]     INFO: email sent
2016-07-19 12:52:18: [sendmail]     INFO: email sent

From the time it took me to write the first message in this thread to this one... I have accumulated 3 more stale/clogged emails in queue. When I look at the log (/var/log/motion.log), I see 1 of them matching (timestamp = 12:25.

pi@webcam01:~/domoticz $ ps aux|grep sendmail
pi        5255  0.0  0.2   4276  2000 pts/0    S+   13:07   0:00 grep --color=auto sendmail
root     16173  0.0  0.0   1912   388 ?        Ss   12:25   0:00 sh -c /usr/local/lib/python2.7/dist-packages/motioneye/scripts/relayevent.sh "/etc/motioneye/motioneye.conf" start 2; /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf 'smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL>' 'motion_start' '2' '2016-07-19T12:25:25' '5'  &
root     16267  0.0  1.4  18376 13988 ?        S    12:25   0:01 /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL> motion_start 2 2016-07-19T12:25:25 5
root     17261  0.1  1.2  20148 11732 ?        S    12:25   0:03 /usr/bin/python /usr/local/lib/python2.7/dist-packages/motioneye/meyectl.pyc sendmail -c /etc/motioneye/motioneye.conf smtp.<myisp>.net' '587' 'username@<myisp>.net' '<myPASSWORD>' 'True' 'motion@<myDOMAIN>.com' '<myEMAIL> motion_start 2 2016-07-19T12:25:25 5

How hard would it be to put a catch/kill line in sendmail.py so that when an email times out, it is nuked instead of being left in queue?

ccrisan commented 8 years ago
  1. Please attach your motion.log file here. It usually contains more details about email sending.
  2. Ideally the email sending process should disappear in the near future being completely embedded in the motionEye process.
fireheadman commented 8 years ago

/var/log/motion.log

pi@webcam01:~/domoticz $ cat /var/log/motion.log
[0] [NTC] [ALL] conf_load: Processing thread 0 - config file /etc/motioneye/motion.conf
[0] [NTC] [ALL] config_thread: Processing config file thread-1.conf
[0] [NTC] [ALL] config_thread: Processing config file thread-2.conf
[0] [NTC] [ALL] motion_startup: Motion Unofficial-Git-UNKNOWN Started
[0] [NTC] [ALL] motion_startup: Logging to syslog
[0] [NTC] [ALL] motion_startup: Using default log type (ALL)
[0] [NTC] [ALL] motion_startup: Using log type (ALL) log level (WRN)
[1] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD
[2] [WRN] [VID] v4l2_select_input: Device doesn't support VIDIOC_G_STD
2016-07-19 12:01:58: [sendmail]     INFO: email sent
2016-07-19 12:04:55: [sendmail]     INFO: email sent
2016-07-19 12:13:37: [sendmail]     INFO: email sent
2016-07-19 12:25:30: [sendmail]     INFO: email sent
2016-07-19 12:25:43: [sendmail]    ERROR: timeout waiting for the media listing process to finish
2016-07-19 12:25:45: [sendmail]     INFO: email sent
2016-07-19 12:52:05: [sendmail]    ERROR: timeout waiting for the media listing process to finish
2016-07-19 12:52:07: [sendmail]     INFO: email sent
2016-07-19 12:52:18: [sendmail]     INFO: email sent

Do I need to find where the debug option is and turn that on for you??

ccrisan commented 8 years ago

It seems that you have too many media files gathered and it takes too much to parse them all (hence the errors you see). Either clean them up and configure the camera in such a way that no more than, say, a few hundred pictures are normally stored in your camera's root folder, or set the email picture timespan to 0 to disable picture email attachments.

fireheadman commented 8 years ago

I would agree on the "too much" piece. I use the Still Image part of motioneye so that I can get a snapshot attached to the notification email since there is not a way to attach the actual video itself.

I use to attach my videos to email when I used the original "motion" program using postfix/mutt combo

However, once a motion event occurs, this causes 50+ Still Images to be saved, so just having 5 events trigger within a few hours can cause 250+ images to piles up. I have already created a cron job to clean up anything over 900min (15hrs of age) since the lowest is 1 day. Would be nice to see the Custom option support hours or even minutes

fireheadman commented 8 years ago

Here is my cleanup solution:

# --------------min (0 - 59)
# | ------------hour (0 - 23)
# | | ----------day of month (1 - 31)
# | | | --------month (1 - 12)
# | | | | ------day of week (0 - 6) (Sunday=0)
# | | | | |
# * * * * *     command to be executed
##
# FIND/DELETE CAMERA IMAGE FILES OLDER THAN 1HR EVERY 10 MIN
*/10 * * * * find /data/webcam01/video_files/cam*/*/images -type f -mmin +60 -exec rm -f {} \;