Make parallel and serial checks
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
# RemoteSupport
|
||||
GLPI Plugin for direct VNC connection from browser inside computer from server
|
||||
GLPI Plugin for direct VNC connection from browser inside computer from server and update status of online computers, it checks computer with go program in glpi cron and with fusion inventory agent...
|
||||
|
||||
This Plugin add a simple button inside computer:
|
||||
|
||||
|
||||
BIN
bin/check_status
BIN
bin/check_status
Binary file not shown.
@@ -11,8 +11,9 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
|
||||
$config = Config::getConfigurationValues('plugin:Remotesupport');
|
||||
|
||||
if ($config["show_in_computers"] == false)
|
||||
if ($config["show_in_computers"] == false) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if ($config["fusion"] == true && $config["easy_novnc"] == true) {
|
||||
$pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
|
||||
@@ -34,7 +35,7 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
echo '<tr class="tab_bg_1">';
|
||||
echo '<td>';
|
||||
|
||||
$url = "<a target=\"_blank\" href=\"". $href ."\"><li class=\"document\"><i class=\"fa fa-laptop-medical\"></i>" . $name . "</li></a>";
|
||||
$url = "<a target=\"_blank\" href=\"" . $href . "\"><li class=\"document\"><i class=\"fa fa-laptop-medical\"></i>" . $name . "</li></a>";
|
||||
|
||||
if ($url != "") {
|
||||
echo "<div><ul class=\"timeline_choices\"><h2>VNC connect : </h2>";
|
||||
@@ -83,10 +84,13 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
|
||||
$config = Config::getConfigurationValues('plugin:Remotesupport');
|
||||
|
||||
if ($config["fusion"])
|
||||
if ($config["fusion"] || $config["run_mode"] == "None") {
|
||||
return 0;
|
||||
}
|
||||
|
||||
Toolbox::logInFile("remotsupport", "Starting search of agents\n");
|
||||
|
||||
if ($config["run_mode"] == "Parallel") {
|
||||
$pfConfig = new PluginFusioninventoryConfig();
|
||||
$port = $pfConfig->getValue('agent_port');
|
||||
$rs_path = Plugin::getPhpDir('remotesupport');
|
||||
@@ -139,6 +143,32 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
Toolbox::logInFile("remotsupport", "command returned $return_value\n");
|
||||
}
|
||||
|
||||
} else {
|
||||
$agents = [];
|
||||
$data_set = [];
|
||||
$checked = [];
|
||||
|
||||
foreach (getAllDataFromTable(PluginFusioninventoryAgent::getTable()) as $a) {
|
||||
|
||||
$data_set[] = $a["id"];
|
||||
$agents[$a["id"]] = $a;
|
||||
}
|
||||
|
||||
foreach ($data_set as $id) {
|
||||
$agent = new PluginFusioninventoryAgent;
|
||||
$agent->getFromDB((int) $id);
|
||||
$st = $agent->getStatus();
|
||||
|
||||
if ($st["message"] != "noanswer") {
|
||||
$check = new stdClass();
|
||||
$check->computers_id = $agents[$id]["computers_id"];
|
||||
$checked[] = $check;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
$stids = self::getStatesIds();
|
||||
|
||||
$DB->update("glpi_computers", [
|
||||
@@ -148,6 +178,7 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
|
||||
$ids = [];
|
||||
$cids = self::getContactArray();
|
||||
|
||||
foreach ($checked as $s) {
|
||||
|
||||
$comp = new Computer();
|
||||
@@ -157,11 +188,10 @@ class PluginRemotesupportRemotesupport extends CommonDBTM
|
||||
}
|
||||
|
||||
$DB->update("glpi_computers", [
|
||||
'states_id' => $stids["Online"] ],
|
||||
['id' => $ids ]
|
||||
'states_id' => $stids["Online"]],
|
||||
['id' => $ids]
|
||||
);
|
||||
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user