I have been a long time lurker, and have learned a lot from these forums, thank you to everyone.
I am using Zoneminder to record a security camera feed. No motion detection, just 24 hour recording. I then have a script that checks Mysql for events dated the day before, and throws them at ffmpeg which turns them into a daily video. I never watch the video, so I am looking to find a way to make sure everything is running right. The daily video that is created is always about 600MB.
So I think there is 2 ways to go about this. Add a line at the end of my script that sends a mail with the created file's details, or run a separate script that checks a directory and mails the details of the newest file in that directory.
Anyone have any advice?
Thanks.
Here is the script I use:
#!/bin/bash
MUSER="XXXX"
MPASS="XXXXXX"
MHOST="localhost"
MDB="zm"
#MYSQL="$(which mysql)"
MYSQL="/usr/bin/mysql"
#MYSQLDUMP="$(which mysqldump)"
MYSQLDUMP="/usr/bin/mysqldump"
PATHTOEVENTS="/var/cache/zoneminder/events"
MonitorId="$1"
tmpdir="/tmp"
if [ "$1" == "$null" ]
then
echo You Must Specify The Monitor ID i.e \'$0 4\' would specify monitor id 4
exit
fi
EVENTS="$($MYSQL -D$MDB -u$MUSER -p$MPASS -Bse 'select id from Events WHERE (StartTime BETWEEN DATE_SUB( CURDATE( ) ,INTERVAL 1 DAY ) AND CURDATE( )) AND (MonitorId = '$MonitorId') order by id asc')"
mkdir $tmpdir/$MonitorId
x=1
for event in ${EVENTS[@]}
do
if [ $x -eq 1 ]
then
mysqldate="$($MYSQL -D$MDB -u$MUSER -p$MPASS -Bse 'select StartTime from Events WHERE id = '$event'')"
date=`date +%Y_%m_%d --date="$mysqldate"`
firstevent="$event"
echo Making Images and Placing them in $tmpdir/$MonitorId .... Please Be Patient this could take a while.
fi
for i in $(ls -r -t $PATHTOEVENTS/$MonitorId/$event/*jpg)
do counter=$(printf %06d $x)
ln -s "$i" $tmpdir/$MonitorId/img"$counter".jpg
x=$(($x+1))
done
done
/usr/bin/ffmpeg -f image2 -i $tmpdir/$MonitorId/img%06d.jpg -vcodec libx264 -vpre normal -threads 0 /home/sasaki/camera_videos/$date-Data_Center.mp4
rm -rf $tmpdir/$MonitorId