/** * @test */ public function PrinterSnmpExtension() { global $DB; $DB->connect(); $pfPrinter = new PluginFusioninventoryPrinter(); $a_printer = current($pfPrinter->find("`printers_id`='1'", "", 1)); unset($a_printer['last_fusioninventory_update']); $a_reference = array('id' => '1', 'printers_id' => '1', 'sysdescr' => 'HP ETHERNET MULTI-ENVIRONMENT', 'plugin_fusioninventory_configsecurities_id' => '0', 'frequence_days' => '1', 'serialized_inventory' => NULL); $this->assertEquals($a_reference, $a_printer); }
static function showInfo($item) { // Manage locks pictures PluginFusioninventoryLock::showLockIcon('Printer'); $pfPrinter = new PluginFusioninventoryPrinter(); $a_printerextend = current($pfPrinter->find("`printers_id`='" . $item->getID() . "'", "", 1)); if (empty($a_printerextend)) { return; } echo '<table class="tab_glpi" width="100%">'; echo '<tr>'; echo '<th colspan="2">' . __('FusionInventory', 'fusioninventory') . '</th>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>'; echo __('Last inventory', 'fusioninventory'); echo '</td>'; echo '<td>'; echo Html::convDateTime($a_printerextend['last_fusioninventory_update']); echo '</td>'; echo '</tr>'; echo '<tr class="tab_bg_1">'; echo '<td>'; echo __('Type'); echo '</td>'; echo '<td>'; echo "SNMP"; echo '</td>'; echo '</tr>'; echo "</table>"; }
function run($jobstate) { $pfAgent = new PluginFusioninventoryAgent(); $pfTaskjobstate = new PluginFusioninventoryTaskjobstate(); $pfTaskjoblog = new PluginFusioninventoryTaskjoblog(); $pfConfigSecurity = new PluginFusioninventoryConfigSecurity(); $pfToolbox = new PluginFusioninventoryToolbox(); $current = $jobstate; $pfAgent->getFromDB($current->fields['plugin_fusioninventory_agents_id']); $ip = current(PluginFusioninventoryToolbox::getIPforDevice($jobstate->fields['itemtype'], $jobstate->fields['items_id'])); if ($ip == '') { $pfTaskjobstate->changeStatusFinish($jobstate->fields['id'], $jobstate->fields['items_id'], $jobstate->fields['itemtype'], 1, "Device have no ip"); } else { $sxml_option = $this->message->addChild('OPTION'); $sxml_option->addChild('NAME', 'SNMPQUERY'); $sxml_param = $sxml_option->addChild('PARAM'); $sxml_param->addAttribute('THREADS_QUERY', $pfAgent->fields["threads_networkinventory"]); $sxml_param->addAttribute('TIMEOUT', $pfAgent->fields["timeout_networkinventory"]); $sxml_param->addAttribute('PID', $current->fields['id']); $changestate = 0; $taskjobstatedatas = $jobstate->fields; $sxml_device = $sxml_option->addChild('DEVICE'); $a_extended = array('plugin_fusioninventory_configsecurities_id' => 0); if ($jobstate->fields['itemtype'] == 'Printer') { $sxml_device->addAttribute('TYPE', 'PRINTER'); $pfPrinter = new PluginFusioninventoryPrinter(); $a_extended = current($pfPrinter->find("`printers_id`='" . $jobstate->fields['items_id'] . "'", '', 1)); } else { if ($jobstate->fields['itemtype'] == 'NetworkEquipment') { $sxml_device->addAttribute('TYPE', 'NETWORKING'); $pfNetworkEquipment = new PluginFusioninventoryNetworkEquipment(); $a_extended = current($pfNetworkEquipment->find("`networkequipments_id`='" . $jobstate->fields['items_id'] . "'", '', 1)); } } $sxml_device->addAttribute('ID', $jobstate->fields['items_id']); $sxml_device->addAttribute('IP', $ip); $sxml_device->addAttribute('AUTHSNMP_ID', $a_extended['plugin_fusioninventory_configsecurities_id']); if ($changestate == '0') { $pfTaskjobstate->changeStatus($taskjobstatedatas['id'], 1); $pfTaskjoblog->addTaskjoblog($taskjobstatedatas['id'], '0', 'PluginFusioninventoryAgent', '1', $pfAgent->fields["threads_networkinventory"] . ' threads', $pfAgent->fields["timeout_networkinventory"] . ' timeout'); $changestate = $pfTaskjobstate->fields['id']; } else { $pfTaskjobstate->changeStatusFinish($taskjobstatedatas['id'], $taskjobstatedatas['items_id'], $taskjobstatedatas['itemtype'], 0, "Merged with " . $changestate); } $snmpauthlist = $pfConfigSecurity->find(); if (count($snmpauthlist)) { foreach ($snmpauthlist as $snmpauth) { $pfToolbox->addAuth($sxml_option, $snmpauth['id']); } } } return $this->message; }
function getSerialized_InventoryArray($itemtype, $items_id) { $item_extend = new PluginFusioninventoryLock(); if ($itemtype == 'Computer') { $item_extend = new PluginFusioninventoryInventoryComputerComputer(); } else { if ($itemtype == 'NetworkEquipment') { $item_extend = new PluginFusioninventoryNetworkEquipment(); } else { if ($itemtype == 'Printer') { $item_extend = new PluginFusioninventoryPrinter(); } } } if ($item_extend->getType() != 'PluginFusioninventoryLock') { // Get device info + field 'serialized_inventory' $a_lists = $item_extend->find("`" . getForeignKeyFieldForItemType($itemtype) . "`='" . $items_id . "'", "", 1); if (count($a_lists) == 1) { $a_list = current($a_lists); if (!empty($a_list['serialized_inventory'])) { $serialized = unserialize(gzuncompress($a_list['serialized_inventory'])); return $serialized[$itemtype]; } } } return array(); }