new (?) function

Forum for questions and support relating to the 1.24.x releases only.
Locked
ericjanssens
Posts: 4
Joined: Wed May 26, 2010 12:48 pm

new (?) function

Post 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
Paranoid
Posts: 129
Joined: Thu Feb 05, 2009 10:40 pm

Post 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.
ericjanssens
Posts: 4
Joined: Wed May 26, 2010 12:48 pm

debug

Post 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 ?
Locked