Added VERBOSE directive.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@251 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
d734f6c27a
commit
669abb72ac
|
@ -41,6 +41,7 @@ use constant DB_PASS => "zmadminzm";
|
||||||
use constant IMAGE_PATH => "@WEB_PREFIX@/images";
|
use constant IMAGE_PATH => "@WEB_PREFIX@/images";
|
||||||
use constant EVENT_PATH => "@WEB_PREFIX@/events";
|
use constant EVENT_PATH => "@WEB_PREFIX@/events";
|
||||||
use constant LOG_FILE => '/tmp/zmaudit.log';
|
use constant LOG_FILE => '/tmp/zmaudit.log';
|
||||||
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
|
@ -148,7 +149,7 @@ do
|
||||||
my $fs_monitors;
|
my $fs_monitors;
|
||||||
foreach my $monitor ( <*> )
|
foreach my $monitor ( <*> )
|
||||||
{
|
{
|
||||||
print( "Found filesystem monitor '$monitor'" );
|
print( "Found filesystem monitor '$monitor'" ) if ( VERBOSE );
|
||||||
my $fs_events = $fs_monitors->{$monitor} = {};
|
my $fs_events = $fs_monitors->{$monitor} = {};
|
||||||
( my $monitor_dir ) = ( $monitor =~ /^(.*)$/ ); # De-taint
|
( my $monitor_dir ) = ( $monitor =~ /^(.*)$/ ); # De-taint
|
||||||
chdir( $monitor_dir );
|
chdir( $monitor_dir );
|
||||||
|
@ -157,7 +158,7 @@ do
|
||||||
$fs_events->{$event} = !undef;
|
$fs_events->{$event} = !undef;
|
||||||
}
|
}
|
||||||
chdir( '..' );
|
chdir( '..' );
|
||||||
print( ", got ".int(keys(%$fs_events))." events\n" );
|
print( ", got ".int(keys(%$fs_events))." events\n" ) if ( VERBOSE );
|
||||||
}
|
}
|
||||||
|
|
||||||
my $db_monitors;
|
my $db_monitors;
|
||||||
|
@ -168,14 +169,14 @@ do
|
||||||
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
while( my $monitor = $sth->fetchrow_hashref() )
|
while( my $monitor = $sth->fetchrow_hashref() )
|
||||||
{
|
{
|
||||||
print( "Found database monitor '$monitor->{Name}'" );
|
print( "Found database monitor '$monitor->{Name}'" ) if ( VERBOSE );
|
||||||
my $db_events = $db_monitors->{$monitor->{Name}} = {};
|
my $db_events = $db_monitors->{$monitor->{Name}} = {};
|
||||||
my $res = $sth2->execute( $monitor->{Id} ) or die( "Can't execute: ".$sth2->errstr() );
|
my $res = $sth2->execute( $monitor->{Id} ) or die( "Can't execute: ".$sth2->errstr() );
|
||||||
while ( my $event = $sth2->fetchrow_hashref() )
|
while ( my $event = $sth2->fetchrow_hashref() )
|
||||||
{
|
{
|
||||||
$db_events->{$event->{Id}} = !undef;
|
$db_events->{$event->{Id}} = !undef;
|
||||||
}
|
}
|
||||||
print( ", got ".int(keys(%$db_events))." events\n" );
|
print( ", got ".int(keys(%$db_events))." events\n" ) if ( VERBOSE );
|
||||||
$sth2->finish();
|
$sth2->finish();
|
||||||
}
|
}
|
||||||
$sth->finish();
|
$sth->finish();
|
||||||
|
|
|
@ -37,6 +37,7 @@
|
||||||
use constant DAEMON_PATH => '@prefix@/bin/';
|
use constant DAEMON_PATH => '@prefix@/bin/';
|
||||||
use constant DC_SOCK_FILE => '/tmp/zmdc.sock';
|
use constant DC_SOCK_FILE => '/tmp/zmdc.sock';
|
||||||
use constant DC_LOG_FILE => '/tmp/zmdc.log';
|
use constant DC_LOG_FILE => '/tmp/zmdc.log';
|
||||||
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
|
|
|
@ -39,6 +39,7 @@ use constant ZM_SHM_KEY => 0x7a6d2000;
|
||||||
use constant EVENT_PATH => "@WEB_PREFIX@/events";
|
use constant EVENT_PATH => "@WEB_PREFIX@/events";
|
||||||
use constant FILTER_RELOAD_DELAY => 300; # How often filters are reloaded
|
use constant FILTER_RELOAD_DELAY => 300; # How often filters are reloaded
|
||||||
use constant LOG_FILE => '/tmp/zmfilter-%d.log';
|
use constant LOG_FILE => '/tmp/zmfilter-%d.log';
|
||||||
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
||||||
# Comment these out if you don't have them and don't want to upload
|
# Comment these out if you don't have them and don't want to upload
|
||||||
# or don't want to use that format
|
# or don't want to use that format
|
||||||
|
@ -162,19 +163,19 @@ while( 1 )
|
||||||
shmread( $shmid, $last_event_id, 12, 4 ) || die( "Can't read from shared memory: $!" );
|
shmread( $shmid, $last_event_id, 12, 4 ) || die( "Can't read from shared memory: $!" );
|
||||||
$last_event_id = unpack( "l", $last_event_id );
|
$last_event_id = unpack( "l", $last_event_id );
|
||||||
|
|
||||||
print( "Last event generated is $last_event_id\n" );
|
print( "Last event generated is $last_event_id\n" ) if ( VERBOSE );
|
||||||
if ( $last_event_id > $event_id )
|
if ( $last_event_id > $event_id )
|
||||||
{
|
{
|
||||||
# Got new event to check
|
# Got new event to check
|
||||||
if ( (time() - $last_action) > FILTER_RELOAD_DELAY )
|
if ( (time() - $last_action) > FILTER_RELOAD_DELAY )
|
||||||
{
|
{
|
||||||
print( "Reloading filters\n" );
|
print( "Reloading filters\n" ) if ( VERBOSE );
|
||||||
$last_action = time();
|
$last_action = time();
|
||||||
$filters = GetFilters( $monitor );
|
$filters = GetFilters( $monitor );
|
||||||
|
|
||||||
foreach my $filter ( @$filters )
|
foreach my $filter ( @$filters )
|
||||||
{
|
{
|
||||||
print( "Checking filter '$filter->{Name}'".($filter->{AutoDelete}?", delete":"").($filter->{AutoUpload}?", upload":"")."\n" );
|
print( "Checking filter '$filter->{Name}'".($filter->{AutoDelete}?", delete":"").($filter->{AutoUpload}?", upload":"")."\n" ) if ( VERBOSE );
|
||||||
my $sql = $filter->{Sql};
|
my $sql = $filter->{Sql};
|
||||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
my $res;
|
my $res;
|
||||||
|
@ -189,7 +190,7 @@ while( 1 )
|
||||||
|
|
||||||
while( my $event = $sth->fetchrow_hashref() )
|
while( my $event = $sth->fetchrow_hashref() )
|
||||||
{
|
{
|
||||||
print( "Checking event $event->{Id}\n" );
|
print( "Checking event $event->{Id}\n" ) if ( VERBOSE );
|
||||||
if ( $filter->{AutoUpload} )
|
if ( $filter->{AutoUpload} )
|
||||||
{
|
{
|
||||||
my $arch_file = FTP_LOC_DIR.$filter->{MonitorName}.'-'.$event->{Id};
|
my $arch_file = FTP_LOC_DIR.$filter->{MonitorName}.'-'.$event->{Id};
|
||||||
|
@ -250,7 +251,7 @@ while( 1 )
|
||||||
}
|
}
|
||||||
if ( $filter->{AutoDelete} )
|
if ( $filter->{AutoDelete} )
|
||||||
{
|
{
|
||||||
print( "Deleting event\n" );
|
print( "Deleting event $event->{Id}\n" );
|
||||||
# Do it individually to avoid locking up the table for new events
|
# Do it individually to avoid locking up the table for new events
|
||||||
my $sql = "delete from Events where Id = ?";
|
my $sql = "delete from Events where Id = ?";
|
||||||
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() );
|
||||||
|
@ -267,7 +268,7 @@ while( 1 )
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
print( "Sleeping for $delay seconds\n" );
|
print( "Sleeping for $delay seconds\n" ) if ( VERBOSE );
|
||||||
sleep( $delay );
|
sleep( $delay );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -282,7 +283,7 @@ sub GetFilters
|
||||||
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() );
|
||||||
FILTER: while( my $filter_data = $sth->fetchrow_hashref() )
|
FILTER: while( my $filter_data = $sth->fetchrow_hashref() )
|
||||||
{
|
{
|
||||||
print( "Found filter '$filter_data->{Name}'\n" );
|
print( "Found filter '$filter_data->{Name}'\n" ) if ( VERBOSE );
|
||||||
my %filter_terms;
|
my %filter_terms;
|
||||||
foreach my $filter_parm ( split( '&', $filter_data->{Query} ) )
|
foreach my $filter_parm ( split( '&', $filter_data->{Query} ) )
|
||||||
{
|
{
|
||||||
|
|
|
@ -40,6 +40,7 @@ use constant WATCH_LOG_FILE => '/tmp/zmwatch.log';
|
||||||
use constant CHECK_INTERVAL => 10; # How often to check the FPS
|
use constant CHECK_INTERVAL => 10; # How often to check the FPS
|
||||||
use constant NUM_BAD_CHECKS => 3; # How many bad checks before we restart
|
use constant NUM_BAD_CHECKS => 3; # How many bad checks before we restart
|
||||||
use constant MIN_FPS => 0.5; # FPS at or below this are bad
|
use constant MIN_FPS => 0.5; # FPS at or below this are bad
|
||||||
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
|
@ -93,10 +94,10 @@ while( 1 )
|
||||||
}
|
}
|
||||||
# Check we are getting a decent FPS, if not then kill it
|
# Check we are getting a decent FPS, if not then kill it
|
||||||
my $command = COMMAND_PATH."zmu -m ".$monitor->{Id}." -f";
|
my $command = COMMAND_PATH."zmu -m ".$monitor->{Id}." -f";
|
||||||
#print( "Getting FPS for monitor $monitor->{Id} ('$command')\n" );
|
print( "Getting FPS for monitor $monitor->{Id} ('$command')\n" ) if ( VERBOSE );
|
||||||
my $fps = qx( $command );
|
my $fps = qx( $command );
|
||||||
chomp($fps);
|
chomp($fps);
|
||||||
#print( "Monitor $monitor->{Id} capturing at $fps FPS\n" );
|
print( "Monitor $monitor->{Id} capturing at $fps FPS\n" ) if ( VERBOSE );
|
||||||
push( @$fps_list, $fps );
|
push( @$fps_list, $fps );
|
||||||
if ( @$fps_list > NUM_BAD_CHECKS )
|
if ( @$fps_list > NUM_BAD_CHECKS )
|
||||||
{
|
{
|
||||||
|
|
|
@ -41,6 +41,7 @@ use constant X10_SOCK_FILE => '/tmp/zmx10.sock';
|
||||||
use constant X10_LOG_FILE => '/tmp/zmx10.log';
|
use constant X10_LOG_FILE => '/tmp/zmx10.log';
|
||||||
use constant COMMAND_PATH => '@prefix@/bin/';
|
use constant COMMAND_PATH => '@prefix@/bin/';
|
||||||
use constant ZM_SHM_KEY => 0x7a6d2000;
|
use constant ZM_SHM_KEY => 0x7a6d2000;
|
||||||
|
use constant VERBOSE => 0; # Whether to output more verbose debug
|
||||||
|
|
||||||
# ==========================================================================
|
# ==========================================================================
|
||||||
#
|
#
|
||||||
|
@ -302,12 +303,12 @@ sub runServer
|
||||||
my $task_list;
|
my $task_list;
|
||||||
if ( $state == 1 && $monitor->{LastState} == 0 ) # Gone into alarm state
|
if ( $state == 1 && $monitor->{LastState} == 0 ) # Gone into alarm state
|
||||||
{
|
{
|
||||||
print( "Applying ON_list\n" );
|
print( "Applying ON_list\n" ) if ( VERBOSE );
|
||||||
$task_list = $monitor->{"ON_list"};
|
$task_list = $monitor->{"ON_list"};
|
||||||
}
|
}
|
||||||
elsif ( $state == 0 && $monitor->{LastState} > 0 ) # Come out of alarm state
|
elsif ( $state == 0 && $monitor->{LastState} > 0 ) # Come out of alarm state
|
||||||
{
|
{
|
||||||
print( "Applying OFF_list\n" );
|
print( "Applying OFF_list\n" ) if ( VERBOSE );
|
||||||
$task_list = $monitor->{"OFF_list"};
|
$task_list = $monitor->{"OFF_list"};
|
||||||
}
|
}
|
||||||
if ( $task_list )
|
if ( $task_list )
|
||||||
|
@ -355,7 +356,7 @@ sub addToDeviceList
|
||||||
my $function = shift;
|
my $function = shift;
|
||||||
my $limit = shift;
|
my $limit = shift;
|
||||||
|
|
||||||
#print( "Adding to device list, uc:$unit_code, ev:$event, mo:$monitor, fu:$function, li:$limit\n" );
|
print( "Adding to device list, uc:$unit_code, ev:$event, mo:$monitor, fu:$function, li:$limit\n" ) if ( VERBOSE );
|
||||||
my $device = $device_hash{$unit_code};
|
my $device = $device_hash{$unit_code};
|
||||||
if ( !$device )
|
if ( !$device )
|
||||||
{
|
{
|
||||||
|
@ -384,7 +385,7 @@ sub addToMonitorList
|
||||||
my $function = shift;
|
my $function = shift;
|
||||||
my $limit = shift;
|
my $limit = shift;
|
||||||
|
|
||||||
#print( "Adding to monitor list, uc:$unit_code, ev:$event, mo:$monitor, fu:$function, li:$limit\n" );
|
print( "Adding to monitor list, uc:$unit_code, ev:$event, mo:$monitor, fu:$function, li:$limit\n" ) if ( VERBOSE );
|
||||||
my $device = $device_hash{$unit_code};
|
my $device = $device_hash{$unit_code};
|
||||||
if ( !$device )
|
if ( !$device )
|
||||||
{
|
{
|
||||||
|
@ -409,7 +410,7 @@ sub loadTasks
|
||||||
{
|
{
|
||||||
%monitor_hash = ();
|
%monitor_hash = ();
|
||||||
|
|
||||||
#print( "Loading tasks\n" );
|
print( "Loading tasks\n" ) if ( VERBOSE );
|
||||||
# Clear out all old device task lists
|
# Clear out all old device task lists
|
||||||
foreach my $unit_code ( sort( keys(%device_hash) ) )
|
foreach my $unit_code ( sort( keys(%device_hash) ) )
|
||||||
{
|
{
|
||||||
|
@ -437,7 +438,7 @@ sub loadTasks
|
||||||
|
|
||||||
if ( $monitor->{Function} eq 'X10' && $monitor->{X10Activation} )
|
if ( $monitor->{Function} eq 'X10' && $monitor->{X10Activation} )
|
||||||
{
|
{
|
||||||
#print( "$monitor->{Name} has active string '$monitor->{X10Activation}'\n" );
|
print( "$monitor->{Name} has active string '$monitor->{X10Activation}'\n" ) if ( VERBOSE );
|
||||||
foreach my $code_string ( split( ',', $monitor->{X10Activation} ) )
|
foreach my $code_string ( split( ',', $monitor->{X10Activation} ) )
|
||||||
{
|
{
|
||||||
#print( "Code string: $code_string\n" );
|
#print( "Code string: $code_string\n" );
|
||||||
|
@ -458,7 +459,7 @@ sub loadTasks
|
||||||
}
|
}
|
||||||
if ( $monitor->{X10AlarmInput} )
|
if ( $monitor->{X10AlarmInput} )
|
||||||
{
|
{
|
||||||
#print( "$monitor->{Name} has alarm input string '$monitor->{X10AlarmInput}'\n" );
|
print( "$monitor->{Name} has alarm input string '$monitor->{X10AlarmInput}'\n" ) if ( VERBOSE );
|
||||||
foreach my $code_string ( split( ',', $monitor->{X10AlarmInput} ) )
|
foreach my $code_string ( split( ',', $monitor->{X10AlarmInput} ) )
|
||||||
{
|
{
|
||||||
#print( "Code string: $code_string\n" );
|
#print( "Code string: $code_string\n" );
|
||||||
|
@ -479,7 +480,7 @@ sub loadTasks
|
||||||
}
|
}
|
||||||
if ( $monitor->{X10AlarmOutput} )
|
if ( $monitor->{X10AlarmOutput} )
|
||||||
{
|
{
|
||||||
#print( "$monitor->{Name} has alarm output string '$monitor->{X10AlarmOutput}'\n" );
|
print( "$monitor->{Name} has alarm output string '$monitor->{X10AlarmOutput}'\n" ) if ( VERBOSE );
|
||||||
foreach my $code_string ( split( ',', $monitor->{X10AlarmOutput} ) )
|
foreach my $code_string ( split( ',', $monitor->{X10AlarmOutput} ) )
|
||||||
{
|
{
|
||||||
#print( "Code string: $code_string\n" );
|
#print( "Code string: $code_string\n" );
|
||||||
|
|
Loading…
Reference in New Issue