Go lang check agents

This commit is contained in:
Jaroslav Drzik
2021-12-06 21:59:24 +01:00
parent 87714aafda
commit ca9dafcab4
5 changed files with 324 additions and 5 deletions

View File

@@ -6,8 +6,7 @@ if (!defined('GLPI_ROOT')) {
class PluginRemoteSupportComputer extends CommonDBTM {
class PluginRemotesupportRemotesupport extends CommonDBTM {
static function showInfo($item) {
$fi_path = Plugin::getWebDir('fusioninventory');
@@ -28,7 +27,7 @@ class PluginRemoteSupportComputer extends CommonDBTM {
echo '<tr class="tab_bg_1">';
echo '<td>';
$url .= "<a target=\"_blank\" href=\"https://" . $_SERVER['SERVER_ADDR']. "/vnc.html?path=vnc%2F". $a_computerextend['remote_addr'] ."&autoconnect=true&resize=scale&reconnect=true&show_dot=true\"><li class=\"document\"><i class=\"fa fa-laptop-medical\"></i>" . $a_computerextend['remote_addr'] . "</li></a>";
$url = "<a target=\"_blank\" href=\"https://" . $_SERVER['SERVER_ADDR']. "/vnc.html?path=vnc%2F". $a_computerextend['remote_addr'] ."&autoconnect=true&resize=scale&reconnect=true&show_dot=true\"><li class=\"document\"><i class=\"fa fa-laptop-medical\"></i>" . $a_computerextend['remote_addr'] . "</li></a>";
if ($url != ""){
echo "<div><ul class=\"timeline_choices\"><h2>VNC connect : </h2>";
@@ -40,4 +39,51 @@ class PluginRemoteSupportComputer extends CommonDBTM {
echo '</table>';
}
static function cronRemotesupport($task) {
global $DB;
Toolbox::logInFile("remotsupport","Starting search of agents\n");
$agents = [];
$data_set = [];
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")
Toolbox::logInFile("remotsupport",print_r($agents[$id],true));
$comp = new Computer();
$comp->getFromDB($agents[$id]["computers_id"]);
if ($st["message"] == "noanswer")
$comp->fields["states_id"] = NULL;
else
$comp->fields["states_id"] = 2;
$DB->update("glpi_computers", [
'states_id' => $comp->fields["states_id"] ],
[ 'id' => $agents[$id]["computers_id"] ]
);
$comp->fields["contact"]."\n";
}
return true;
}
static function cronInfo($name) {
return [
'description' => "Agent search remotesupport"];
}
}