diff --git a/scripts/zmaudit.pl.z b/scripts/zmaudit.pl.z index 720b6adb0..8cd1d0b8f 100755 --- a/scripts/zmaudit.pl.z +++ b/scripts/zmaudit.pl.z @@ -35,13 +35,17 @@ # These are the elements you need to edit to suit your installation # # ========================================================================== -use constant DB_NAME => "zm"; -use constant DB_NAME => "zm"; -use constant DB_USER => "zmadmin"; -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 ZM_DB_SERVER => ""; +use constant ZM_DB_NAME => ""; +use constant ZM_DB_USERA => ""; +use constant ZM_DB_PASSA => ""; +use constant ZM_DIR_IMAGES => ""; +use constant ZM_DIR_EVENTS => ""; +use constant ZM_PATH_LOGS => ""; + +use constant IMAGE_PATH => "@WEB_PREFIX@/".ZM_DIR_IMAGES; +use constant EVENT_PATH => "@WEB_PREFIX@/".ZM_DIR_EVENTS; +use constant LOG_FILE => ZM_PATH_LOGS.'/zmaudit.log'; use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== @@ -128,7 +132,7 @@ if ( $report && $yes ) usage(); } -my $dbh = DBI->connect( "DBI:mysql@".DB_SERVER.":".DB_NAME, DB_USER, DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql@".ZM_DB_SERVER.":".ZM_DB_NAME, ZM_DB_USERA, ZM_DB_PASSA ); chdir( EVENT_PATH ); if ( !$yes && !$report ) diff --git a/scripts/zmdc.pl.z b/scripts/zmdc.pl.z index ae22d7988..015b9bd2f 100755 --- a/scripts/zmdc.pl.z +++ b/scripts/zmdc.pl.z @@ -34,9 +34,11 @@ # # ========================================================================== +use constant ZM_PATH_LOGS => ""; + use constant DAEMON_PATH => '@prefix@/bin/'; use constant DC_SOCK_FILE => '/tmp/zmdc.sock'; -use constant DC_LOG_FILE => '/tmp/zmdc.log'; +use constant DC_LOG_FILE => ZM_PATH_LOGS.'/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 418de39d8..ac3348d77 100755 --- a/scripts/zmfilter.pl.z +++ b/scripts/zmfilter.pl.z @@ -32,33 +32,45 @@ use strict; # These are the elements you need to edit to suit your installation # # ========================================================================== -use constant DB_NAME => "zm"; -use constant DB_USER => "zmadmin"; -use constant DB_PASS => "zmadminzm"; -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 ZM_DB_SERVER => ""; +use constant ZM_DB_NAME => ""; +use constant ZM_DB_USERA => ""; +use constant ZM_DB_PASSA => ""; +use constant ZM_DIR_EVENTS => ""; +use constant ZM_PATH_LOGS => ""; +use constant ZM_SHM_KEY => ; +use constant ZM_FILTER_RELOAD_DELAY => ; +use constant ZM_OPT_UPLOAD => ; +use constant ZM_UPLOAD_ARCH_FORMAT => ; +use constant ZM_UPLOAD_ARCH_COMPRESS => ; +use constant ZM_UPLOAD_ARCH_ANALYSE => ; +use constant ZM_UPLOAD_FTP_HOST => ""; +use constant ZM_UPLOAD_FTP_USER => ""; +use constant ZM_UPLOAD_FTP_PASS => ""; +use constant ZM_UPLOAD_FTP_LOC_DIR => ""; +use constant ZM_UPLOAD_FTP_REM_DIR => ""; +use constant ZM_UPLOAD_FTP_TIMEOUT => ; +use constant ZM_UPLOAD_FTP_PASSIVE => ; +use constant ZM_UPLOAD_FTP_DEBUG => ; + +use constant EVENT_PATH => "@WEB_PREFIX@/".ZM_DIR_EVENTS; +use constant LOG_FILE => ZM_PATH_LOGS.'/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 -use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); -use Archive::Tar; -use Net::FTP; - -use constant ARCH_FORMAT => 'tar'; # This can be 'tar' or 'zip' -use constant ARCH_COMPRESS => '0'; # Whether to compress archive files -use constant ARCH_ANALYSE => '0'; # Whether to include the analysis files in the archive, bigger but slower - -use constant FTP_HOST => 'raq182.uk2net.com'; # Your ftp host -use constant FTP_USER => 'admin'; # Your ftp username -use constant FTP_PASS => 'n603mht'; # Your ftp password -use constant FTP_LOC_DIR => '/temp_data/'; # The local directory in which to create upload files -use constant FTP_REM_DIR => 'transfer/'; # The remote directory to upload to -use constant FTP_TIMEOUT => 120; # How long we allow the transfer to take for each file -use constant FTP_PASSIVE => 1; # Whether to use passive ftp -use constant FTP_DEBUG => 0; # Whether to switch ftp debugging on +if ( ZM_OPT_UPLOAD ) +{ + # Comment these out if you don't have them and don't want to upload + # or don't want to use that format + if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" ) + { + use Archive::Zip qw( :ERROR_CODES :CONSTANTS ); + } + else + { + use Archive::Tar; + } + use Net::FTP; +} # ========================================================================== # @@ -136,7 +148,7 @@ select( LOG ); $| = 1; chdir( EVENT_PATH ); -my $dbh = DBI->connect( "DBI:mysql:".DB_NAME, DB_USER, DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql@".ZM_DB_SERVER.":".ZM_DB_NAME, ZM_DB_USERA, ZM_DB_PASSA ); my $last_event_id; @@ -167,7 +179,7 @@ while( 1 ) if ( $last_event_id > $event_id ) { # Got new event to check - if ( (time() - $last_action) > FILTER_RELOAD_DELAY ) + if ( (time() - $last_action) > ZM_FILTER_RELOAD_DELAY ) { print( "Reloading filters\n" ) if ( VERBOSE ); $last_action = time(); @@ -191,15 +203,15 @@ while( 1 ) while( my $event = $sth->fetchrow_hashref() ) { print( "Checking event $event->{Id}\n" ) if ( VERBOSE ); - if ( $filter->{AutoUpload} ) + if ( ZM_OPT_UPLOAD && $filter->{AutoUpload} ) { next if ( $event->{Uploaded} ); - my $arch_file = FTP_LOC_DIR.$filter->{MonitorName}.'-'.$event->{Id}; - my $arch_image_path = "$filter->{MonitorName}/$event->{Id}/".(ARCH_ANALYSE?'*':'capture*').".jpg"; + my $arch_file = ZM_UPLOAD_FTP_LOC_DIR.'/'.$filter->{MonitorName}.'-'.$event->{Id}; + my $arch_image_path = "$filter->{MonitorName}/$event->{Id}/".(ZM_UPLOAD_ARCH_ANALYSE?'*':'capture*').".jpg"; my $arch_error; - if ( ARCH_FORMAT eq "zip" ) + if ( ZM_UPLOAD_ARCH_FORMAT eq "zip" ) { $arch_file .= '.zip'; my $zip = Archive::Zip->new(); @@ -211,7 +223,7 @@ while( 1 ) print( "Adding $image_file\n" ); my $member = $zip->addFile( $image_file ); last unless ( $member ); - $member->desiredCompressionMethod( ARCH_COMPRESS?COMPRESSION_DEFLATED:COMPRESSION_STORED ); + $member->desiredCompressionMethod( ZM_UPLOAD_ARCH_COMPRESS?COMPRESSION_DEFLATED:COMPRESSION_STORED ); } $status = $zip->writeToFileNamed( $arch_file ); @@ -220,9 +232,9 @@ while( 1 ) print( "Zip error: $status\n " ); } } - elsif ( ARCH_FORMAT eq "tar" ) + elsif ( ZM_UPLOAD_ARCH_FORMAT eq "tar" ) { - if ( ARCH_COMPRESS ) + if ( ZM_UPLOAD_ARCH_COMPRESS ) { $arch_file .= '.tar.gz'; } @@ -232,7 +244,7 @@ while( 1 ) } print( "Creating upload file '$arch_file'\n" ); - if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ARCH_COMPRESS, <*$arch_image_path> ) ) + if ( $arch_error = !Archive::Tar->create_archive( $arch_file, ZM_UPLOAD_ARCH_COMPRESS, <*$arch_image_path> ) ) { print( "Tar error: ".Archive::Tar->error()."\n " ); } @@ -241,11 +253,11 @@ while( 1 ) if ( !$arch_error ) { - print( "Uploading to ".FTP_HOST."\n" ); - my $ftp = Net::FTP->new( FTP_HOST, Timeout=>FTP_TIMEOUT, Passive=>FTP_PASSIVE, Debug=>FTP_DEBUG ); - $ftp->login( FTP_USER, FTP_PASS ) or warn( "FTP - Can't login" ); + print( "Uploading to ".ZM_UPLOAD_FTP_HOST."\n" ); + my $ftp = Net::FTP->new( ZM_UPLOAD_FTP_HOST, Timeout=>ZM_UPLOAD_FTP_TIMEOUT, Passive=>ZM_UPLOAD_FTP_PASSIVE, Debug=>ZM_UPLOAD_FTP_DEBUG ); + $ftp->login( ZM_UPLOAD_FTP_USER, ZM_UPLOAD_FTP_PASS ) or warn( "FTP - Can't login" ); $ftp->binary() or warn( "FTP - Can't go binary" ); - $ftp->cwd( FTP_REM_DIR ) or warn( "FTP - Can't cwd" ); + $ftp->cwd( ZM_UPLOAD_FTP_REM_DIR ) or warn( "FTP - Can't cwd" ); $ftp->put( $arch_file ) or warn( "FTP - Can't upload '$arch_file'" ); $ftp->quit() or warn( "FTP - Can't quit" ); unlink( $arch_file ); diff --git a/scripts/zmwatch.pl.z b/scripts/zmwatch.pl.z index 8912a9e98..57eb33479 100755 --- a/scripts/zmwatch.pl.z +++ b/scripts/zmwatch.pl.z @@ -32,14 +32,17 @@ # # ========================================================================== -use constant DB_NAME => "zm"; -use constant DB_USER => "zmadmin"; -use constant DB_PASS => "zmadminzm"; +use constant ZM_DB_SERVER => ""; +use constant ZM_DB_NAME => ""; +use constant ZM_DB_USERA => ""; +use constant ZM_DB_PASSA => ""; +use constant ZM_PATH_LOGS => ""; +use constant ZM_WATCH_CHECK_INTERVAL => ; +use constant ZM_WATCH_NUM_BAD_CHECKS => ; +use constant ZM_WATCH_MIN_FPS => ; + use constant COMMAND_PATH => '@prefix@/bin/'; -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 WATCH_LOG_FILE => ZM_PATH_LOGS.'/zmwatch.log'; use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== @@ -75,7 +78,7 @@ select( STDERR ); $| = 1; select( LOG ); $| = 1; print( "Watchdog starting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" ); -my $dbh = DBI->connect( "DBI:mysql@".DB_SERVER.":".DB_NAME, DB_USER, DB_PASS ); +my $dbh = DBI->connect( "DBI:mysql@".ZM_DB_SERVER.":".ZM_DB_NAME, ZM_DB_USERA, ZM_DB_PASSA ); my $sql = "select * from Monitors"; my $sth = $dbh->prepare_cached( $sql ) or die( "Can't prepare '$sql': ".$dbh->errstr() ); @@ -100,14 +103,14 @@ while( 1 ) chomp($fps); print( "Monitor $monitor->{Id} capturing at $fps FPS\n" ) if ( VERBOSE ); push( @$fps_list, $fps ); - if ( @$fps_list > NUM_BAD_CHECKS ) + if ( @$fps_list > ZM_WATCH_NUM_BAD_CHECKS ) { shift( @$fps_list ); # See if we can find any good FPS readings - my @good_fps = grep { $_ > MIN_FPS } @$fps_list; - if ( @good_fps < NUM_BAD_CHECKS ) + my @good_fps = grep { $_ > ZM_WATCH_MIN_FPS } @$fps_list; + if ( @good_fps < ZM_WATCH_NUM_BAD_CHECKS ) { - print( "Monitor $monitor->{Id} has ".(NUM_BAD_CHECKS-int(@good_fps))." samples below ".MIN_FPS." FPS\n" ); + print( "Monitor $monitor->{Id} has ".(ZM_WATCH_NUM_BAD_CHECKS-int(@good_fps))." samples below ".ZM_WATCH_MIN_FPS." FPS\n" ); } if ( @good_fps ) { @@ -121,7 +124,7 @@ while( 1 ) } } } - sleep( CHECK_INTERVAL ); + sleep( ZM_WATCH_CHECK_INTERVAL ); } print( "Watchdog exiting at ".strftime( '%y/%m/%d %H:%M:%S', localtime() )."\n" ); exit(); diff --git a/scripts/zmx10.pl.z b/scripts/zmx10.pl.z index 02c50c6a9..5b61879b4 100755 --- a/scripts/zmx10.pl.z +++ b/scripts/zmx10.pl.z @@ -31,16 +31,20 @@ # # ========================================================================== -use constant DB_NAME => "zm"; -use constant DB_USER => "zmadmin"; -use constant DB_PASS => "zmadminzm"; -use constant DB_RELOAD_INTERVAL => 60; -use constant X10_DEVICE => '/dev/ttyS1'; -use constant X10_HOUSE_CODE => 'K'; -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_DB_SERVER => ""; +use constant ZM_DB_NAME => ""; +use constant ZM_DB_USERA => ""; +use constant ZM_DB_PASSA => ""; +use constant ZM_DIR_EVENTS => ""; +use constant ZM_PATH_LOGS => ""; +use constant ZM_X10_DB_RELOAD_INTERVAL => 60; +use constant ZM_X10_DEVICE => '/dev/ttyS1'; +use constant ZM_X10_HOUSE_CODE => 'K'; use constant ZM_SHM_KEY => 0x7a6d2000; + +use constant X10_SOCK_FILE => '/tmp/zmx10.sock'; +use constant X10_LOG_FILE => ZM_PATH_LOGS.'/zmx10.log'; +use constant COMMAND_PATH => '@prefix@/bin/'; use constant VERBOSE => 0; # Whether to output more verbose debug # ========================================================================== @@ -168,9 +172,9 @@ sub runServer bind( SERVER, $saddr ) or die( "Can't bind: $!" ); listen( SERVER, SOMAXCONN ) or die( "Can't listen: $!" ); - $dbh = DBI->connect( "DBI:mysql@".DB_SERVER.":".DB_NAME, DB_USER, DB_PASS ); + $dbh = DBI->connect( "DBI:mysql@".ZM_DB_SERVER.":".ZM_DB_NAME, ZM_DB_USERA, ZM_DB_PASSA ); - $x10 = new X10::ActiveHome( port=>main::X10_DEVICE, house_code=>main::X10_HOUSE_CODE, debug=>1 ); + $x10 = new X10::ActiveHome( port=>main::ZM_X10_DEVICE, house_code=>main::ZM_X10_HOUSE_CODE, debug=>1 ); loadTasks(); @@ -183,7 +187,7 @@ sub runServer #print( "F:".fileno(SERVER)."\n" ); my $reload = undef; my $reload_count = 0; - my $reload_limit = main::DB_RELOAD_INTERVAL/$timeout; + my $reload_limit = main::ZM_X10_DB_RELOAD_INTERVAL/$timeout; while( 1 ) { my $nfound = select( my $rout = $rin, undef, undef, $timeout ); @@ -638,7 +642,7 @@ sub x10listen foreach my $event ( @_ ) { #print( Data::Dumper( $_ )."\n" ); - if ( $event->house_code() eq main::X10_HOUSE_CODE ) + if ( $event->house_code() eq main::ZM_X10_HOUSE_CODE ) { my $unit_code = $event->unit_code(); my $device = $device_hash{$unit_code};