Merge branch 'storageareas' of github.com:connortechnology/ZoneMinder into tesla
This commit is contained in:
commit
5d4fde88d9
|
@ -644,11 +644,11 @@ CREATE INDEX `Monitors_ServerId_idx` ON `Monitors` (`ServerId`);
|
||||||
|
|
||||||
DROP TABLE IF EXISTS `Monitor_Status`;
|
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||||
CREATE TABLE `Monitor_Status` (
|
CREATE TABLE `Monitor_Status` (
|
||||||
`Id` int(10) unsigned NOT NULL,
|
`MonitorId` int(10) unsigned NOT NULL,
|
||||||
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||||
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||||
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||||
PRIMARY KEY (`Id`)
|
PRIMARY KEY (`MonitorId`)
|
||||||
) ENGINE=MEMORY;
|
) ENGINE=MEMORY;
|
||||||
--
|
--
|
||||||
-- Table structure for table `States`
|
-- Table structure for table `States`
|
||||||
|
|
|
@ -0,0 +1,8 @@
|
||||||
|
DROP TABLE IF EXISTS `Monitor_Status`;
|
||||||
|
CREATE TABLE `Monitor_Status` (
|
||||||
|
`MonitorId` int(10) unsigned NOT NULL,
|
||||||
|
`Status` enum('Unknown','NotRunning','Running','NoSignal','Signal') NOT NULL default 'Unknown',
|
||||||
|
`CaptureFPS` DECIMAL(10,2) NOT NULL default 0,
|
||||||
|
`AnalysisFPS` DECIMAL(5,2) NOT NULL default 0,
|
||||||
|
PRIMARY KEY (`MonitorId`)
|
||||||
|
) ENGINE=MEMORY;
|
|
@ -227,6 +227,10 @@ MAIN: while( $loop ) {
|
||||||
Debug("Weird non digit characters in $monitor");
|
Debug("Weird non digit characters in $monitor");
|
||||||
next;
|
next;
|
||||||
}
|
}
|
||||||
|
if ( $monitor_id and ( $monitor_id != $monitor ) ) {
|
||||||
|
Debug("Skipping monitor $monitor because we are only interested in monitor $monitor_id");
|
||||||
|
next;
|
||||||
|
}
|
||||||
|
|
||||||
Debug( "Found filesystem monitor '$monitor'" );
|
Debug( "Found filesystem monitor '$monitor'" );
|
||||||
$fs_monitors->{$monitor} = {} if ! $fs_monitors->{$monitor};
|
$fs_monitors->{$monitor} = {} if ! $fs_monitors->{$monitor};
|
||||||
|
@ -371,6 +375,7 @@ MAIN: while( $loop ) {
|
||||||
} # end foreach fs event
|
} # end foreach fs event
|
||||||
} else {
|
} else {
|
||||||
aud_print( "Filesystem monitor '$monitor_id' in $$Storage{Path} does not exist in database" );
|
aud_print( "Filesystem monitor '$monitor_id' in $$Storage{Path} does not exist in database" );
|
||||||
|
|
||||||
if ( confirm() ) {
|
if ( confirm() ) {
|
||||||
my $command = "rm -rf $monitor_id";
|
my $command = "rm -rf $monitor_id";
|
||||||
executeShellCommand( $command );
|
executeShellCommand( $command );
|
||||||
|
@ -501,7 +506,7 @@ MAIN: while( $loop ) {
|
||||||
$res = $selectEmptyEventsSth->execute()
|
$res = $selectEmptyEventsSth->execute()
|
||||||
or Fatal( "Can't execute: ".$selectEmptyEventsSth->errstr() );
|
or Fatal( "Can't execute: ".$selectEmptyEventsSth->errstr() );
|
||||||
while( my $event = $selectEmptyEventsSth->fetchrow_hashref() ) {
|
while( my $event = $selectEmptyEventsSth->fetchrow_hashref() ) {
|
||||||
aud_print( "Found empty event with no frame records '$event->{Id}'" );
|
aud_print( "Found empty event with no frame records '$event->{Id}' at $$event{StartTime}" );
|
||||||
if ( confirm() ) {
|
if ( confirm() ) {
|
||||||
$res = $deleteEventSth->execute( $event->{Id} )
|
$res = $deleteEventSth->execute( $event->{Id} )
|
||||||
or Fatal( "Can't execute: ".$deleteEventSth->errstr() );
|
or Fatal( "Can't execute: ".$deleteEventSth->errstr() );
|
||||||
|
@ -713,7 +718,7 @@ sub confirm {
|
||||||
if ( $report ) {
|
if ( $report ) {
|
||||||
print( "\n" );
|
print( "\n" );
|
||||||
} elsif ( $interactive ) {
|
} elsif ( $interactive ) {
|
||||||
print( ", $prompt y/n: " );
|
print( ", $prompt Y/n/q: " );
|
||||||
my $char = <>;
|
my $char = <>;
|
||||||
chomp( $char );
|
chomp( $char );
|
||||||
if ( $char eq 'q' ) {
|
if ( $char eq 'q' ) {
|
||||||
|
@ -808,6 +813,7 @@ yet.
|
||||||
-c, --continuous - Run continuously
|
-c, --continuous - Run continuously
|
||||||
-f, --force - Run even if pid file exists
|
-f, --force - Run even if pid file exists
|
||||||
-i, --interactive - Ask before applying any changes
|
-i, --interactive - Ask before applying any changes
|
||||||
|
-m, --monitor_id - Only consider the given monitor
|
||||||
-r, --report - Just report don't actually do anything
|
-r, --report - Just report don't actually do anything
|
||||||
-s, --storage_id - Specify a storage area to audit instead of all
|
-s, --storage_id - Specify a storage area to audit instead of all
|
||||||
-v, --version - Print the installed version of ZoneMinder
|
-v, --version - Print the installed version of ZoneMinder
|
||||||
|
|
|
@ -2,30 +2,34 @@
|
||||||
|
|
||||||
$start_time = time();
|
$start_time = time();
|
||||||
|
|
||||||
define( "MSG_TIMEOUT", ZM_WEB_AJAX_TIMEOUT );
|
define( 'MSG_TIMEOUT', ZM_WEB_AJAX_TIMEOUT );
|
||||||
define( "MSG_DATA_SIZE", 4+256 );
|
define( 'MSG_DATA_SIZE', 4+256 );
|
||||||
|
|
||||||
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
|
if ( !($_REQUEST['connkey'] && $_REQUEST['command']) ) {
|
||||||
ajaxError( "Unexpected received message type '$type'" );
|
ajaxError( "Unexpected received message type '$type'" );
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
if ( !($socket = @socket_create( AF_UNIX, SOCK_DGRAM, 0 )) ) {
|
||||||
ajaxError( "socket_create() failed: ".socket_strerror(socket_last_error()) );
|
ajaxError( 'socket_create() failed: '.socket_strerror(socket_last_error()) );
|
||||||
}
|
|
||||||
$locSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.sock';
|
|
||||||
if ( file_exists( $locSockFile ) ) {
|
|
||||||
Warning("sock file $locSockFile already exists?! Is someone else talking to zms?");
|
|
||||||
// They could be. We can maybe have concurrent requests from a browser.
|
|
||||||
} else {
|
|
||||||
Logger::Debug("socket file does not exist, we should be good to connect.");
|
|
||||||
}
|
|
||||||
if ( !@socket_bind( $socket, $locSockFile ) ) {
|
|
||||||
ajaxError( "socket_bind( $locSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
|
||||||
} else {
|
|
||||||
Logger::Debug("Bound to $locSockFile");
|
|
||||||
}
|
}
|
||||||
|
$key = ftok(ZM_PATH_SOCKS.'/zms-'.sprintf("%06d",$_REQUEST['connkey']).'w.lock');
|
||||||
|
$semaphore = sem_get($key,1);
|
||||||
|
if ( sem_acquire($semaphore,1) !== false ) {
|
||||||
|
|
||||||
switch ( $_REQUEST['command'] ) {
|
$localSocketFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'w.sock';
|
||||||
|
if ( file_exists( $localSocketFile ) ) {
|
||||||
|
Warning("sock file $localSocketFile already exists?! Is someone else talking to zms?");
|
||||||
|
// They could be. We can maybe have concurrent requests from a browser.
|
||||||
|
} else {
|
||||||
|
Logger::Debug("socket file does not exist, we should be good to connect.");
|
||||||
|
}
|
||||||
|
if ( !@socket_bind( $socket, $localSocketFile ) ) {
|
||||||
|
ajaxError( "socket_bind( $localSocketFile ) failed: ".socket_strerror(socket_last_error()) );
|
||||||
|
} else {
|
||||||
|
Logger::Debug("Bound to $localSocketFile");
|
||||||
|
}
|
||||||
|
|
||||||
|
switch ( $_REQUEST['command'] ) {
|
||||||
case CMD_VARPLAY :
|
case CMD_VARPLAY :
|
||||||
Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
Logger::Debug( 'Varplaying to '.$_REQUEST['rate'] );
|
||||||
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
$msg = pack( 'lcn', MSG_CMD, $_REQUEST['command'], $_REQUEST['rate']+32768 );
|
||||||
|
@ -49,50 +53,50 @@ switch ( $_REQUEST['command'] ) {
|
||||||
default :
|
default :
|
||||||
$msg = pack( 'lc', MSG_CMD, $_REQUEST['command'] );
|
$msg = pack( 'lc', MSG_CMD, $_REQUEST['command'] );
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
|
|
||||||
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock';
|
|
||||||
$max_socket_tries = 10;
|
|
||||||
// FIXME This should not exceed web_ajax_timeout
|
|
||||||
while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
|
|
||||||
//Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
|
|
||||||
usleep(200000);
|
|
||||||
}
|
|
||||||
|
|
||||||
if ( !file_exists($remSockFile) ) {
|
|
||||||
ajaxError("Socket $remSockFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/latest/faq.html#why-can-t-i-see-streamed-images-when-i-can-see-stills-in-the-zone-window-etc for more information.");
|
|
||||||
} else {
|
|
||||||
if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) {
|
|
||||||
ajaxError( "socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
$rSockets = array( $socket );
|
$remSockFile = ZM_PATH_SOCKS.'/zms-'.sprintf('%06d',$_REQUEST['connkey']).'s.sock';
|
||||||
$wSockets = NULL;
|
$max_socket_tries = 10;
|
||||||
$eSockets = NULL;
|
// FIXME This should not exceed web_ajax_timeout
|
||||||
|
while ( !file_exists($remSockFile) && $max_socket_tries-- ) { //sometimes we are too fast for our own good, if it hasn't been setup yet give it a second.
|
||||||
$timeout = MSG_TIMEOUT - ( time() - $start_time );
|
//Logger::Debug("$remSockFile does not exist, waiting, current " . (time() - $start_time) . ' seconds' );
|
||||||
Logger::Debug("TImeout is: $timeout " );
|
usleep(200000);
|
||||||
|
|
||||||
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
|
||||||
|
|
||||||
if ( $numSockets === false ) {
|
|
||||||
Error("socket_select failed: " . socket_strerror(socket_last_error()) );
|
|
||||||
ajaxError( "socket_select failed: ".socket_strerror(socket_last_error()) );
|
|
||||||
} else if ( $numSockets < 0 ) {
|
|
||||||
Error( "Socket closed $remSockFile" );
|
|
||||||
ajaxError( "Socket closed $remSockFile" );
|
|
||||||
} else if ( $numSockets == 0 ) {
|
|
||||||
Error( "Timed out waiting for msg $remSockFile" );
|
|
||||||
ajaxError( "Timed out waiting for msg $remSockFile" );
|
|
||||||
} else if ( $numSockets > 0 ) {
|
|
||||||
if ( count($rSockets) != 1 ) {
|
|
||||||
Error( "Bogus return from select, ".count($rSockets).' sockets available' );
|
|
||||||
ajaxError( "Bogus return from select, ".count($rSockets).' sockets available' );
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
|
if ( !file_exists($remSockFile) ) {
|
||||||
|
ajaxError("Socket $remSockFile does not exist. This file is created by zms, and since it does not exist, either zms did not run, or zms exited early. Please check your zms logs and ensure that CGI is enabled in apache and check that the PATH_ZMS is set correctly. Make sure that ZM is actually recording. If you are trying to view a live stream and the capture process (zmc) is not running then zms will exit. Please go to http://zoneminder.readthedocs.io/en/latest/faq.html#why-can-t-i-see-streamed-images-when-i-can-see-stills-in-the-zone-window-etc for more information.");
|
||||||
|
} else {
|
||||||
|
if ( !@socket_sendto( $socket, $msg, strlen($msg), 0, $remSockFile ) ) {
|
||||||
|
ajaxError( "socket_sendto( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
$rSockets = array( $socket );
|
||||||
|
$wSockets = NULL;
|
||||||
|
$eSockets = NULL;
|
||||||
|
|
||||||
|
$timeout = MSG_TIMEOUT - ( time() - $start_time );
|
||||||
|
Logger::Debug("TImeout is: $timeout " );
|
||||||
|
|
||||||
|
$numSockets = @socket_select( $rSockets, $wSockets, $eSockets, intval($timeout/1000), ($timeout%1000)*1000 );
|
||||||
|
|
||||||
|
if ( $numSockets === false ) {
|
||||||
|
Error('socket_select failed: ' . socket_strerror(socket_last_error()) );
|
||||||
|
ajaxError( 'socket_select failed: '.socket_strerror(socket_last_error()) );
|
||||||
|
} else if ( $numSockets < 0 ) {
|
||||||
|
Error( "Socket closed $remSockFile" );
|
||||||
|
ajaxError( "Socket closed $remSockFile" );
|
||||||
|
} else if ( $numSockets == 0 ) {
|
||||||
|
Error( "Timed out waiting for msg $remSockFile" );
|
||||||
|
ajaxError( "Timed out waiting for msg $remSockFile" );
|
||||||
|
} else if ( $numSockets > 0 ) {
|
||||||
|
if ( count($rSockets) != 1 ) {
|
||||||
|
Error( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
||||||
|
ajaxError( 'Bogus return from select, '.count($rSockets).' sockets available' );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFile ) ) {
|
||||||
case -1 :
|
case -1 :
|
||||||
{
|
{
|
||||||
ajaxError( "socket_recvfrom( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
ajaxError( "socket_recvfrom( $remSockFile ) failed: ".socket_strerror(socket_last_error()) );
|
||||||
|
@ -109,10 +113,11 @@ switch( $nbytes = @socket_recvfrom( $socket, $msg, MSG_DATA_SIZE, 0, $remSockFil
|
||||||
ajaxError( "Got unexpected message size, got $nbytes, expected ".MSG_DATA_SIZE );
|
ajaxError( "Got unexpected message size, got $nbytes, expected ".MSG_DATA_SIZE );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
$data = unpack( 'ltype', $msg );
|
|
||||||
switch ( $data['type'] ) {
|
$data = unpack( 'ltype', $msg );
|
||||||
|
switch ( $data['type'] ) {
|
||||||
case MSG_DATA_WATCH :
|
case MSG_DATA_WATCH :
|
||||||
{
|
{
|
||||||
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
|
$data = unpack( "ltype/imonitor/istate/dfps/ilevel/irate/ddelay/izoom/Cdelayed/Cpaused/Cenabled/Cforced", $msg );
|
||||||
|
@ -156,15 +161,19 @@ switch ( $data['type'] ) {
|
||||||
{
|
{
|
||||||
ajaxError( "Unexpected received message type '$type'" );
|
ajaxError( "Unexpected received message type '$type'" );
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
sem_release($semaphore);
|
||||||
|
} else {
|
||||||
|
Error("Couldn't get semaphore");
|
||||||
}
|
}
|
||||||
|
|
||||||
ajaxError( 'Unrecognised action or insufficient permissions' );
|
ajaxError( 'Unrecognised action or insufficient permissions' );
|
||||||
|
|
||||||
function ajaxCleanup() {
|
function ajaxCleanup() {
|
||||||
global $socket, $locSockFile;
|
global $socket, $localSocketFile;
|
||||||
if ( !empty( $socket ) )
|
if ( !empty( $socket ) )
|
||||||
@socket_close( $socket );
|
@socket_close( $socket );
|
||||||
if ( !empty( $locSockFile ) )
|
if ( !empty( $localSocketFile ) )
|
||||||
@unlink( $locSockFile );
|
@unlink( $localSocketFile );
|
||||||
}
|
}
|
||||||
?>
|
?>
|
||||||
|
|
|
@ -1 +1 @@
|
||||||
Subproject commit ca91b87fda8e006e4fca2ed870f24f9a29c2905d
|
Subproject commit 7108489f218c54d36d235d3af91d6da2f8311237
|
|
@ -89,7 +89,7 @@ if ( ! is_array( $selected_monitor_ids ) ) {
|
||||||
$values += $ids;
|
$values += $ids;
|
||||||
}
|
}
|
||||||
|
|
||||||
$sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON S.Id=M.Id ' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
$sql = 'SELECT *,S.Status AS Status, S.CaptureFPS AS CaptureFPS FROM Monitors AS M LEFT JOIN Monitor_Status AS S ON MonitorId=Id ' . ( count($conditions) ? ' WHERE ' . implode(' AND ', $conditions ) : '' ).' ORDER BY Sequence ASC';
|
||||||
$monitors = dbFetchAll( $sql, null, $values );
|
$monitors = dbFetchAll( $sql, null, $values );
|
||||||
$displayMonitors = array();
|
$displayMonitors = array();
|
||||||
$monitors_dropdown = array();
|
$monitors_dropdown = array();
|
||||||
|
|
Loading…
Reference in New Issue