Merge branch 'storageareas' of github.com:ConnorTechnology/ZoneMinder into storageareas
This commit is contained in:
commit
2f9e69d959
|
@ -104,23 +104,23 @@ my @daemons = (
|
|||
'zmtelemetry.pl'
|
||||
);
|
||||
|
||||
if ($Config{ZM_OPT_USE_EVENTNOTIFICATION}) {
|
||||
push @daemons,'zmeventnotification.pl';
|
||||
if ( $Config{ZM_OPT_USE_EVENTNOTIFICATION} ) {
|
||||
push @daemons,'zmeventnotification.pl';
|
||||
}
|
||||
|
||||
my $command = shift @ARGV;
|
||||
if( ! $command ) {
|
||||
print( STDERR "No command given\n" );
|
||||
if ( !$command ) {
|
||||
print(STDERR "No command given\n");
|
||||
pod2usage(-exitstatus => -1);
|
||||
}
|
||||
if ( $command eq 'version' ) {
|
||||
print ZoneMinder::Base::ZM_VERSION."\n";
|
||||
exit( 0 );
|
||||
exit(0);
|
||||
}
|
||||
my $needs_daemon = $command !~ /(?:startup|shutdown|status|check|logrot|version)/;
|
||||
my $daemon = shift( @ARGV );
|
||||
my $daemon = shift @ARGV;
|
||||
if ( $needs_daemon && ! $daemon ) {
|
||||
print( STDERR "No daemon given\n" );
|
||||
print(STDERR "No daemon given\n");
|
||||
pod2usage(-exitstatus => -1);
|
||||
}
|
||||
my @args;
|
||||
|
@ -130,7 +130,7 @@ if ( $needs_daemon ) {
|
|||
if ( $daemon =~ /^${daemon_patt}$/ ) {
|
||||
$daemon = $1;
|
||||
} else {
|
||||
print( STDERR "Invalid daemon '$daemon' specified" );
|
||||
print(STDERR "Invalid daemon '$daemon' specified");
|
||||
pod2usage(-exitstatus => -1);
|
||||
}
|
||||
}
|
||||
|
@ -141,19 +141,19 @@ foreach my $arg ( @ARGV ) {
|
|||
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) {
|
||||
push( @args, $1 );
|
||||
} else {
|
||||
print( STDERR "Bogus argument '$arg' found" );
|
||||
exit( -1 );
|
||||
print(STDERR "Bogus argument '$arg' found");
|
||||
exit(-1);
|
||||
}
|
||||
}
|
||||
|
||||
my $dbh = zmDbConnect();
|
||||
|
||||
socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" );
|
||||
socket(CLIENT, PF_UNIX, SOCK_STREAM, 0) or Fatal("Can't open socket: $!");
|
||||
|
||||
my $saddr = sockaddr_un( SOCK_FILE );
|
||||
my $server_up = connect( CLIENT, $saddr );
|
||||
my $saddr = sockaddr_un(SOCK_FILE);
|
||||
my $server_up = connect(CLIENT, $saddr);
|
||||
|
||||
if ( ! $server_up ) {
|
||||
if ( !$server_up ) {
|
||||
if ( $Config{ZM_SERVER_ID} ) {
|
||||
use Sys::MemInfo qw(totalmem freemem totalswap freeswap);
|
||||
use ZoneMinder::Server qw(CpuLoad);
|
||||
|
@ -168,16 +168,16 @@ if ( ! $server_up ) {
|
|||
exit();
|
||||
}
|
||||
if ( $command eq 'check' ) {
|
||||
print( "stopped\n" );
|
||||
print("stopped\n");
|
||||
exit();
|
||||
} elsif ( $command ne 'startup' ) {
|
||||
print( "Unable to connect to server using socket at " . SOCK_FILE . "\n" );
|
||||
print("Unable to connect to server using socket at " . SOCK_FILE . "\n");
|
||||
exit( -1 );
|
||||
}
|
||||
|
||||
# The server isn't there
|
||||
print( "Starting server\n" );
|
||||
close( CLIENT );
|
||||
print("Starting server\n");
|
||||
close(CLIENT);
|
||||
|
||||
if ( my $cpid = fork() ) {
|
||||
# Parent process just sleep and fall through
|
||||
|
@ -185,7 +185,7 @@ if ( ! $server_up ) {
|
|||
# I'm still not sure why we need to re-init the logs
|
||||
logInit();
|
||||
|
||||
socket( CLIENT, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" );
|
||||
socket(CLIENT, PF_UNIX, SOCK_STREAM, 0) or Fatal("Can't open socket: $!");
|
||||
my $attempts = 0;
|
||||
while( !connect(CLIENT, $saddr) ) {
|
||||
$attempts++;
|
||||
|
@ -209,7 +209,6 @@ if ( ($command eq 'check') && !$daemon ) {
|
|||
}
|
||||
|
||||
# The server is there, connect to it
|
||||
#print( "Writing commands\n" );
|
||||
CLIENT->autoflush();
|
||||
my $message = join(';', $command, ( $daemon ? $daemon : () ), @args );
|
||||
print(CLIENT $message);
|
||||
|
@ -218,9 +217,7 @@ while( my $line = <CLIENT> ) {
|
|||
chomp($line);
|
||||
print("$line\n");
|
||||
}
|
||||
# And we're done!
|
||||
close(CLIENT);
|
||||
#print( "Finished writing, bye\n" );
|
||||
|
||||
exit;
|
||||
|
||||
|
@ -248,35 +245,35 @@ our %terminating_processes;
|
|||
|
||||
sub run {
|
||||
my $fd = 0;
|
||||
while( $fd < POSIX::sysconf( &POSIX::_SC_OPEN_MAX ) ) {
|
||||
POSIX::close( $fd++ );
|
||||
while( $fd < POSIX::sysconf(&POSIX::_SC_OPEN_MAX) ) {
|
||||
POSIX::close($fd++);
|
||||
}
|
||||
|
||||
setpgrp();
|
||||
|
||||
logInit();
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, 'Server starting at '
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||
dPrint(ZoneMinder::Logger::INFO, 'Server starting at '
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
|
||||
if ( open( my $PID, '>', ZM_PID ) ) {
|
||||
print( $PID $$ );
|
||||
close( $PID );
|
||||
if ( open(my $PID, '>', ZM_PID) ) {
|
||||
print($PID $$);
|
||||
close($PID);
|
||||
} else {
|
||||
Error( "Can't open pid file at " . ZM_PID );
|
||||
Error("Can't open pid file at " . ZM_PID);
|
||||
}
|
||||
|
||||
# Tell any existing processes to die, wait 1 second between TERM and KILL
|
||||
killAll( 1 );
|
||||
killAll(1);
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, 'Socket should be open at ' .main::SOCK_FILE );
|
||||
dPrint(ZoneMinder::Logger::INFO, 'Socket should be open at ' .main::SOCK_FILE);
|
||||
my $dbh = zmDbConnect(1);
|
||||
socket( SERVER, PF_UNIX, SOCK_STREAM, 0 ) or Fatal( "Can't open socket: $!" );
|
||||
unlink( main::SOCK_FILE ) or Error( 'Unable to unlink ' . main::SOCK_FILE .". Error message was: $!" ) if -e main::SOCK_FILE;
|
||||
bind( SERVER, $saddr ) or Fatal( "Can't bind to " . main::SOCK_FILE . ": $!" );
|
||||
listen( SERVER, SOMAXCONN ) or Fatal( "Can't listen: $!" );
|
||||
socket(SERVER, PF_UNIX, SOCK_STREAM, 0) or Fatal("Can't open socket: $!");
|
||||
unlink(main::SOCK_FILE) or Error('Unable to unlink ' . main::SOCK_FILE .". Error message was: $!") if -e main::SOCK_FILE;
|
||||
bind(SERVER, $saddr) or Fatal("Can't bind to " . main::SOCK_FILE . ": $!");
|
||||
listen(SERVER, SOMAXCONN) or Fatal("Can't listen: $!");
|
||||
|
||||
$SIG{CHLD} = \&reaper;
|
||||
$SIG{INT} = \&shutdownAll;
|
||||
|
@ -285,7 +282,7 @@ sub run {
|
|||
$SIG{HUP} = \&logrot;
|
||||
|
||||
my $rin = '';
|
||||
vec( $rin, fileno(SERVER), 1 ) = 1;
|
||||
vec($rin, fileno(SERVER), 1) = 1;
|
||||
my $win = $rin;
|
||||
my $ein = $win;
|
||||
my $timeout = 1;
|
||||
|
@ -294,8 +291,8 @@ sub run {
|
|||
|
||||
if ( $Config{ZM_SERVER_ID} ) {
|
||||
require ZoneMinder::Server;
|
||||
$Server = new ZoneMinder::Server( $Config{ZM_SERVER_ID} );
|
||||
dPrint( ZoneMinder::Logger::INFO, 'Loading Server record have ' . $$Server{Name} );
|
||||
$Server = new ZoneMinder::Server($Config{ZM_SERVER_ID});
|
||||
dPrint(ZoneMinder::Logger::INFO, 'Loading Server record have ' . $$Server{Name});
|
||||
}
|
||||
|
||||
while( 1 ) {
|
||||
|
@ -311,41 +308,41 @@ sub run {
|
|||
}
|
||||
$secs_count += 1;
|
||||
}
|
||||
my $nfound = select( my $rout = $rin, undef, undef, $timeout );
|
||||
my $nfound = select(my $rout = $rin, undef, undef, $timeout);
|
||||
if ( $nfound > 0 ) {
|
||||
if ( vec( $rout, fileno(SERVER), 1 ) ) {
|
||||
my $paddr = accept( CLIENT, SERVER );
|
||||
if ( vec($rout, fileno(SERVER), 1) ) {
|
||||
my $paddr = accept(CLIENT, SERVER);
|
||||
my $message = <CLIENT>;
|
||||
|
||||
next if !$message;
|
||||
|
||||
my ( $command, $daemon, @args ) = split( /;/, $message );
|
||||
my ( $command, $daemon, @args ) = split(';', $message);
|
||||
|
||||
if ( $command eq 'start' ) {
|
||||
start( $daemon, @args );
|
||||
start($daemon, @args);
|
||||
} elsif ( $command eq 'stop' ) {
|
||||
stop( $daemon, @args );
|
||||
stop($daemon, @args);
|
||||
} elsif ( $command eq 'restart' ) {
|
||||
restart( $daemon, @args );
|
||||
restart($daemon, @args);
|
||||
} elsif ( $command eq 'reload' ) {
|
||||
reload( $daemon, @args );
|
||||
reload($daemon, @args);
|
||||
} elsif ( $command eq 'startup' ) {
|
||||
# Do nothing, this is all we're here for
|
||||
dPrint( ZoneMinder::Logger::WARNING, "Already running, ignoring command '$command'\n" );
|
||||
dPrint(ZoneMinder::Logger::WARNING, "Already running, ignoring command '$command'\n");
|
||||
} elsif ( $command eq 'shutdown' ) {
|
||||
shutdownAll();
|
||||
} elsif ( $command eq 'check' ) {
|
||||
check( $daemon, @args );
|
||||
check($daemon, @args);
|
||||
} elsif ( $command eq 'status' ) {
|
||||
if ( $daemon ) {
|
||||
status( $daemon, @args );
|
||||
status($daemon, @args);
|
||||
} else {
|
||||
status();
|
||||
}
|
||||
} elsif ( $command eq 'logrot' ) {
|
||||
logrot();
|
||||
} else {
|
||||
dPrint( ZoneMinder::Logger::ERROR, "Invalid command '$command'\n" );
|
||||
dPrint(ZoneMinder::Logger::ERROR, "Invalid command '$command'\n");
|
||||
}
|
||||
close(CLIENT);
|
||||
} else {
|
||||
|
@ -370,18 +367,18 @@ sub run {
|
|||
check_for_processes_to_kill();
|
||||
|
||||
} # end while
|
||||
dPrint( ZoneMinder::Logger::INFO, 'Server exiting at '
|
||||
dPrint(ZoneMinder::Logger::INFO, 'Server exiting at '
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||
."\n"
|
||||
);
|
||||
if ( $Config{ZM_SERVER_ID} ) {
|
||||
$dbh = zmDbConnect() if ! $dbh->ping();
|
||||
if ( ! defined $dbh->do(q{UPDATE Servers SET Status='NotRunning' WHERE Id=?}, undef, $Config{ZM_SERVER_ID} ) ) {
|
||||
if ( ! defined $dbh->do(q{UPDATE Servers SET Status='NotRunning' WHERE Id=?}, undef, $Config{ZM_SERVER_ID}) ) {
|
||||
Error("Failed Updating status of Server record for Id=$Config{ZM_SERVER_ID}".$dbh->errstr());
|
||||
}
|
||||
}
|
||||
unlink( main::SOCK_FILE ) or Error( 'Unable to unlink ' . main::SOCK_FILE .". Error message was: $!" ) if ( -e main::SOCK_FILE );
|
||||
unlink( ZM_PID ) or Error( 'Unable to unlink ' . ZM_PID .". Error message was: $!" ) if ( -e ZM_PID );
|
||||
unlink(main::SOCK_FILE) or Error('Unable to unlink ' . main::SOCK_FILE .". Error message was: $!") if ( -e main::SOCK_FILE );
|
||||
unlink(ZM_PID) or Error('Unable to unlink ' . ZM_PID .". Error message was: $!") if ( -e ZM_PID );
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -398,15 +395,15 @@ sub dPrint {
|
|||
print CLIENT @_
|
||||
}
|
||||
if ( $logLevel == ZoneMinder::Logger::DEBUG ) {
|
||||
Debug( @_ );
|
||||
Debug(@_);
|
||||
} elsif ( $logLevel == ZoneMinder::Logger::INFO ) {
|
||||
Info( @_ );
|
||||
Info(@_);
|
||||
} elsif ( $logLevel == ZoneMinder::Logger::WARNING ) {
|
||||
Warning( @_ );
|
||||
Warning(@_);
|
||||
} elsif ( $logLevel == ZoneMinder::Logger::ERROR ) {
|
||||
Error( @_ );
|
||||
Error(@_);
|
||||
} elsif ( $logLevel == ZoneMinder::Logger::FATAL ) {
|
||||
Fatal( @_ );
|
||||
Fatal(@_);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -414,61 +411,60 @@ sub start {
|
|||
my $daemon = shift;
|
||||
my @args = @_;
|
||||
|
||||
my $command = join(' ', $daemon, @args );
|
||||
my $command = join(' ', $daemon, @args);
|
||||
my $process = $cmd_hash{$command};
|
||||
|
||||
if ( !$process ) {
|
||||
# It's not running, or at least it's not been started by us
|
||||
$process = { daemon=>$daemon, args=>\@args, command=>$command, keepalive=>!undef };
|
||||
} elsif ( $process->{pid} && $pid_hash{$process->{pid}} ) {
|
||||
dPrint( ZoneMinder::Logger::INFO, "'$process->{command}' already running at "
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) )
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$process->{command}' already running at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
|
||||
.", pid = $process->{pid}\n"
|
||||
);
|
||||
return();
|
||||
return;
|
||||
}
|
||||
|
||||
my $sigset = POSIX::SigSet->new;
|
||||
my $blockset = POSIX::SigSet->new( SIGCHLD );
|
||||
sigprocmask( SIG_BLOCK, $blockset, $sigset ) or Fatal( "Can't block SIGCHLD: $!" );
|
||||
sigprocmask(SIG_BLOCK, $blockset, $sigset) or Fatal("Can't block SIGCHLD: $!");
|
||||
if ( my $cpid = fork() ) {
|
||||
logReinit();
|
||||
|
||||
$process->{pid} = $cpid;
|
||||
$process->{started} = time();
|
||||
delete( $process->{pending} );
|
||||
delete $process->{pending};
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, "'$command' starting at "
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime( $process->{started}) )
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$command' starting at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime($process->{started}))
|
||||
.", pid = $process->{pid}\n"
|
||||
);
|
||||
|
||||
$cmd_hash{$process->{command}} = $pid_hash{$cpid} = $process;
|
||||
sigprocmask( SIG_SETMASK, $sigset ) or Fatal( "Can't restore SIGCHLD: $!" );
|
||||
} elsif ( defined($cpid ) ) {
|
||||
sigprocmask(SIG_SETMASK, $sigset) or Fatal("Can't restore SIGCHLD: $!");
|
||||
} elsif ( defined($cpid) ) {
|
||||
# Force reconnection to the db.
|
||||
$dbh = zmDbConnect(1);
|
||||
logReinit();
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, "'".join( ' ', ( $daemon, @args ) )
|
||||
."' started at "
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$command' started at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
|
||||
if ( $daemon =~ /^${daemon_patt}$/ ) {
|
||||
$daemon = $Config{ZM_PATH_BIN}.'/'.$1;
|
||||
} else {
|
||||
Fatal( "Invalid daemon '$daemon' specified" );
|
||||
Fatal("Invalid daemon '$daemon' specified");
|
||||
}
|
||||
|
||||
my @good_args;
|
||||
foreach my $arg ( @args ) {
|
||||
# Detaint arguments, if they look ok
|
||||
if ( $arg =~ /^(-{0,2}[\w\/?&=.-]+)$/ ) {
|
||||
push( @good_args, $1 );
|
||||
push @good_args, $1;
|
||||
} else {
|
||||
Fatal( "Bogus argument '$arg' found" );
|
||||
Fatal("Bogus argument '$arg' found");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -476,8 +472,8 @@ sub start {
|
|||
zmDbDisconnect();
|
||||
|
||||
my $fd = 0;
|
||||
while( $fd < POSIX::sysconf( &POSIX::_SC_OPEN_MAX ) ) {
|
||||
POSIX::close( $fd++ );
|
||||
while( $fd < POSIX::sysconf(&POSIX::_SC_OPEN_MAX) ) {
|
||||
POSIX::close($fd++);
|
||||
}
|
||||
|
||||
# Child process
|
||||
|
@ -486,11 +482,11 @@ sub start {
|
|||
$SIG{TERM} = 'DEFAULT';
|
||||
$SIG{ABRT} = 'DEFAULT';
|
||||
|
||||
exec( $daemon, @good_args ) or Fatal( "Can't exec: $!" );
|
||||
exec($daemon, @good_args) or Fatal("Can't exec: $!");
|
||||
} else {
|
||||
Fatal( "Can't fork: $!" );
|
||||
Fatal("Can't fork: $!");
|
||||
}
|
||||
}
|
||||
} # end sub start
|
||||
|
||||
# Sends the stop signal, without waiting around to see if the process died.
|
||||
sub send_stop {
|
||||
|
@ -499,9 +495,9 @@ sub send_stop {
|
|||
my $command = $process->{command};
|
||||
if ( $process->{pending} ) {
|
||||
|
||||
delete( $cmd_hash{$command} );
|
||||
dPrint( ZoneMinder::Logger::INFO, "Command '$command' removed from pending list at "
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||
delete $cmd_hash{$command};
|
||||
dPrint(ZoneMinder::Logger::INFO, "Command '$command' removed from pending list at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
return();
|
||||
|
@ -509,12 +505,12 @@ sub send_stop {
|
|||
|
||||
my $pid = $process->{pid};
|
||||
if ( !$pid_hash{$pid} ) {
|
||||
dPrint( ZoneMinder::Logger::ERROR, "No process with command of '$command' pid $pid is running\n" );
|
||||
dPrint(ZoneMinder::Logger::ERROR, "No process with command of '$command' pid $pid is running\n");
|
||||
return();
|
||||
}
|
||||
|
||||
dPrint( ZoneMinder::Logger::INFO, "'$command' sending stop to pid $pid at "
|
||||
.strftime( '%y/%m/%d %H:%M:%S', localtime() )
|
||||
dPrint(ZoneMinder::Logger::INFO, "'$command' sending stop to pid $pid at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
$process->{keepalive} = !$final;
|
||||
|
@ -522,8 +518,7 @@ sub send_stop {
|
|||
$process->{pending} = 0;
|
||||
$terminating_processes{$command} = $process;
|
||||
|
||||
|
||||
kill( 'TERM', $pid );
|
||||
kill('TERM', $pid);
|
||||
return $pid;
|
||||
} # end sub send_stop
|
||||
|
||||
|
@ -531,9 +526,10 @@ sub check_for_processes_to_kill {
|
|||
# Turn off SIGCHLD
|
||||
my $sigset = POSIX::SigSet->new;
|
||||
my $blockset = POSIX::SigSet->new(SIGCHLD);
|
||||
sigprocmask(SIG_BLOCK, $blockset, $sigset ) or die "dying at block...\n";
|
||||
sigprocmask(SIG_BLOCK, $blockset, $sigset) or die "dying at block...\n";
|
||||
foreach my $command ( %terminating_processes ) {
|
||||
my $process = $cmd_hash{$command};
|
||||
Debug("Have process $command at pid $$process{pid} $$process{term_sent_at}");
|
||||
if ( $$process{term_sent_at} - time > KILL_DELAY ) {
|
||||
dPrint(ZoneMinder::Logger::WARNING, "'$$process{command}' has not stopped at "
|
||||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
|
@ -551,11 +547,11 @@ sub stop {
|
|||
my $command = join(' ', $daemon, @args );
|
||||
my $process = $cmd_hash{$command};
|
||||
if ( !$process ) {
|
||||
dPrint( ZoneMinder::Logger::WARNING, "Can't find process with command of '$command'\n" );
|
||||
dPrint(ZoneMinder::Logger::WARNING, "Can't find process with command of '$command'\n");
|
||||
return;
|
||||
}
|
||||
|
||||
send_stop( 1, $process );
|
||||
send_stop(1, $process);
|
||||
}
|
||||
|
||||
# restart is the same as stop, except that we flag the processes for restarting once it dies
|
||||
|
@ -563,7 +559,7 @@ sub stop {
|
|||
sub restart {
|
||||
my ( $daemon, @args ) = @_;
|
||||
|
||||
my $command = join(' ', $daemon, @args );
|
||||
my $command = join(' ', $daemon, @args);
|
||||
dPrint(ZoneMinder::Logger::DEBUG, "Restarting $command\n");
|
||||
my $process = $cmd_hash{$command};
|
||||
if ( !$process ) {
|
||||
|
@ -580,7 +576,7 @@ sub reload {
|
|||
my $daemon = shift;
|
||||
my @args = @_;
|
||||
|
||||
my $command = join(' ', $daemon, @args ) ;
|
||||
my $command = join(' ', $daemon, @args);
|
||||
my $process = $cmd_hash{$command};
|
||||
if ( $process ) {
|
||||
if ( $process->{pid} ) {
|
||||
|
@ -591,7 +587,7 @@ sub reload {
|
|||
|
||||
sub logrot {
|
||||
logReinit();
|
||||
foreach my $process ( values(%pid_hash) ) {
|
||||
foreach my $process ( values %pid_hash ) {
|
||||
if ( $process->{pid} ) {
|
||||
# && $process->{command} =~ /^zm.*\.pl/ ) {
|
||||
kill('HUP', $process->{pid});
|
||||
|
@ -601,14 +597,14 @@ sub logrot {
|
|||
|
||||
sub reaper {
|
||||
my $saved_status = $!;
|
||||
while ( (my $cpid = waitpid( -1, WNOHANG )) > 0 ) {
|
||||
while ( (my $cpid = waitpid(-1, WNOHANG)) > 0 ) {
|
||||
my $status = $?;
|
||||
|
||||
my $process = $pid_hash{$cpid};
|
||||
delete $pid_hash{$cpid};
|
||||
|
||||
if ( !$process ) {
|
||||
dPrint( ZoneMinder::Logger::INFO, "Can't find child with pid of '$cpid'\n" );
|
||||
dPrint(ZoneMinder::Logger::INFO, "Can't find child with pid of '$cpid'\n");
|
||||
next;
|
||||
}
|
||||
delete $terminating_processes{$$process{command}};
|
||||
|
@ -643,9 +639,9 @@ sub reaper {
|
|||
$out_str .= "\n";
|
||||
|
||||
if ( $exit_status == 0 ) {
|
||||
Info( $out_str );
|
||||
Info($out_str);
|
||||
} else {
|
||||
Error( $out_str );
|
||||
Error($out_str);
|
||||
}
|
||||
|
||||
if ( $process->{keepalive} ) {
|
||||
|
@ -685,7 +681,7 @@ sub shutdownAll {
|
|||
foreach my $pid ( keys %pid_hash ) {
|
||||
# This is a quick fix because a SIGCHLD can happen and alter pid_hash while we are in here.
|
||||
next if ! $pid_hash{$pid};
|
||||
send_stop( 1, $pid_hash{$pid} );
|
||||
send_stop(1, $pid_hash{$pid});
|
||||
}
|
||||
while ( %terminating_processes ) {
|
||||
check_for_processes_to_kill();
|
||||
|
@ -695,10 +691,10 @@ sub shutdownAll {
|
|||
.strftime('%y/%m/%d %H:%M:%S', localtime())
|
||||
."\n"
|
||||
);
|
||||
unlink( main::SOCK_FILE ) or Error( "Unable to unlink " . main::SOCK_FILE .". Error message was: $!" ) if ( -e main::SOCK_FILE );
|
||||
unlink( ZM_PID ) or Error( "Unable to unlink " . ZM_PID .". Error message was: $!" ) if ( -e ZM_PID );
|
||||
close( CLIENT );
|
||||
close( SERVER );
|
||||
unlink(main::SOCK_FILE) or Error("Unable to unlink " . main::SOCK_FILE .". Error message was: $!") if ( -e main::SOCK_FILE );
|
||||
unlink(ZM_PID) or Error("Unable to unlink " . ZM_PID .". Error message was: $!") if ( -e ZM_PID );
|
||||
close(CLIENT);
|
||||
close(SERVER);
|
||||
exit();
|
||||
}
|
||||
|
||||
|
@ -706,18 +702,18 @@ sub check {
|
|||
my $daemon = shift;
|
||||
my @args = @_;
|
||||
|
||||
my $command = join( ' ', $daemon, @args );
|
||||
my $command = join(' ', $daemon, @args);
|
||||
my $process = $cmd_hash{$command};
|
||||
if ( !$process ) {
|
||||
cPrint( "unknown\n" );
|
||||
cPrint("unknown\n");
|
||||
} elsif ( $process->{pending} ) {
|
||||
cPrint( "pending\n" );
|
||||
cPrint("pending\n");
|
||||
} else {
|
||||
my $cpid = $process->{pid};
|
||||
if ( ! $pid_hash{$cpid} ) {
|
||||
cPrint( "stopped\n" );
|
||||
cPrint("stopped\n");
|
||||
} else {
|
||||
cPrint( "running\n" );
|
||||
cPrint("running\n");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -785,14 +781,14 @@ sub killAll {
|
|||
}
|
||||
foreach my $daemon ( @daemons ) {
|
||||
my $cmd = $killall ."TERM $daemon";
|
||||
Debug( $cmd );
|
||||
qx( $cmd );
|
||||
Debug($cmd);
|
||||
qx($cmd);
|
||||
}
|
||||
sleep( $delay );
|
||||
sleep($delay);
|
||||
foreach my $daemon ( @daemons ) {
|
||||
my $cmd = $killall."KILL $daemon";
|
||||
Debug( $cmd );
|
||||
qx( $cmd );
|
||||
Debug($cmd);
|
||||
qx($cmd);
|
||||
}
|
||||
}
|
||||
1;
|
||||
|
|
|
@ -595,19 +595,19 @@ bool Monitor::connect() {
|
|||
Debug(3,"Aligning shared memory images to the next 64 byte boundary");
|
||||
shared_images = (uint8_t*)((unsigned long)shared_images + (64 - ((unsigned long)shared_images % 64)));
|
||||
}
|
||||
Debug(3, "Allocating %d image buffers", image_buffer_count );
|
||||
image_buffer = new Snapshot[image_buffer_count];
|
||||
for ( int i = 0; i < image_buffer_count; i++ ) {
|
||||
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
||||
}
|
||||
if ( (deinterlacing & 0xff) == 4) {
|
||||
/* Four field motion adaptive deinterlacing in use */
|
||||
/* Allocate a buffer for the next image */
|
||||
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
next_buffer.timestamp = new struct timeval;
|
||||
}
|
||||
Debug(3, "Allocating %d image buffers", image_buffer_count );
|
||||
image_buffer = new Snapshot[image_buffer_count];
|
||||
for ( int i = 0; i < image_buffer_count; i++ ) {
|
||||
image_buffer[i].timestamp = &(shared_timestamps[i]);
|
||||
image_buffer[i].image = new Image( width, height, camera->Colours(), camera->SubpixelOrder(), &(shared_images[i*camera->ImageSize()]) );
|
||||
image_buffer[i].image->HoldBuffer(true); /* Don't release the internal buffer or replace it with another */
|
||||
}
|
||||
if ( (deinterlacing & 0xff) == 4) {
|
||||
/* Four field motion adaptive deinterlacing in use */
|
||||
/* Allocate a buffer for the next image */
|
||||
next_buffer.image = new Image( width, height, camera->Colours(), camera->SubpixelOrder());
|
||||
next_buffer.timestamp = new struct timeval;
|
||||
}
|
||||
if ( ( purpose == ANALYSIS ) && analysis_fps ) {
|
||||
// Size of pre event buffer must be greater than pre_event_count
|
||||
// if alarm_frame_count > 1, because in this case the buffer contains
|
||||
|
@ -834,7 +834,7 @@ double Monitor::GetFPS() const {
|
|||
Snapshot *snap1 = &image_buffer[index1];
|
||||
if ( !snap1->timestamp || !snap1->timestamp->tv_sec ) {
|
||||
// This should be impossible
|
||||
Warning("Impossible situation. No timestamp on captured image");
|
||||
Warning("Impossible situation. No timestamp on captured image index was %d, image-buffer_count was (%d)", index1, image_buffer_count);
|
||||
return 0.0;
|
||||
}
|
||||
struct timeval time1 = *snap1->timestamp;
|
||||
|
|
|
@ -21,6 +21,7 @@
|
|||
#include "zm_rtsp_auth.h"
|
||||
|
||||
#include "zm_mem_utils.h"
|
||||
#include "zm_signal.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/socket.h>
|
||||
|
@ -192,24 +193,24 @@ int RemoteCameraHttp::ReadData( Buffer &buffer, unsigned int bytes_expected ) {
|
|||
|
||||
struct timeval temp_timeout = timeout;
|
||||
|
||||
int n_found = select( sd+1, &rfds, NULL, NULL, &temp_timeout );
|
||||
int n_found = select(sd+1, &rfds, NULL, NULL, &temp_timeout);
|
||||
if( n_found == 0 ) {
|
||||
Debug( 4, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec );
|
||||
Debug( 1, "Select timed out timeout was %d secs %d usecs", temp_timeout.tv_sec, temp_timeout.tv_usec );
|
||||
int error = 0;
|
||||
socklen_t len = sizeof (error);
|
||||
int retval = getsockopt (sd, SOL_SOCKET, SO_ERROR, &error, &len);
|
||||
if(retval != 0 ) {
|
||||
Debug( 1, "error getting socket error code %s", strerror(retval) );
|
||||
}
|
||||
if (error != 0) {
|
||||
if (error != 0 ) {
|
||||
return -1;
|
||||
}
|
||||
// Why are we disconnecting? It's just a timeout, meaning that data wasn't available.
|
||||
//Disconnect();
|
||||
return( 0 );
|
||||
return 0;
|
||||
} else if ( n_found < 0) {
|
||||
Error( "Select error: %s", strerror(errno) );
|
||||
return( -1 );
|
||||
Error("Select error: %s", strerror(errno));
|
||||
return -1;
|
||||
}
|
||||
|
||||
unsigned int total_bytes_to_read = 0;
|
||||
|
@ -309,13 +310,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
static RegExpr *content_length_expr = 0;
|
||||
static RegExpr *content_type_expr = 0;
|
||||
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for REGEXP HEADER");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read header data" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
if ( !header_expr )
|
||||
header_expr = new RegExpr( "^(.+?\r?\n\r?\n)", PCRE_DOTALL );
|
||||
if ( header_expr->Match( (char*)buffer, buffer.size() ) == 2 )
|
||||
|
@ -483,13 +485,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
else
|
||||
{
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting to extract subheader");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to extract subheader data" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -522,13 +525,16 @@ int RemoteCameraHttp::GetResponse()
|
|||
|
||||
if ( content_length )
|
||||
{
|
||||
while ( (long)buffer.size() < content_length )
|
||||
while ( ((long)buffer.size() < content_length ) && ! zm_terminate )
|
||||
{
|
||||
Debug(3, "Need more data buffer %d < content length %d", buffer.size(), content_length );
|
||||
if ( ReadData( buffer ) < 0 ) {
|
||||
int bytes_read = ReadData( buffer );
|
||||
|
||||
if ( bytes_read < 0 ) {
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += bytes_read;
|
||||
}
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
}
|
||||
|
@ -536,13 +542,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
{
|
||||
while ( !content_length )
|
||||
{
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for content");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
static RegExpr *content_expr = 0;
|
||||
if ( mode == MULTI_IMAGE )
|
||||
{
|
||||
|
@ -656,13 +663,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
}
|
||||
case HEADERCONT :
|
||||
{
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) && !zm_terminate ) {
|
||||
Debug(4, "Timeout waiting for HEADERCONT");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read header" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
|
||||
char *crlf = 0;
|
||||
char *header_ptr = (char *)buffer;
|
||||
|
@ -941,13 +949,14 @@ int RemoteCameraHttp::GetResponse()
|
|||
state = CONTENT;
|
||||
} else {
|
||||
Debug( 3, "Unable to extract subheader from stream, retrying" );
|
||||
while ( ! ( buffer_len = ReadData( buffer ) ) ) {
|
||||
while ( !( buffer_len = ReadData(buffer) ) &&!zm_terminate ) {
|
||||
Debug(1, "Timeout waiting to extra subheader non regexp");
|
||||
}
|
||||
if ( buffer_len < 0 ) {
|
||||
Error( "Unable to read subheader" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
state = SUBHEADERCONT;
|
||||
}
|
||||
break;
|
||||
|
@ -980,18 +989,19 @@ int RemoteCameraHttp::GetResponse()
|
|||
}
|
||||
|
||||
if ( content_length ) {
|
||||
while ( (long)buffer.size() < content_length ) {
|
||||
//int buffer_len = ReadData( buffer, content_length-buffer.size() );
|
||||
while ( ( (long)buffer.size() < content_length ) && ! zm_terminate ) {
|
||||
Debug(4, "getting more data");
|
||||
if ( ReadData( buffer ) < 0 ) {
|
||||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
int bytes_read = ReadData(buffer);
|
||||
if ( bytes_read < 0 ) {
|
||||
Error("Unable to read content");
|
||||
return -1;
|
||||
}
|
||||
bytes += bytes_read;
|
||||
}
|
||||
Debug( 3, "Got end of image by length, content-length = %d", content_length );
|
||||
} else {
|
||||
// Read until we find the end of image or the stream closes.
|
||||
while ( !content_length ) {
|
||||
while ( !content_length && !zm_terminate ) {
|
||||
Debug(4, "!content_length, ReadData");
|
||||
buffer_len = ReadData( buffer );
|
||||
if ( buffer_len < 0 )
|
||||
|
@ -999,6 +1009,7 @@ int RemoteCameraHttp::GetResponse()
|
|||
Error( "Unable to read content" );
|
||||
return( -1 );
|
||||
}
|
||||
bytes += buffer_len;
|
||||
int buffer_size = buffer.size();
|
||||
if ( buffer_len ) {
|
||||
// Got some data
|
||||
|
|
|
@ -711,8 +711,8 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
|||
opkt.dts = video_next_dts;
|
||||
opkt.duration = 0;
|
||||
|
||||
int duration;
|
||||
if (!video_last_pts) {
|
||||
int64_t duration;
|
||||
if ( !video_last_pts ) {
|
||||
duration = 0;
|
||||
} else {
|
||||
duration =
|
||||
|
@ -723,7 +723,7 @@ int VideoStore::writeVideoFramePacket(AVPacket *ipkt) {
|
|||
video_last_pts,
|
||||
duration);
|
||||
if (duration < 0) {
|
||||
duration = ipkt->duration;
|
||||
duration = ipkt->duration ? ipkt->duration : av_rescale_q(1,video_in_stream->time_base, video_out_stream->time_base);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -228,6 +228,7 @@ int main(int argc, char *argv[]) {
|
|||
sigset_t block_set;
|
||||
sigemptyset(&block_set);
|
||||
|
||||
sigaddset(&block_set, SIGHUP);
|
||||
sigaddset(&block_set, SIGUSR1);
|
||||
sigaddset(&block_set, SIGUSR2);
|
||||
|
||||
|
|
|
@ -181,7 +181,7 @@ private $control_fields = array(
|
|||
return $this->{$fn};
|
||||
#array_unshift($args, $this);
|
||||
#call_user_func_array( $this->{$fn}, $args);
|
||||
} else {
|
||||
} else {
|
||||
if ( array_key_exists($fn, $this->control_fields) ) {
|
||||
return $this->control_fields{$fn};
|
||||
} else if ( array_key_exists( $fn, $this->defaults ) ) {
|
||||
|
@ -254,22 +254,26 @@ private $control_fields = array(
|
|||
return $this->{'Height'};
|
||||
}
|
||||
|
||||
public function set( $data ) {
|
||||
public function set($data) {
|
||||
foreach ($data as $k => $v) {
|
||||
if ( is_array( $v ) ) {
|
||||
# perhaps should turn into a comma-separated string
|
||||
$this->{$k} = implode(',',$v);
|
||||
} else if ( is_string( $v ) ) {
|
||||
$this->{$k} = trim( $v );
|
||||
} else if ( is_integer( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
} else if ( is_bool( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
if ( method_exists($this, $k) ) {
|
||||
$this->{$k}($v);
|
||||
} else {
|
||||
Error( "Unknown type $k => $v of var " . gettype( $v ) );
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
}
|
||||
if ( is_array( $v ) ) {
|
||||
# perhaps should turn into a comma-separated string
|
||||
$this->{$k} = implode(',',$v);
|
||||
} else if ( is_string( $v ) ) {
|
||||
$this->{$k} = trim( $v );
|
||||
} else if ( is_integer( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
} else if ( is_bool( $v ) ) {
|
||||
$this->{$k} = $v;
|
||||
} else {
|
||||
Error( "Unknown type $k => $v of var " . gettype( $v ) );
|
||||
$this->{$k} = $v;
|
||||
}
|
||||
} # end if method_exists
|
||||
} # end foreach $data as $k=>$v
|
||||
}
|
||||
public static function find_all( $parameters = null, $options = null ) {
|
||||
$filters = array();
|
||||
|
@ -305,7 +309,7 @@ private $control_fields = array(
|
|||
return $filters;
|
||||
}
|
||||
|
||||
public function save( $new_values = null ) {
|
||||
public function save($new_values = null) {
|
||||
|
||||
if ( $new_values ) {
|
||||
foreach ( $new_values as $k=>$v ) {
|
||||
|
@ -313,12 +317,12 @@ private $control_fields = array(
|
|||
}
|
||||
}
|
||||
|
||||
$fields = array_keys( $this->defaults );
|
||||
$fields = array_keys($this->defaults);
|
||||
|
||||
$sql = 'UPDATE Monitors SET '.implode(', ', array_map( function($field) {return $field.'=?';}, $fields ) ) . ' WHERE Id=?';
|
||||
$values = array_map( function($field){return $this->{$field};}, $fields );
|
||||
$sql = 'UPDATE Monitors SET '.implode(', ', array_map(function($field) {return $field.'=?';}, $fields )) . ' WHERE Id=?';
|
||||
$values = array_map(function($field){return $this->{$field};}, $fields);
|
||||
$values[] = $this->{'Id'};
|
||||
dbQuery( $sql, $values );
|
||||
dbQuery($sql, $values);
|
||||
} // end function save
|
||||
|
||||
function zmcControl( $mode=false ) {
|
||||
|
@ -400,10 +404,20 @@ private $control_fields = array(
|
|||
}
|
||||
} // end if we are on the recording server
|
||||
}
|
||||
public function GroupIds( ) {
|
||||
public function GroupIds( $new='') {
|
||||
if ( $new != '' ) {
|
||||
if(!is_array($new)) {
|
||||
$this->{'GroupIds'} = array($new);
|
||||
} else {
|
||||
$this->{'GroupIds'} = $new;
|
||||
}
|
||||
}
|
||||
|
||||
if ( !array_key_exists('GroupIds', $this) ) {
|
||||
if ( array_key_exists('Id', $this) and $this->{'Id'} ) {
|
||||
$this->{'GroupIds'} = dbFetchAll( 'SELECT GroupId FROM Groups_Monitors WHERE MonitorId=?', 'GroupId', array($this->{'Id'}) );
|
||||
$this->{'GroupIds'} = dbFetchAll('SELECT GroupId FROM Groups_Monitors WHERE MonitorId=?', 'GroupId', array($this->{'Id'}) );
|
||||
if ( ! $this->{'GroupIds'} )
|
||||
$this->{'GroupIds'} = array();
|
||||
} else {
|
||||
$this->{'GroupIds'} = array();
|
||||
}
|
||||
|
|
|
@ -458,7 +458,7 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
$x10Monitor = array();
|
||||
}
|
||||
}
|
||||
$Monitor = new Monitor( $monitor );
|
||||
$Monitor = new Monitor($monitor);
|
||||
|
||||
// Define a field type for anything that's not simple text equivalent
|
||||
$types = array(
|
||||
|
@ -475,7 +475,7 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
|
||||
if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) {
|
||||
Logger::Debug("Auto selecting server");
|
||||
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne( 'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id' );
|
||||
$_REQUEST['newMonitor']['ServerId'] = dbFetchOne('SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem DESC, CpuLoad ASC LIMIT 1', 'Id');
|
||||
Logger::Debug("Auto selecting server: Got " . $_REQUEST['newMonitor']['ServerId'] );
|
||||
if ( ( ! $_REQUEST['newMonitor'] ) and defined('ZM_SERVER_ID') ) {
|
||||
$_REQUEST['newMonitor']['ServerId'] = ZM_SERVER_ID;
|
||||
|
@ -485,8 +485,8 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
Logger::Debug("NOT Auto selecting server" . $_REQUEST['newMonitor']['ServerId']);
|
||||
}
|
||||
|
||||
$columns = getTableColumns( 'Monitors' );
|
||||
$changes = getFormChanges( $monitor, $_REQUEST['newMonitor'], $types, $columns );
|
||||
$columns = getTableColumns('Monitors');
|
||||
$changes = getFormChanges($monitor, $_REQUEST['newMonitor'], $types, $columns);
|
||||
|
||||
if ( count( $changes ) ) {
|
||||
if ( $mid ) {
|
||||
|
@ -565,6 +565,8 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
return;
|
||||
}
|
||||
|
||||
$restart = true;
|
||||
} # end if count(changes)
|
||||
if (
|
||||
( !isset($_POST['newMonitor']['GroupIds']) )
|
||||
or
|
||||
|
@ -581,8 +583,6 @@ if ( canEdit( 'Monitors' ) ) {
|
|||
}
|
||||
}
|
||||
} // end if there has been a change of groups
|
||||
$restart = true;
|
||||
} # end if count(changes)
|
||||
|
||||
if ( ZM_OPT_X10 ) {
|
||||
$x10Changes = getFormChanges( $x10Monitor, $_REQUEST['newX10Monitor'] );
|
||||
|
|
|
@ -133,10 +133,7 @@ function dbQuery( $sql, $params=NULL ) {
|
|||
}
|
||||
} else {
|
||||
if ( defined('ZM_DB_DEBUG') ) {
|
||||
if ( $params )
|
||||
Warning("SQL: $sql" . implode(',',$params) );
|
||||
else
|
||||
Warning("SQL: $sql:" );
|
||||
Logger::Debug("SQL: $sql values:" . $params?implode(',',$params):'' );
|
||||
}
|
||||
$result = $dbConn->query($sql);
|
||||
}
|
||||
|
@ -186,7 +183,7 @@ function dbFetchAll( $sql, $col=false, $params=NULL ) {
|
|||
$dbRows = array();
|
||||
while( $dbRow = $result->fetch( PDO::FETCH_ASSOC ) )
|
||||
$dbRows[] = $col?$dbRow[$col]:$dbRow;
|
||||
return( $dbRows );
|
||||
return $dbRows;
|
||||
}
|
||||
|
||||
function dbFetchAssoc( $sql, $indexCol, $dataCol=false ) {
|
||||
|
|
|
@ -486,7 +486,7 @@ function getFormChanges( $values, $newValues, $types=false, $columns=false ) {
|
|||
$types = array();
|
||||
|
||||
foreach( $newValues as $key=>$value ) {
|
||||
if ( $columns && !$columns[$key] )
|
||||
if ( $columns && !isset($columns[$key]) )
|
||||
continue;
|
||||
|
||||
if ( !isset($types[$key]) )
|
||||
|
|
|
@ -62,7 +62,7 @@ if ( ! $monitor ) {
|
|||
$nextId = getTableAutoInc( 'Monitors' );
|
||||
if ( isset( $_REQUEST['dupId'] ) ) {
|
||||
$monitor = new Monitor( $_REQUEST['dupId'] );
|
||||
$monitor->GroupIds(); // have to lead before we change the Id
|
||||
$monitor->GroupIds(); // have to load before we change the Id
|
||||
if ( ZM_OPT_X10 )
|
||||
$x10Monitor = dbFetchOne( 'SELECT * FROM TriggersX10 WHERE MonitorId = ?', NULL, array($_REQUEST['dupId']) );
|
||||
$clonedName = $monitor->Name();
|
||||
|
@ -534,6 +534,11 @@ if ( $tab != 'general' ) {
|
|||
<input type="hidden" name="newMonitor[Name]" value="<?php echo validHtmlStr($monitor->Name()) ?>"/>
|
||||
<input type="hidden" name="newMonitor[ServerId]" value="<?php echo validHtmlStr($monitor->ServerId() ) ?>"/>
|
||||
<input type="hidden" name="newMonitor[StorageId]" value="<?= validHtmlStr($monitor->StorageId() ) ?>"/>
|
||||
<?php
|
||||
foreach ( $monitor->GroupIds() as $group_id ) {
|
||||
echo '<input type="hidden" name="newMonitor[GroupIds][]" value="'.$group_id.'"/>';
|
||||
}
|
||||
?>
|
||||
<input type="hidden" name="newMonitor[Type]" value="<?php echo validHtmlStr($monitor->Type()) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Function]" value="<?php echo validHtmlStr($monitor->Function()) ?>"/>
|
||||
<input type="hidden" name="newMonitor[Enabled]" value="<?php echo validHtmlStr($monitor->Enabled()) ?>"/>
|
||||
|
|
Loading…
Reference in New Issue