diff --git a/web/includes/actions.php b/web/includes/actions.php index 6f25a40d0..5b0347499 100644 --- a/web/includes/actions.php +++ b/web/includes/actions.php @@ -483,11 +483,20 @@ if ( canEdit( 'Monitors' ) ) { 'RecordAudio' => 'toggle', ); + if ( $_REQUEST['newMonitor']['ServerId'] == 'auto' ) { +Logger::Debug("Auto selecting server"); + $_REQUEST['newMonitor']['ServerId'] = dbFetchOne( 'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem, CpuLoad 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; +Logger::Debug("Auto selecting server to " . ZM_SERVER_ID); + } +} else { +Logger::Debug("NOT Auto selecting server" . $_REQUEST['newMonitor']['ServerId']); + } + $columns = getTableColumns( 'Monitors' ); $changes = getFormChanges( $monitor, $_REQUEST['newMonitor'], $types, $columns ); - if ( isset($changes['ServerId']) and $changes['ServerId'] == 'auto' ) { - $changes['ServerId'] = dbFetchOne( 'SELECT Id FROM Servers WHERE Status=\'Running\' ORDER BY FreeMem, CpuLoad LIMIT 1', 'Id' ); - } if ( count( $changes ) ) { if ( $mid ) {