Page 1 of 1

new (?) function

Posted: Tue Jun 15, 2010 1:40 pm
by ericjanssens
can I make a function in zoneminder that sends an email at <x> o clock, when there has NOT been any motion events on monitor <n> for the last <y> hours?

if not,

how can i make a cron-job, running at <x> o clock that sends an email to <email> at <smtp> , when there has NOT been any motion events on monitor <n> for the last <y> hours?


p.s. I am a newbee in linux

Posted: Tue Jun 15, 2010 4:05 pm
by Paranoid
Try this (untested):

Code: Select all

#!/usr/bin/ksh

MYSQL=/usr/bin/mysql
USER=zm_admin
PASS=password
ID=1
DB=zm
INTERVAL=3600
EMAIL="somebody@example.com a.n.other@example.com"

since=`$MYSQL -ss -u $USER --password=$PASS -D $DB -e "select UNIX_TIMESTAMP() - UNIX_TIMESTAMP(max(StartTime)) from Events where MonitorId = $ID"`

if [ $since -gt $INTERVAL ]
then
    mailx -s "No alarms for $since seconds" $EMAIL <<EOF
Zoneminder has not alarmed for $since seconds.
.
EOF
fi

exit 0
Save it to a file, make the file executable (chmod a+x filename) and run it in a cron job.
You will have to set the initial variables to your particular setup.
INTERVAL is in seconds.

debug

Posted: Tue Jun 29, 2010 7:21 am
by ericjanssens
hi

this looks ok. but it doesn't work
because i am a newbee in scripting. How can i put debug statement in this script, and where can i find the output ?