zmMemVerify always false in script (see FAQ)
Posted: Wed Jan 09, 2013 5:09 pm
Hi All,
Just upgraded to ZoneMinder 1.25 and my perl script which checks if monitors have alarmed no longer works.
using the example from the FAQ
First issue is zmDbgInit no longer exists, I commented this out and all seems to be ok.
Second issue is zmMemVerify is always false so it never actually checks if its alarms, if I comment that line out I get the following error :
Someone else asked this recently and didn't get an answer - http://www.zoneminder.com/forums/viewto ... mMemVerify
Any ideas?
thanks
Toby
Just upgraded to ZoneMinder 1.25 and my perl script which checks if monitors have alarmed no longer works.
using the example from the FAQ
Code: Select all
#!/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 ( !zmMemVerify( $monitor ) );
print( "Checking Monitor ".$monitor->{Name}."\n" );
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 );
}
Second issue is zmMemVerify is always false so it never actually checks if its alarms, if I comment that line out I get the following error :
Code: Select all
Use of uninitialized value $state in numeric eq (==) at /usr/share/perl5/ZoneMinder/Memory.pm line 497.
Use of uninitialized value $state in numeric eq (==) at /usr/share/perl5/ZoneMinder/Memory.pm line 497.
Use of uninitialized value $last_event_id in numeric ne (!=) at /usr/share/perl5/ZoneMinder/Memory.pm line 501.
Use of uninitialized value $last_event in numeric ne (!=) at /usr/share/perl5/ZoneMinder/Memory.pm line 501.
Any ideas?
thanks
Toby