Added monitor function changes.
git-svn-id: http://svn.zoneminder.com/svn/zm/trunk@28 e3e1d417-86f3-4887-817a-d78f3d33393f
This commit is contained in:
parent
2dfbd35809
commit
c28fd36613
47
web/zm.php
47
web/zm.php
|
@ -115,44 +115,29 @@ if ( $action )
|
||||||
$result = mysql_query( $sql );
|
$result = mysql_query( $sql );
|
||||||
if ( !$result )
|
if ( !$result )
|
||||||
echo mysql_error();
|
echo mysql_error();
|
||||||
$sql = "select * from Monitors where Device = '$monitor[Device]' and Function != 'None'";
|
$sql = "select count(if(Function='Passive',1,NULL)) as PassiveCount, count(if(Function='Active',1,NULL)) as ActiveCount from Monitors where Id = '$mid'";
|
||||||
$result = mysql_query( $sql );
|
$result = mysql_query( $sql );
|
||||||
if ( !$result )
|
if ( !$result )
|
||||||
die( mysql_error() );
|
echo mysql_error();
|
||||||
$device_monitors = mysql_num_rows( $result );
|
$row = mysql_fetch_assoc( $result );
|
||||||
if ( $new_function == "None" )
|
$passive_count = $row[PassiveCount];
|
||||||
{
|
$active_count = $row[ActiveCount];
|
||||||
if ( $device_monitors == 0 )
|
|
||||||
|
if ( !$passive_count && !$active_count )
|
||||||
{
|
{
|
||||||
stopDaemon( "zmc", $monitor[Device] );
|
stopDaemon( "zmc", $monitor[Device] );
|
||||||
stopDaemon( "zma", $monitor[Device] );
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
signalDaemon( "zmc", $monitor[Device], 'HUP' );
|
|
||||||
signalDaemon( "zma", $monitor[Device], 'HUP' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ( $new_function == "Passive" )
|
|
||||||
{
|
{
|
||||||
startDaemon( "zmc", $monitor[Device] );
|
startDaemon( "zmc", $monitor[Device] );
|
||||||
if ( $device_monitors == 0 )
|
}
|
||||||
|
if ( !$active_count )
|
||||||
{
|
{
|
||||||
stopDaemon( "zma", $monitor[Device] );
|
stopDaemon( "zma", $monitor[Device] );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
signalDaemon( "zmc", $monitor[Device], 'HUP' );
|
|
||||||
startDaemon( "zma", $monitor[Device] );
|
startDaemon( "zma", $monitor[Device] );
|
||||||
signalDaemon( "zma", $monitor[Device], 'HUP' );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
elseif ( $new_function == "Active" )
|
|
||||||
{
|
|
||||||
startDaemon( "zmc", $monitor[Device] );
|
|
||||||
signalDaemon( "zmc", $monitor[Device], 'HUP' );
|
|
||||||
startDaemon( "zma", $monitor[Device] );
|
|
||||||
signalDaemon( "zma", $monitor[Device], 'HUP' );
|
|
||||||
}
|
}
|
||||||
$refresh_parent = true;
|
$refresh_parent = true;
|
||||||
}
|
}
|
||||||
|
@ -1223,7 +1208,10 @@ function startDaemon( $daemon, $did )
|
||||||
$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
|
$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
|
||||||
$pid = $ps_array[3];
|
$pid = $ps_array[3];
|
||||||
if ( $pid )
|
if ( $pid )
|
||||||
|
{
|
||||||
|
exec( "kill -HUP $pid" );
|
||||||
return;
|
return;
|
||||||
|
}
|
||||||
$command = ZM_PATH."/$daemon $did".' 2>/dev/null >&- <&- >/dev/null &';
|
$command = ZM_PATH."/$daemon $did".' 2>/dev/null >&- <&- >/dev/null &';
|
||||||
exec( $command );
|
exec( $command );
|
||||||
$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
|
$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
|
||||||
|
@ -1256,17 +1244,6 @@ function stopDaemon( $daemon, $did )
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
function signalDaemon( $daemon, $did, $signal )
|
|
||||||
{
|
|
||||||
$ps_command = "ps -edalf | grep '$daemon $did' | grep -v grep";
|
|
||||||
$ps_array = preg_split( "/\s+/", exec( $ps_command ) );
|
|
||||||
if ( $ps_array[3] )
|
|
||||||
{
|
|
||||||
$pid = $ps_array[3];
|
|
||||||
exec( "kill -$signal $pid" );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
function getEnumValues( $table, $column )
|
function getEnumValues( $table, $column )
|
||||||
{
|
{
|
||||||
$enum_values = array();
|
$enum_values = array();
|
||||||
|
|
Loading…
Reference in New Issue