ZoneMinder to trigger script

Forum for questions and support relating to the 1.24.x releases only.
Locked
acrohymn
Posts: 3
Joined: Tue Apr 28, 2009 8:20 am

ZoneMinder to trigger script

Post by acrohymn »

Hi there,

I have been trying to get an example perl monitor script working which I have had working on previous versions of zoneminder. On ZM 1.24.1 it seems to throw up the folowing error:-

Undefined subroutine &main::zmShmVerify

Knowing little about perl I can't sus the problem, At a guess the subroutine no longer exists or maybe shared memory is not being used. Can someone help diagnose or help with an equivalent script for 1.24.1

The perl script used is as follows:-

#!/usr/bin/perl -w

use strict;

use ZoneMinder;

$| = 1;

zmDbgInit( "myscript", level=>0, to_log=>0, to_syslog=>0, to_term=>1 );

my $dbh = DBI->connect( "DBI:mysql:database=".ZM_DB_NAME.";host=".ZM_DB_HOST, ZM_DB_USER, ZM_DB_PASS );

my $sql = "select M.*, max(E.Id) as LastEventId from Monitors as M left join Events as E on M.Id = E.MonitorId where M.Function != 'None' group by (M.Id)";
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );

my $res = $sth->execute() or die( "Can't execute '$sql': ".$sth->errstr() );
my @monitors;
while ( my $monitor = $sth->fetchrow_hashref() )
{
push( @monitors, $monitor );
}

while( 1 )
{
foreach my $monitor ( @monitors )
{
next if ( !zmShmVerify( $monitor ) );

if ( my $last_event_id = zmHasAlarmed( $monitor, $monitor->{LastEventId} ) )
{
$monitor->{LastEventId} = $last_event_id;
print( "Monitor ".$monitor->{Name}." has alarmed\n" );
#
# Do your stuff here
#
}
}
sleep( 1 );
}


Undefined subroutine &main::zmShmVerify called at /root/sms/zm-trigger.pl line 27

Many thanks,

John
RossFabricant
Posts: 3
Joined: Sat Sep 26, 2009 9:15 pm

Post by RossFabricant »

It appears that zmShmVerify has been replaced by zmMemVerify in a recent version of ZoneMinder, so if you just make that change it should work. You can read about the module by running:
perldoc ZoneMinder::Memory
Locked