From f868d991b168fb53517f334a153980b440de56b9 Mon Sep 17 00:00:00 2001 From: Jaroslav Drzik Date: Wed, 15 Dec 2021 10:24:10 +0100 Subject: [PATCH] Port from config and path from plugin function --- inc/remote_status.php | 10 ++++++++-- inc/remotesupport.class.php | 11 ++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/inc/remote_status.php b/inc/remote_status.php index 6aa95a8..3b4e8e4 100644 --- a/inc/remote_status.php +++ b/inc/remote_status.php @@ -8,13 +8,19 @@ global $DB, $agents; $check_arr = []; $comps = []; + +$rs_path = Plugin::getPhpDir('remotesupport'); + +$pfConfig = new PluginFusioninventoryConfig(); +$port = $pfConfig->getValue('agent_port'); + $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer(); foreach (getAllDataFromTable(PluginFusioninventoryAgent::getTable()) as $a) { $check = []; $a_computerextend = $pfInventoryComputerComputer->hasAutomaticInventory($a["computers_id"]); - $check["url"] = "http://" . $a_computerextend["remote_addr"] . ":62354/status"; + $check["url"] = "http://" . $a_computerextend["remote_addr"] . ":" . $port . "/status"; $check["id"] = $a["id"]; $check["computers_id"] = $a["computers_id"]; $check["status"] = "unknown"; @@ -33,7 +39,7 @@ $descriptorspec = array( $cwd = '/tmp'; $env = array('debug' => 'false'); -$process = proc_open(__DIR__ . '/check_status', $descriptorspec, $pipes, $cwd, $env); +$process = proc_open($rs_path . '/bin/check_status', $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { // $pipes now looks like this: diff --git a/inc/remotesupport.class.php b/inc/remotesupport.class.php index 4a985ee..e61ca6a 100644 --- a/inc/remotesupport.class.php +++ b/inc/remotesupport.class.php @@ -9,10 +9,8 @@ class PluginRemotesupportRemotesupport extends CommonDBTM public static function showInfo($item) { - $fi_path = Plugin::getWebDir('fusioninventory'); - // Manage locks pictures - PluginFusioninventoryLock::showLockIcon('Computer'); + //PluginFusioninventoryLock::showLockIcon('Computer'); $pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer(); $a_computerextend = $pfInventoryComputerComputer->hasAutomaticInventory($item->getID()); @@ -75,6 +73,9 @@ class PluginRemotesupportRemotesupport extends CommonDBTM global $DB; Toolbox::logInFile("remotsupport", "Starting search of agents\n"); + $pfConfig = new PluginFusioninventoryConfig(); + $port = $pfConfig->getValue('agent_port'); + $rs_path = Plugin::getPhpDir('remotesupport'); $check_arr = []; $comps = []; @@ -84,7 +85,7 @@ class PluginRemotesupportRemotesupport extends CommonDBTM $check = []; $a_computerextend = $pfInventoryComputerComputer->hasAutomaticInventory($a["computers_id"]); - $check["url"] = "http://" . $a_computerextend["remote_addr"] . ":62354/status"; + $check["url"] = "http://" . $a_computerextend["remote_addr"] . ":" . $port . "/status"; $check["id"] = $a["id"]; $check["computers_id"] = $a["computers_id"]; $check["status"] = "unknown"; @@ -103,7 +104,7 @@ class PluginRemotesupportRemotesupport extends CommonDBTM $cwd = '/tmp'; $env = array('debug' => 'false'); - $process = proc_open(__DIR__ . '/../bin/check_status', $descriptorspec, $pipes, $cwd, $env); + $process = proc_open($rs_path . '/bin/check_status', $descriptorspec, $pipes, $cwd, $env); if (is_resource($process)) { // $pipes now looks like this: