Array of states

This commit is contained in:
Jaroslav Drzik
2021-12-09 17:57:03 +01:00
parent 6d5d6e18f5
commit 6d0f7fb392
3 changed files with 41 additions and 7 deletions

View File

@@ -48,6 +48,7 @@ declare(ticks=1);
global $DB,$agents;
$check_arr = [];
$comps = [];
$pfInventoryComputerComputer = new PluginFusioninventoryInventoryComputerComputer();
foreach (getAllDataFromTable(PluginFusioninventoryAgent::getTable()) as $a) {
@@ -60,6 +61,7 @@ global $DB,$agents;
$check["status"] = "unknown";
$check_arr[] = $check;
$comps[$a["computers_id"]] = $check;
//print_r($agent->getAgentStatusURLs());
}
@@ -73,7 +75,7 @@ $descriptorspec = array(
$cwd = '/tmp';
$env = array('debug' => 'false');
$process = proc_open(__DIR__.'/bench_urls', $descriptorspec, $pipes, $cwd, $env);
$process = proc_open(__DIR__.'/check_status', $descriptorspec, $pipes, $cwd, $env);
if (is_resource($process)) {
// $pipes now looks like this:
@@ -94,8 +96,18 @@ if (is_resource($process)) {
echo "command returned $return_value\n";
}
$req = $DB->request('glpi_states', ['FIELDS' => ['glpi_states' => ['id', 'name']]], [ 'OR' => [ 'name' => 'Online', 'name' => 'Offline']]);
$ret = $req->next();
$states_ids[$ret['name']] = $ret['id'];
$ret = $req->next();
$states_ids[$ret['name']] = $ret['id'];
print_r($states_ids);
$DB->update("glpi_computers", [
'states_id' => NULL ] ,
'states_id' => $states_ids["Offline"] ] ,
[ '1' => '1' ]
);
@@ -105,7 +117,7 @@ foreach ($checked as $s) {
$comp = new Computer();
$comp->getFromDB($s->computers_id);
$comp->fields["states_id"] = 2;
$comp->fields["states_id"] = $states_ids["Online"];
$DB->update("glpi_computers", [
'states_id' => $comp->fields["states_id"] ],
[ 'id' => $s->computers_id ]