/**
  * Send Computer to inventoryruleimport
  *
  * @param $p_DEVICEID XML code to import
  * @param $p_CONTENT XML code of the Computer
  * @param $p_CONTENT XML code of all agent have sent
  *
  * @return nothing
  *
  **/
 function sendCriteria($p_DEVICEID, $arrayinventory)
 {
     if (isset($_SESSION['plugin_fusioninventory_entityrestrict'])) {
         unset($_SESSION['plugin_fusioninventory_entityrestrict']);
     }
     $this->device_id = $p_DEVICEID;
     // * Hacks
     // Hack to put OS in software
     if (isset($arrayinventory['CONTENT']['HARDWARE']['OSNAME'])) {
         $inputos = array();
         if (isset($arrayinventory['CONTENT']['HARDWARE']['OSCOMMENTS'])) {
             $inputos['COMMENTS'] = $arrayinventory['CONTENT']['HARDWARE']['OSCOMMENTS'];
         }
         $inputos['NAME'] = $arrayinventory['CONTENT']['HARDWARE']['OSNAME'];
         if (isset($arrayinventory['CONTENT']['HARDWARE']['OSVERSION'])) {
             $inputos['VERSION'] = $arrayinventory['CONTENT']['HARDWARE']['OSVERSION'];
         }
         if (isset($arrayinventory['CONTENT']['SOFTWARES']['VERSION'])) {
             $temparray = $arrayinventory['CONTENT']['SOFTWARES'];
             $arrayinventory['CONTENT']['SOFTWARES'] = array();
             $arrayinventory['CONTENT']['SOFTWARES'][] = $temparray;
         }
         $arrayinventory['CONTENT']['SOFTWARES'][] = $inputos;
     }
     // Hack for USB Printer serial
     if (isset($arrayinventory['CONTENT']['PRINTERS'])) {
         foreach ($arrayinventory['CONTENT']['PRINTERS'] as $key => $printer) {
             if (isset($printer['SERIAL']) and preg_match('/\\/$/', $printer['SERIAL'])) {
                 $arrayinventory['CONTENT']['PRINTERS'][$key]['SERIAL'] = preg_replace('/\\/$/', '', $printer['SERIAL']);
             }
         }
     }
     // Hack to remove Memories with Flash types see ticket
     // http://forge.fusioninventory.org/issues/1337
     if (isset($arrayinventory['CONTENT']['MEMORIES'])) {
         foreach ($arrayinventory['CONTENT']['MEMORIES'] as $key => $memory) {
             if (isset($memory['TYPE']) and preg_match('/Flash/', $memory['TYPE'])) {
                 unset($arrayinventory['CONTENT']['MEMORIES'][$key]);
             }
         }
     }
     // End hack
     $a_computerinventory = PluginFusioninventoryFormatconvert::computerInventoryTransformation($arrayinventory['CONTENT']);
     // Get tag is defined and put it in fusioninventory_agent table
     $tagAgent = "";
     if (isset($a_computerinventory['ACCOUNTINFO'])) {
         if (isset($a_computerinventory['ACCOUNTINFO']['KEYNAME']) && $a_computerinventory['ACCOUNTINFO']['KEYNAME'] == 'TAG') {
             if (isset($a_computerinventory['ACCOUNTINFO']['KEYVALUE']) && $a_computerinventory['ACCOUNTINFO']['KEYVALUE'] != '') {
                 $tagAgent = $a_computerinventory['ACCOUNTINFO']['KEYVALUE'];
             }
         }
     }
     $pfAgent = new PluginFusioninventoryAgent();
     $input = array();
     $input['id'] = $_SESSION['plugin_fusioninventory_agents_id'];
     $input['tag'] = $tagAgent;
     $pfAgent->update($input);
     $pfBlacklist = new PluginFusioninventoryInventoryComputerBlacklist();
     $a_computerinventory = $pfBlacklist->cleanBlacklist($a_computerinventory);
     if (isset($a_computerinventory['monitor'])) {
         foreach ($a_computerinventory['monitor'] as $num => $a_monit) {
             $a_computerinventory['monitor'][$num] = $pfBlacklist->cleanBlacklist($a_monit);
         }
     }
     $this->arrayinventory = $a_computerinventory;
     $input = array();
     // Global criterias
     if (isset($a_computerinventory['Computer']['serial']) and !empty($a_computerinventory['Computer']['serial'])) {
         $input['serial'] = $a_computerinventory['Computer']['serial'];
     }
     if (isset($a_computerinventory['Computer']['uuid']) and !empty($a_computerinventory['Computer']['uuid'])) {
         $input['uuid'] = $a_computerinventory['Computer']['uuid'];
     }
     foreach ($a_computerinventory['networkport'] as $network) {
         if (isset($network['virtualdev']) && $network['virtualdev'] != 1 or !isset($network['virtualdev'])) {
             if (isset($network['mac']) and !empty($network['mac'])) {
                 $input['mac'][] = $network['mac'];
             }
             foreach ($network['ipaddress'] as $ip) {
                 if ($ip != '127.0.0.1' && $ip != '::1') {
                     $input['ip'][] = $ip;
                 }
             }
             if (isset($network['subnet']) and !empty($network['subnet'])) {
                 $input['subnet'][] = $network['subnet'];
             }
         }
     }
     // Case of virtualmachines
     if (!isset($input['mac']) && !isset($input['ip'])) {
         foreach ($a_computerinventory['networkport'] as $network) {
             if (isset($network['mac']) and !empty($network['mac'])) {
                 $input['mac'][] = $network['mac'];
             }
             foreach ($network['ipaddress'] as $ip) {
                 if ($ip != '127.0.0.1' && $ip != '::1') {
                     $input['ip'][] = $ip;
                 }
             }
             if (isset($network['subnet']) and !empty($network['subnet'])) {
                 $input['subnet'][] = $network['subnet'];
             }
         }
     }
     if (isset($a_computerinventory['Computer']['os_license_number']) and !empty($a_computerinventory['Computer']['os_license_number'])) {
         $input['mskey'] = $a_computerinventory['Computer']['os_license_number'];
     }
     if (isset($a_computerinventory['Computer']['operatingsystems_id']) and !empty($a_computerinventory['Computer']['operatingsystems_id'])) {
         $input['osname'] = $a_computerinventory['Computer']['operatingsystems_id'];
     }
     if (isset($a_inventory['fusioninventorycomputer']['oscomment']) and !empty($a_inventory['fusioninventorycomputer']['oscomment'])) {
         $input['oscomment'] = $a_inventory['fusioninventorycomputer']['oscomment'];
     }
     if (isset($a_computerinventory['Computer']['computermodels_id']) and !empty($a_computerinventory['Computer']['computermodels_id'])) {
         $input['model'] = $a_computerinventory['Computer']['computermodels_id'];
     }
     if (isset($a_computerinventory['Computer']['domains_id']) and !empty($a_computerinventory['Computer']['domains_id'])) {
         $input['domains_id'] = $a_computerinventory['Computer']['domains_id'];
     }
     // TODO
     //         if (isset($arrayinventory['CONTENT']['STORAGES'])) {
     //            foreach($arrayinventory['CONTENT']['STORAGES'] as $storage) {
     //               if ((isset($storage['SERIALNUMBER'])) AND (!empty($storage['SERIALNUMBER']))) {
     //                  $input['partitionserial'][] = $storage['SERIALNUMBER'];
     //               }
     //            }
     //         }
     //         if (isset($arrayinventory['CONTENT']['computerdisk'])) {
     //            foreach($arrayinventory['CONTENT']['DRIVES'] as $drive) {
     //               if ((isset($drive['SERIAL'])) AND (!empty($drive['SERIAL']))) {
     //                  $input['hdserial'][] = $drive['SERIAL'];
     //               }
     //            }
     //         }
     $input['tag'] = $tagAgent;
     if (isset($a_computerinventory['Computer']['name']) and $a_computerinventory['Computer']['name'] != '') {
         $input['name'] = $a_computerinventory['Computer']['name'];
     } else {
         $input['name'] = '';
     }
     $input['itemtype'] = "Computer";
     // If transfer is disable, get entity and search only on this entity
     // (see http://forge.fusioninventory.org/issues/1503)
     $pfConfig = new PluginFusioninventoryConfig();
     $pfEntity = new PluginFusioninventoryEntity();
     // * entity rules
     $inputent = $input;
     if (isset($a_computerinventory['Computer']['domains_id']) and !empty($a_computerinventory['Computer']['domains_id'])) {
         $inputent['domain'] = $a_computerinventory['Computer']['domains_id'];
     }
     if (isset($inputent['serial'])) {
         $inputent['serialnumber'] = $inputent['serial'];
     }
     $ruleEntity = new PluginFusioninventoryInventoryRuleEntityCollection();
     // * Reload rules (required for unit tests)
     $ruleEntity->getCollectionPart();
     $dataEntity = $ruleEntity->processAllRules($inputent, array());
     if (isset($dataEntity['_ignore_import'])) {
         return;
     }
     if (isset($dataEntity['entities_id']) && $dataEntity['entities_id'] >= 0) {
         $_SESSION["plugin_fusioninventory_entity"] = $dataEntity['entities_id'];
         $input['entities_id'] = $dataEntity['entities_id'];
     } else {
         if (isset($dataEntity['entities_id']) && $dataEntity['entities_id'] == -1) {
             $input['entities_id'] = 0;
             $_SESSION["plugin_fusioninventory_entity"] = -1;
         } else {
             $input['entities_id'] = 0;
             $_SESSION["plugin_fusioninventory_entity"] = 0;
         }
     }
     if (isset($dataEntity['locations_id'])) {
         $_SESSION['plugin_fusioninventory_locations_id'] = $dataEntity['locations_id'];
     }
     // End entity rules
     $_SESSION['plugin_fusioninventory_classrulepassed'] = "PluginFusioninventoryInventoryComputerInventory";
     $ruleLocation = new PluginFusioninventoryInventoryRuleLocationCollection();
     // * Reload rules (required for unit tests)
     $ruleLocation->getCollectionPart();
     $dataLocation = $ruleLocation->processAllRules($input, array());
     if (isset($dataLocation['locations_id'])) {
         $_SESSION['plugin_fusioninventory_locations_id'] = $dataLocation['locations_id'];
     }
     $rule = new PluginFusioninventoryInventoryRuleImportCollection();
     // * Reload rules (required for unit tests)
     $rule->getCollectionPart();
     $data = $rule->processAllRules($input, array(), array('class' => $this));
     PluginFusioninventoryToolbox::logIfExtradebug("pluginFusioninventory-rules", $data);
     if (isset($data['_no_rule_matches']) and $data['_no_rule_matches'] == '1') {
         $this->rulepassed(0, "Computer");
     } else {
         if (!isset($data['found_equipment'])) {
             $pfIgnoredimportdevice = new PluginFusioninventoryIgnoredimportdevice();
             $inputdb = array();
             $inputdb['name'] = $input['name'];
             $inputdb['date'] = date("Y-m-d H:i:s");
             $inputdb['itemtype'] = "Computer";
             if (isset($a_computerinventory['Computer']['domains_id']) and !empty($a_computerinventory['Computer']['domains_id'])) {
                 $inputdb['domain'] = $a_computerinventory['Computer']['domains_id'];
             }
             if (isset($a_computerinventory['Computer']['serial'])) {
                 $inputdb['serial'] = $a_computerinventory['Computer']['serial'];
             }
             if (isset($a_computerinventory['Computer']['uuid'])) {
                 $inputdb['uuid'] = $a_computerinventory['Computer']['uuid'];
             }
             if (isset($input['ip'])) {
                 $inputdb['ip'] = $input['ip'];
             }
             if (isset($input['mac'])) {
                 $inputdb['mac'] = $input['mac'];
             }
             $inputdb['entities_id'] = $input['entities_id'];
             if (isset($input['ip'])) {
                 $inputdb['ip'] = exportArrayToDB($input['ip']);
             }
             if (isset($input['mac'])) {
                 $inputdb['mac'] = exportArrayToDB($input['mac']);
             }
             $inputdb['rules_id'] = $data['_ruleid'];
             $inputdb['method'] = 'inventory';
             $pfIgnoredimportdevice->add($inputdb);
         }
     }
 }
 /**
  * Import data
  *
  * @param $p_DEVICEID XML code to import
  * @param $p_CONTENT XML code to import
  * @param $p_xml value XML code to import
  *
  * @return "" (import ok) / error string (import ko)
  *
  **/
 function import($p_DEVICEID, $a_CONTENT, $arrayinventory)
 {
     $pfTaskjobstate = new PluginFusioninventoryTaskjobstate();
     $pfAgent = new PluginFusioninventoryAgent();
     PluginFusioninventoryCommunication::addLog('Function PluginFusioninventoryCommunicationNetworkDiscovery->import().');
     $errors = '';
     $a_agent = $pfAgent->InfosByKey($p_DEVICEID);
     if (isset($a_CONTENT['PROCESSNUMBER'])) {
         $_SESSION['glpi_plugin_fusioninventory_processnumber'] = $a_CONTENT['PROCESSNUMBER'];
         if ($pfTaskjobstate->getFromDB($a_CONTENT['PROCESSNUMBER'])) {
             if ($pfTaskjobstate->fields['state'] != "3") {
                 $pfTaskjobstate->changeStatus($a_CONTENT['PROCESSNUMBER'], 2);
                 if (!isset($a_CONTENT['AGENT']['START']) and !isset($a_CONTENT['AGENT']['END'])) {
                     $nb_devices = 0;
                     if (isset($a_CONTENT['DEVICE'])) {
                         if (is_int(key($a_CONTENT['DEVICE']))) {
                             $nb_devices = count($a_CONTENT['DEVICE']);
                         } else {
                             $nb_devices = 1;
                         }
                     }
                     $_SESSION['plugin_fusinvsnmp_taskjoblog']['taskjobs_id'] = $a_CONTENT['PROCESSNUMBER'];
                     $_SESSION['plugin_fusinvsnmp_taskjoblog']['items_id'] = $a_agent['id'];
                     $_SESSION['plugin_fusinvsnmp_taskjoblog']['itemtype'] = 'PluginFusioninventoryAgent';
                     $_SESSION['plugin_fusinvsnmp_taskjoblog']['state'] = '6';
                     $_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] = $nb_devices . ' ==devicesfound==';
                     $this->addtaskjoblog();
                 }
             }
         }
     }
     if ($pfTaskjobstate->getFromDB($a_CONTENT['PROCESSNUMBER'])) {
         if ($pfTaskjobstate->fields['state'] != "3") {
             $pfImportExport = new PluginFusioninventorySnmpmodelImportExport();
             $errors .= $pfImportExport->import_netdiscovery($a_CONTENT, $p_DEVICEID);
             if (isset($a_CONTENT['AGENT']['END'])) {
                 if (isset($a_CONTENT['DICO']) and $a_CONTENT['DICO'] == "REQUEST") {
                     $pfAgent->getFromDB($pfTaskjobstate->fields["plugin_fusioninventory_agents_id"]);
                     $input = array();
                     $input['id'] = $pfAgent->fields['id'];
                     $input["senddico"] = "1";
                     $pfAgent->update($input);
                     $pfTaskjobstate->changeStatusFinish($a_CONTENT['PROCESSNUMBER'], $a_agent['id'], 'PluginFusioninventoryAgent', '1', '==diconotuptodate==');
                 } else {
                     $messages = array('Total Found' => 0, 'Created' => 0, 'Updated' => 0);
                     $messages['Updated'] = countElementsInTable('glpi_plugin_fusioninventory_taskjoblogs', "`plugin_fusioninventory_taskjobstates_id`='" . $a_CONTENT['PROCESSNUMBER'] . "' " . " AND `comment` LIKE '%==updatetheitem==%'");
                     $messages['Created'] = countElementsInTable('glpi_plugin_fusioninventory_taskjoblogs', "`plugin_fusioninventory_taskjobstates_id`='" . $a_CONTENT['PROCESSNUMBER'] . "' " . " AND `comment` LIKE '%==addtheitem==%'");
                     $messages['Total Found'] = $messages['Updated'] + $messages['Created'];
                     $message = 'Total Found:' . $messages['Total Found'] . ' Created:' . $messages['Created'] . ' Updated:' . $messages['Updated'];
                     $pfTaskjobstate->changeStatusFinish($a_CONTENT['PROCESSNUMBER'], $a_agent['id'], 'PluginFusioninventoryAgent', '0', $message);
                 }
             }
         }
     }
     return $errors;
 }
 /**
  * Import the content (where have all devices)
  *@param $p_content CONTENT code to import
  *
  *@return errors string to be alimented if import ko / '' if ok
  **/
 function importContent($arrayinventory)
 {
     PluginFusioninventoryCommunication::addLog('Function PluginFusioninventoryCommunicationNetworkInventory->importContent().');
     $pfAgent = new PluginFusioninventoryAgent();
     $errors = '';
     $nbDevices = 0;
     foreach ($arrayinventory as $childname => $child) {
         PluginFusioninventoryCommunication::addLog($childname);
         switch ($childname) {
             case 'DEVICE':
                 $a_devices = array();
                 if (is_int(key($child))) {
                     $a_devices = $child;
                 } else {
                     $a_devices[] = $child;
                 }
                 $xml_num = 0;
                 foreach ($a_devices as $dchild) {
                     $_SESSION['plugin_fusioninventory_xmlnum'] = $xml_num;
                     $a_inventory = array();
                     if (isset($dchild['INFO'])) {
                         if ($dchild['INFO']['TYPE'] == "NETWORKING") {
                             $a_inventory = PluginFusioninventoryFormatconvert::networkequipmentInventoryTransformation($dchild);
                         } else {
                             if ($dchild['INFO']['TYPE'] == "PRINTER") {
                                 $a_inventory = PluginFusioninventoryFormatconvert::printerInventoryTransformation($dchild);
                             }
                         }
                     }
                     if (isset($dchild['ERROR'])) {
                         $itemtype = "";
                         if ($dchild['ERROR']['TYPE'] == "NETWORKING") {
                             $itemtype = "NetworkEquipment";
                         } else {
                             if ($dchild['ERROR']['TYPE'] == "PRINTER") {
                                 $itemtype = "Printer";
                             }
                         }
                         $_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] = '[==detail==] ' . $dchild['ERROR']['MESSAGE'] . ' [[' . $itemtype . '::' . $dchild['ERROR']['ID'] . ']]';
                         $this->addtaskjoblog();
                     } else {
                         if ($a_inventory['PluginFusioninventory' . $a_inventory['itemtype']]['sysdescr'] == '' && $a_inventory[$a_inventory['itemtype']]['name'] == '' && $a_inventory[$a_inventory['itemtype']]['serial'] == '') {
                             $_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] = '[==detail==] No informations [[' . $a_inventory['itemtype'] . '::' . $dchild['INFO']['ID'] . ']]';
                             $this->addtaskjoblog();
                         } else {
                             if (count($a_inventory) > 0) {
                                 $errors .= $this->sendCriteria($a_inventory);
                                 $nbDevices++;
                             }
                         }
                     }
                     $xml_num++;
                 }
                 break;
             case 'AGENT':
                 if (isset($this->arrayinventory['CONTENT']['AGENT']['AGENTVERSION'])) {
                     $agent = $pfAgent->InfosByKey($this->arrayinventory['DEVICEID']);
                     $agent['fusioninventory_agent_version'] = $this->arrayinventory['CONTENT']['AGENT']['AGENTVERSION'];
                     $agent['last_agent_update'] = date("Y-m-d H:i:s");
                     $pfAgent->update($agent);
                 }
                 break;
             case 'PROCESSNUMBER':
                 break;
             case 'MODULEVERSION':
                 break;
             default:
                 $_SESSION['plugin_fusinvsnmp_taskjoblog']['comment'] = '[==detail==] ' . __('Unattended element in', 'fusioninventory') . ' CONTENT : ' . $childname;
                 $this->addtaskjoblog();
         }
     }
     return $errors;
 }
Exemplo n.º 4
0
function plugin_item_transfer_fusioninventory($parm)
{
    switch ($parm['type']) {
        case 'Computer':
            $pfAgent = new PluginFusioninventoryAgent();
            if ($agent_id = $pfAgent->getAgentWithComputerid($parm['id'])) {
                $input = array();
                $input['id'] = $agent_id;
                $computer = new Computer();
                $computer->getFromDB($parm['newID']);
                $input['entities_id'] = $computer->fields['entities_id'];
                $pfAgent->update($input);
            }
            break;
    }
    return FALSE;
}
    $agent->getFromDB($_POST['agent_id']);
    if ($agent->wakeUp()) {
        Session::addMessageAfterRedirect(__('The agent is running', 'fusioninventory'));
    } else {
        Session::addMessageAfterRedirect(__('Impossible to communicate with agent!', 'fusioninventory'));
    }
    Html::back();
} else {
    if (isset($_POST["update"])) {
        Session::checkRight('plugin_fusioninventory_agent', UPDATE);
        if (isset($_POST['items_id'])) {
            if ($_POST['items_id'] != "0" and $_POST['items_id'] != "") {
                $_POST['itemtype'] = '1';
            }
        }
        $agent->update($_POST);
        Html::back();
    } else {
        if (isset($_POST["purge"])) {
            Session::checkRight('plugin_fusioninventory_agent', PURGE);
            $agent->delete($_POST, true);
            $agent->redirectToList();
        } else {
            if (isset($_POST["startagent"])) {
                Html::back();
            }
        }
    }
}
Html::header(__('FusionInventory', 'fusioninventory'), $_SERVER["PHP_SELF"], "plugins", "pluginfusioninventorymenu", "agent");
PluginFusioninventoryMenu::displayMenu("mini");
 /**
  * Import agent : create if not exist and update if yet exist
  *
  * @param $p_xml simpleXMLobject
  *
  **/
 function importToken($arrayinventory)
 {
     if (isset($arrayinventory['DEVICEID'])) {
         $pfAgent = new PluginFusioninventoryAgent();
         $a_agent = $pfAgent->find("`device_id`='" . $arrayinventory['DEVICEID'] . "'", "", "1");
         if (empty($a_agent)) {
             $a_input = array();
             if (isset($arrayinventory['TOKEN'])) {
                 $a_input['token'] = $arrayinventory['TOKEN'];
             }
             $a_input['name'] = $arrayinventory['DEVICEID'];
             $a_input['device_id'] = $arrayinventory['DEVICEID'];
             $a_input['entities_id'] = 0;
             $a_input['last_contact'] = date("Y-m-d H:i:s");
             if (isset($_SERVER['HTTP_USER_AGENT'])) {
                 $a_input['useragent'] = $_SERVER['HTTP_USER_AGENT'];
             }
             return $pfAgent->add($a_input);
         } else {
             foreach ($a_agent as $data) {
                 $input = array();
                 $input['id'] = $data['id'];
                 if (isset($arrayinventory['TOKEN'])) {
                     $input['token'] = $arrayinventory['TOKEN'];
                 }
                 $input['last_contact'] = date("Y-m-d H:i:s");
                 if (isset($_SERVER['HTTP_USER_AGENT'])) {
                     $input['useragent'] = $_SERVER['HTTP_USER_AGENT'];
                 }
                 $pfAgent->update($input);
                 return $data['id'];
             }
         }
     }
     return;
 }
 function import_netdiscovery($arrayinventory, $agentKey)
 {
     PluginFusioninventoryCommunication::addLog('Function PluginFusioninventorySnmpmodelImportExport->import_netdiscovery().');
     $ptap = new PluginFusioninventoryStateDiscovery();
     $pta = new PluginFusioninventoryAgent();
     $agent = $pta->InfosByKey($agentKey);
     if (isset($arrayinventory['AGENT']['START'])) {
         $ptap->updateState($arrayinventory['PROCESSNUMBER'], array('start_time' => date("Y-m-d H:i:s")), $agent['id']);
     } else {
         if (isset($arrayinventory['AGENT']['END'])) {
             $ptap->updateState($arrayinventory['PROCESSNUMBER'], array('end_time' => date("Y-m-d H:i:s")), $agent['id']);
         } else {
             if (isset($arrayinventory['AGENT']['EXIT'])) {
                 $ptap->endState($arrayinventory['PROCESSNUMBER'], date("Y-m-d H:i:s"), $agent['id']);
             } else {
                 if (isset($arrayinventory['AGENT']['NBIP'])) {
                     $ptap->updateState($arrayinventory['PROCESSNUMBER'], array('nb_ip' => $arrayinventory['AGENT']['NBIP']), $agent['id']);
                 }
             }
         }
     }
     if (isset($arrayinventory['AGENT']['AGENTVERSION'])) {
         $agent['last_contact'] = date("Y-m-d H:i:s");
         $pta->update($agent);
     }
     $_SESSION['glpi_plugin_fusioninventory_agentid'] = $agent['id'];
     $count_discovery_devices = 0;
     if (isset($arrayinventory['DEVICE'])) {
         if (is_int(key($arrayinventory['DEVICE']))) {
             $count_discovery_devices = count($arrayinventory['DEVICE']);
         } else {
             $count_discovery_devices = 1;
         }
     }
     if ($count_discovery_devices != "0") {
         $ptap->updateState($_SESSION['glpi_plugin_fusioninventory_processnumber'], array('nb_found' => $count_discovery_devices), $agent['id']);
         if (is_int(key($arrayinventory['DEVICE']))) {
             foreach ($arrayinventory['DEVICE'] as $discovery) {
                 if (count($discovery) > 0) {
                     $pfCommunicationNetworkDiscovery = new PluginFusioninventoryCommunicationNetworkDiscovery();
                     $pfCommunicationNetworkDiscovery->sendCriteria($discovery);
                 }
             }
         } else {
             $pfCommunicationNetworkDiscovery = new PluginFusioninventoryCommunicationNetworkDiscovery();
             $pfCommunicationNetworkDiscovery->sendCriteria($arrayinventory['DEVICE']);
         }
     }
 }