diff --git a/scripts/zmaudit.pl.z b/scripts/zmaudit.pl.z index 09ea06e8a..7174a7764 100755 --- a/scripts/zmaudit.pl.z +++ b/scripts/zmaudit.pl.z @@ -41,6 +41,7 @@ use constant DB_PASS => "zmadminzm"; use constant IMAGE_PATH => "@WEB_PREFIX@/images"; use constant EVENT_PATH => "@WEB_PREFIX@/events"; 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; foreach my $monitor ( <*> ) { - print( "Found filesystem monitor '$monitor'" ); + print( "Found filesystem monitor '$monitor'" ) if ( VERBOSE ); my $fs_events = $fs_monitors->{$monitor} = {}; ( my $monitor_dir ) = ( $monitor =~ /^(.*)$/ ); # De-taint chdir( $monitor_dir ); @@ -157,7 +158,7 @@ do $fs_events->{$event} = !undef; } chdir( '..' ); - print( ", got ".int(keys(%$fs_events))." events\n" ); + print( ", got ".int(keys(%$fs_events))." events\n" ) if ( VERBOSE ); } my $db_monitors; @@ -168,14 +169,14 @@ do my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() ); 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 $res = $sth2->execute( $monitor->{Id} ) or die( "Can't execute: ".$sth2->errstr() ); while ( my $event = $sth2->fetchrow_hashref() ) { $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(); } $sth->finish(); diff --git a/scripts/zmdc.pl.z b/scripts/zmdc.pl.z index 8e940a7b3..80bc09304 100755 --- a/scripts/zmdc.pl.z +++ b/scripts/zmdc.pl.z @@ -37,6 +37,7 @@ use constant DAEMON_PATH => '@prefix@/bin/'; use constant DC_SOCK_FILE => '/tmp/zmdc.sock'; use constant DC_LOG_FILE => '/tmp/zmdc.log'; +use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== # diff --git a/scripts/zmfilter.pl.z b/scripts/zmfilter.pl.z index e63a5bfe3..5d339ed35 100755 --- a/scripts/zmfilter.pl.z +++ b/scripts/zmfilter.pl.z @@ -39,6 +39,7 @@ use constant ZM_SHM_KEY => 0x7a6d2000; use constant EVENT_PATH => "@WEB_PREFIX@/events"; use constant FILTER_RELOAD_DELAY => 300; # How often filters are reloaded 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 # 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: $!" ); $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 ) { # Got new event to check if ( (time() - $last_action) > FILTER_RELOAD_DELAY ) { - print( "Reloading filters\n" ); + print( "Reloading filters\n" ) if ( VERBOSE ); $last_action = time(); $filters = GetFilters( $monitor ); 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 $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); my $res; @@ -189,7 +190,7 @@ while( 1 ) while( my $event = $sth->fetchrow_hashref() ) { - print( "Checking event $event->{Id}\n" ); + print( "Checking event $event->{Id}\n" ) if ( VERBOSE ); if ( $filter->{AutoUpload} ) { my $arch_file = FTP_LOC_DIR.$filter->{MonitorName}.'-'.$event->{Id}; @@ -250,7 +251,7 @@ while( 1 ) } 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 my $sql = "delete from Events where Id = ?"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -267,7 +268,7 @@ while( 1 ) } else { - print( "Sleeping for $delay seconds\n" ); + print( "Sleeping for $delay seconds\n" ) if ( VERBOSE ); sleep( $delay ); } } @@ -282,7 +283,7 @@ sub GetFilters my $res = $sth->execute() or die( "Can't execute: ".$sth->errstr() ); 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; foreach my $filter_parm ( split( '&', $filter_data->{Query} ) ) { diff --git a/scripts/zmwatch.pl.z b/scripts/zmwatch.pl.z index b4080411b..b8166a4dc 100755 --- a/scripts/zmwatch.pl.z +++ b/scripts/zmwatch.pl.z @@ -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 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 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 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 ); 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 ); if ( @$fps_list > NUM_BAD_CHECKS ) { diff --git a/scripts/zmx10.pl.z b/scripts/zmx10.pl.z index 584b4a023..98ad74c25 100755 --- a/scripts/zmx10.pl.z +++ b/scripts/zmx10.pl.z @@ -41,6 +41,7 @@ use constant X10_SOCK_FILE => '/tmp/zmx10.sock'; use constant X10_LOG_FILE => '/tmp/zmx10.log'; use constant COMMAND_PATH => '@prefix@/bin/'; 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; 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"}; } 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"}; } if ( $task_list ) @@ -355,7 +356,7 @@ sub addToDeviceList my $function = 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}; if ( !$device ) { @@ -384,7 +385,7 @@ sub addToMonitorList my $function = 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}; if ( !$device ) { @@ -409,7 +410,7 @@ sub loadTasks { %monitor_hash = (); - #print( "Loading tasks\n" ); + print( "Loading tasks\n" ) if ( VERBOSE ); # Clear out all old device task lists foreach my $unit_code ( sort( keys(%device_hash) ) ) { @@ -437,7 +438,7 @@ sub loadTasks 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} ) ) { #print( "Code string: $code_string\n" ); @@ -458,7 +459,7 @@ sub loadTasks } 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} ) ) { #print( "Code string: $code_string\n" ); @@ -479,7 +480,7 @@ sub loadTasks } 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} ) ) { #print( "Code string: $code_string\n" );