Hi I have currently set up the zoneminder at home more or less successfully, but it suits my needs right now.
I'm thinking about extending the monitoring to my allotment, via LTE and OpenVPN capable router.
Since it's LTE I wouldn't like to transfer the data all the time (for understandable reasons) I know there is zmtrigger.pl so I thought I would setup a more or less constant OpenVPN tunnel, and setup the zmtrigger.pl to start and stop the monitor and recording all toghater.
Now the question is it possible to do it that way, i.e. is it possible to force the monitor to connect to the source on demand and start event recording?
Start remote capturing after an event
Re: Start remote capturing after an event
yes I think you can with zmtrigger.pl
Re: Start remote capturing after an event
For an example, I use wireless remote motion detectors that use X10 that are monitored by a cm19a usb X10 transceiver which is polled by a PERL daemon that sends the ON message through a SOCK to zmtrigger.pl turning on recording and activating an event in zoneminder. These cameras are set to NODECT but this will also trigger an event when the monitors (cameras) are set to MODECT also.
here is an example...this is all very simple code and there is a lot of room for improvement.
/usr/bin/zmusb12.pl
the controller for the daemon
/etc/init.d/zmusb12x
This can be done of course in PHP as well.
here is an example...this is all very simple code and there is a lot of room for improvement.
/usr/bin/zmusb12.pl
Code: Select all
#!/usr/bin/perl -w
use strict;
use warnings;
use autodie;
use IO::Socket::INET;
use LWP::UserAgent;
use Proc::Daemon;
my $continue = 1;
my $monitor = 2;
my ($socket);
Proc::Daemon::Init;
$SIG{TERM} = sub { $continue = 0 };
open (my $LOG, '>>', '/var/log/cm19a/cm19a.log');
select $LOG;
$| = 1;
print localtime()." Started zmusb12\r\n";
my $get_url = 'http://localhost:8008/?command=getqueue';
my $cmdon = $monitor.'|on+90|255|motion sensor|downstairs|motion sensor';
my $cmdoff = $monitor.'|off|0|||';
my $ua = LWP::UserAgent->new;
sub start_sock() {
$socket = new IO::Socket::INET (
PeerHost => 'localhost',
PeerPort => '6802',
Proto => 'tcp',
) or die "ERROR in Socket creation : $ !\n";
print "Connected to Socket \n";
}
sub run_cmdon() {
start_sock();
my $size = $socket->send($cmdon);
print "sent data ON: length $size\n";
print "----------------------------- \n";
shutdown($socket, 1);
}
sub run_cmdoff() {
start_sock();
my $size = $socket->send($cmdoff);
print "sent data OFF: length $size\n";
print "----------------------------- \n";
shutdown($socket, 1);
}
while($continue)
{
my $req = $ua->get($get_url);
my $html = $req->decoded_content;
if ($html !~ /Receive queue is empty/ ) {
print localtime()." $html\r";
if ($html =~ /A1ON/) { run_cmdon(); }
if ($html =~ /A1OFF/) { run_cmdoff(); }
$socket->close() if $socket;
}
sleep 1;
}
print localtime()." Stopped zmusb12\r\n";
/etc/init.d/zmusb12x
Code: Select all
#!/bin/sh
zmusb12_PID=/tmp/zmusb12.pid
function show_status {
if [ ! -f $zmusb12_PID ]; then
echo -e "ZMUSB12 NOTRUNNING"
exit 3
fi
PID=`cat ${zmusb12_PID}`
if [ ! -d /proc/${PID} &>/dev/null ]; then
echo -e "ZMUSB12 NOTRUNNING"
exit 1
fi
echo -e "ZMUSB12 RUNNING"
}
case "$1" in
start)
if [ -f /tmp/zmusb12.pid ]; then
PID=$(cat /tmp/zmusb12.pid)
kill -0 ${PID} &>/dev/null
if [ $? = 0 ]; then
echo "zmusb12 is already running."
else
/usr/bin/zmusb12.pl
pidof zmusb12.pl > /tmp/zmusb12.pid
PID=$(cat /tmp/zmusb12.pid)
kill -0 ${PID} &>/dev/null
if [ $? = 0 ]; then
echo "zmusb12 started succesfully."
else
echo "Error starting zmusb12"
fi
fi
else
/usr/bin/zmusb12.pl
pidof zmusb12.pl > /tmp/zmusb12.pid
PID=$(cat /tmp/zmusb12.pid)
kill -0 ${PID} &>/dev/null
if [ $? = 0 ]; then
echo "zmusb12 started succesfully."
else
echo "Error starting zmusb12"
fi
fi
;;
stop)
if [ -f /tmp/zmusb12.pid ];then
PID=$(cat /tmp/zmusb12.pid)
kill -0 ${PID} &>/dev/null
rm -f /tmp/zmusb12.pid
if [ $? = 0 ]; then
/bin/kill ${PID}
kill -0 ${PID} &>/dev/null
if [ $? = 0 ]; then
echo "zmusb12 stopped succesfully."
else
echo "Error stopping zmusb12"
fi
else
echo "zmusb12 is already stopped."
fi
else
echo "zmusb12 is already stopped."
fi
;;
reload|restart)
$0 stop
$0 start
;;
status)
show_status
;;
*)
echo "Usage: $0 start|stop|restart|reload|status"
exit 1
esac
exit 0
Re: Start remote capturing after an event
Thanks a lot, so just to clarify:
line like this
should put the monitor off, e.g. disconnect ffmpeg process from rtsp server, i.e. just kill it? (I'm new to zoneminder and I know I'm missing some basics, sorry for that, just trying to do some fun stuff in my spare time, and that doesn't come in aboundance...)
line like this
Code: Select all
$cmdoff = $monitor.'|off|0|||';