run command when an even ocurrs / trigger event with command
run command when an even ocurrs / trigger event with command
Hi!
Is there a way to configure ZoneMinder, or a specific Monitor to run a linux command when an event occurs? The reverse would be very interesting, too: triggering an event by calling some command from outside of zoneminder. I seem to remember that there was a comamnd for the latter, but can't find it in the docs anymore.
Is there a way to configure ZoneMinder, or a specific Monitor to run a linux command when an event occurs? The reverse would be very interesting, too: triggering an event by calling some command from outside of zoneminder. I seem to remember that there was a comamnd for the latter, but can't find it in the docs anymore.
Ok. It seems that zmtrigger.pl can be used to trigger events from outside of ZM (although i still haven't got it to work - the docs are a bit lacking, i think. can zmtrigger read from STDIN?)
But the more important part of my question (for me) was how to get ZM to call some external command when an event occurs - the exact opposite of zmtrigger.pl
Thanks for any help.
But the more important part of my question (for me) was how to get ZM to call some external command when an event occurs - the exact opposite of zmtrigger.pl
Thanks for any help.
External events
You can send events to ZoneMinder fairly easily via TCP port 6802, I've successfully tried that so far. There are other connection options (Unix?) I haven't experimented with that might work as well.
Hi,
I have configured a filter that runs a command when an event occurs but it doesn't work. I need it for run gnokii that sends me an sms:
$ echo 'message here' | gnokii --config /etc/gnokiirc --sendsms PhoneNumber
I tried to run other command and it doesn't work yet but if I select the "Email details of all matches" it works perfectly.
Can someone help me?
tnx
I have configured a filter that runs a command when an event occurs but it doesn't work. I need it for run gnokii that sends me an sms:
$ echo 'message here' | gnokii --config /etc/gnokiirc --sendsms PhoneNumber
I tried to run other command and it doesn't work yet but if I select the "Email details of all matches" it works perfectly.
Can someone help me?
tnx
From zoneminder documentation
http://www.zoneminder.com/wiki/index.ph ... ing_Events :
must be written to a script eg. /var/www/htdocs/zm_sendsms.sh and and set it as executable
zm will use its full path /var/www/htdocs/zm_sendsms.sh , when an even occured (eg. from camera 1)
zm will call it as /var/www/htdocs/zm_sendsms.sh 1/nnn, where 1 is camera Id and nnn is the occuring Event Id
[/b]
http://www.zoneminder.com/wiki/index.ph ... ing_Events :
So your commandFinally you can also specify a script which is run on each matched event. This script should be readable and executable by your web server user. It will get run once per event and the relative path to the directory containing the event in question. Normally this will be of the form <MonitorName>/<EventId> so from this path you can derive both the monitor name and event id and perform any action you wish. Note that arbitrary commands are not allowed to be specified in the filter, for security the only thing it may contain is the full path to an executable. What that contains is entirely up to you however.
echo 'message here' | gnokii --config /etc/gnokiirc --sendsms PhoneNumber
must be written to a script eg. /var/www/htdocs/zm_sendsms.sh and and set it as executable
Code: Select all
chmod 755 /var/www/htdocs/zm_sendsms.sh
zm will call it as /var/www/htdocs/zm_sendsms.sh 1/nnn, where 1 is camera Id and nnn is the occuring Event Id
[/b]
I created /usr/share/zoneminder/zm_sendsms.sh
that contains
with 755 permissions
and created a filter:
images in alarm >= 1,
command to execute: "zm_sendsms.sh"
I tried also the full path /usr/share/zoneminder/zm_sendsms.sh but it doesn't work. Where is the mistake?
tnx
that contains
Code: Select all
echo 'message here' | gnokii --config /etc/gnokiirc --sendsms 38070xxxxx
and created a filter:
images in alarm >= 1,
command to execute: "zm_sendsms.sh"
I tried also the full path /usr/share/zoneminder/zm_sendsms.sh but it doesn't work. Where is the mistake?
tnx
Just to make sure that zm handle execute filter properly, could you please use simple script that write somethig to a file eg.
to replace zm_sendsms.sh temporaryly.
if /tmp/somefile.log really exists and contain the output of script above, then
maybe there something wrong with the zm_sendsms.sh or any commands in it.
Check /tmp/zmfilter.log when the Event triggering the filter, try
Code: Select all
#!/bin/sh
date > /tmp/somefile.log
echo "I was called as $@" >> /tmp/somefile.log
if /tmp/somefile.log really exists and contain the output of script above, then
maybe there something wrong with the zm_sendsms.sh or any commands in it.
Check /tmp/zmfilter.log when the Event triggering the filter, try
Code: Select all
tail -f /tmp/zmfilter.log
all i get with a test script is:
and the script is chmod 777, runnable by apache (and any other) user under shell and cgi.
and i triple-checked that i specified the command correctly various times. i put it in /tmp/ , in /, in zoneminders home, etc.
Code: Select all
03/16/08 23:32:15.654832 zmfilter[22022].ERR [Auto execute script '/tmp/zoneminderScript.pl' not found, skipping filter '_TempFilter1205731933']
and i triple-checked that i specified the command correctly various times. i put it in /tmp/ , in /, in zoneminders home, etc.
Created /tmp/somefile.log chmod 777
When an the event occurs it writes somefile.log correctly and exit normally. This is the log output:
03/27/08 19:09:04.581008 zmfilter[12060].DBG [Checking filter 'call', execute]
03/27/08 19:09:04.586316 zmfilter[12060].DBG [Checking event 1151]
03/27/08 19:09:04.586635 zmfilter[12060].INF [Executing '/usr/share/zoneminder/zm_sendsms.sh 8/1151']
03/27/08 19:09:04.589702 zmfilter[12060].DBG [Output: ]
But gnokii doesn't call me or send sms. Zoneminder requires a certain exit status?
Code: Select all
#!/bin/sh
/usr/bin/gnokii --config /etc/gnokiirc --dialvoice 38070xxxxx
date > /tmp/somefile.log
echo "I was called as $@" >> /tmp/somefile.log
03/27/08 19:09:04.581008 zmfilter[12060].DBG [Checking filter 'call', execute]
03/27/08 19:09:04.586316 zmfilter[12060].DBG [Checking event 1151]
03/27/08 19:09:04.586635 zmfilter[12060].INF [Executing '/usr/share/zoneminder/zm_sendsms.sh 8/1151']
03/27/08 19:09:04.589702 zmfilter[12060].DBG [Output: ]
But gnokii doesn't call me or send sms. Zoneminder requires a certain exit status?
Last edited by igor on Thu Mar 27, 2008 8:46 pm, edited 1 time in total.
From igor's zmfilter.log file, I am now sure that his zm installation is OK and as I presume before
that maybe some commands inside the script failed to run properly.
is webserver-user has access to the /etc/gnokiirc ?
Try to run the script as webserver-user (mine apache)
Is there any error messages ?
that maybe some commands inside the script failed to run properly.
is webserver-user has access to the /etc/gnokiirc ?
Try to run the script as webserver-user (mine apache)
Code: Select all
root ~# su - apache
apache ~$ /usr/bin/gnokii --config /etc/gnokiirc --dialvoice 3807016441