glpi電腦,軟件數(shù)據(jù)庫(kù)分析

查詢電腦

參考php文件:glpi-9.1.4\inc\computer.php

電腦表結(jié)構(gòu)關(guān)系
        SELECT
            'glpi' AS currentuser,
            `glpi_computers`.`entities_id`,
            `glpi_computers`.`is_recursive`,
            `glpi_computers`.`name` AS `ITEM_0`,
            `glpi_computers`.`id` AS `ITEM_0_id`,
            `glpi_states`.`completename` AS `ITEM_1`,
            `glpi_manufacturers`.`name` AS `ITEM_2`,
            `glpi_computers`.`serial` AS `ITEM_3`,
            `glpi_computertypes`.`name` AS `ITEM_4`,
            `glpi_computermodels`.`name` AS `ITEM_5`,
            `glpi_operatingsystems`.`name` AS `ITEM_6`,
            `glpi_locations`.`completename` AS `ITEM_7`,
            `glpi_computers`.`date_mod` AS `ITEM_8`,
            GROUP_CONCAT(
                DISTINCT CONCAT(
                    IFNULL(
                        `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`designation`,
                        '__NULL__'
                    ),
                    '$#$',
                    `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`id`
                ) SEPARATOR '$$##$$'
            ) AS `ITEM_9`,
            `glpi_computers`.`id` AS id
        FROM
            `glpi_computers`
        LEFT JOIN `glpi_states` ON (
            `glpi_computers`.`states_id` = `glpi_states`.`id`
        )
        LEFT JOIN `glpi_manufacturers` ON (
            `glpi_computers`.`manufacturers_id` = `glpi_manufacturers`.`id`
        )
        LEFT JOIN `glpi_computertypes` ON (
            `glpi_computers`.`computertypes_id` = `glpi_computertypes`.`id`
        )
        LEFT JOIN `glpi_computermodels` ON (
            `glpi_computers`.`computermodels_id` = `glpi_computermodels`.`id`
        )
        LEFT JOIN `glpi_operatingsystems` ON (
            `glpi_computers`.`operatingsystems_id` = `glpi_operatingsystems`.`id`
        )
        LEFT JOIN `glpi_locations` ON (
            `glpi_computers`.`locations_id` = `glpi_locations`.`id`
        )
        LEFT JOIN `glpi_items_deviceprocessors` ON (
            `glpi_computers`.`id` = `glpi_items_deviceprocessors`.`items_id`
            AND `glpi_items_deviceprocessors`.`itemtype` = 'Computer'
        )
        LEFT JOIN `glpi_deviceprocessors` AS `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604` ON (
            `glpi_items_deviceprocessors`.`deviceprocessors_id` = `glpi_deviceprocessors_7083fb7d2b7a8b8abd619678acc5b604`.`id`
        )
        WHERE
            `glpi_computers`.`is_deleted` = '0'
        AND `glpi_computers`.`is_template` = '0'
        GROUP BY
            `glpi_computers`.`id`
        ORDER BY
            ITEM_0 ASC
        LIMIT 0,
         20

查詢軟件

參考php文件:glpi-9.1.4\inc\computer_softwareversion.class.php

軟件表結(jié)構(gòu)關(guān)系
    SELECT
        `glpi_softwares`.`softwarecategories_id`,
        `glpi_softwares`.`name` AS softname,
        `glpi_computers_softwareversions`.`id`,
        `glpi_computers_softwareversions`.`is_dynamic`,
        `glpi_states`.`name` AS state,
        `glpi_softwareversions`.`id` AS verid,
        `glpi_softwareversions`.`softwares_id`,
        `glpi_softwareversions`.`name` AS VERSION,
        `glpi_softwares`.`is_valid` AS softvalid,
        `glpi_computers_softwareversions`.`date_install` AS dateinstall
    FROM
        `glpi_computers_softwareversions`
    LEFT JOIN `glpi_softwareversions` ON (
        `glpi_computers_softwareversions`.`softwareversions_id` = `glpi_softwareversions`.`id`
    )
    LEFT JOIN `glpi_states` ON (
        `glpi_states`.`id` = `glpi_softwareversions`.`states_id`
    )
    LEFT JOIN `glpi_softwares` ON (
        `glpi_softwareversions`.`softwares_id` = `glpi_softwares`.`id`
    )
    WHERE
        `glpi_computers_softwareversions`.`computers_id` = '3'
    AND `glpi_computers_softwareversions`.`is_deleted` = '0'
    ORDER BY
        `softname`,
        `version`

查詢磁盤(pán)信息

磁盤(pán)信息表結(jié)構(gòu)
        SELECT
            `glpi_filesystems`.`name` AS fsname,
            `glpi_computerdisks`.*
        FROM
            `glpi_computerdisks`
        LEFT JOIN `glpi_filesystems` ON (
            `glpi_computerdisks`.`filesystems_id` = `glpi_filesystems`.`id`
        )
        WHERE
            `computers_id` = '3'
        AND `is_deleted` = '0'

網(wǎng)絡(luò)端口

參考php文件:glpi-9.1.4\inc\networkport.class.php

網(wǎng)絡(luò)端口表結(jié)構(gòu)
        SELECT
            *
        FROM
            `glpi_networkports`
        WHERE
            `items_id` = '3'
        AND `itemtype` = 'Computer'
        AND `instantiation_type` = 'NetworkPortEthernet'
        AND `is_deleted` = '0'
        ORDER BY
            `name`,
            `logical_number`

殺毒軟件

參考php文件:glpi-9.1.4\inc\computerantivirus.class.php


殺毒軟件表結(jié)構(gòu)
        SELECT
            *
        FROM
            `glpi_computerantiviruses`
        WHERE
            `computers_id` = 3
        AND `is_deleted` = 0

控制器查詢

查詢所有devicecontrols_id

    SELECT
        *
    FROM
        `glpi_items_devicecontrols`
    WHERE
        `itemtype` = 'Computer'
    AND `items_id` = '3'
    AND `is_deleted` = '0'
    ORDER BY
        devicecontrols_id
查詢所有devices id

遍歷查詢每個(gè) devicecontrols_id 的具體信息

    SELECT
        *
    FROM
        `glpi_devicecontrols`
    WHERE
        `glpi_devicecontrols`.`id` = '3'
    LIMIT 1 
單個(gè)control id 對(duì)應(yīng)的control具體信息

查詢所有devices control信息

        SELECT
            *
        FROM
            `glpi_devicecontrols`
查詢所有control信息

上報(bào)數(shù)據(jù)導(dǎo)入功能流程

  • 接收xml文件

      $pfCommunication = new PluginFusioninventoryCommunication(); 
      if (!isset($rawdata)) {
          $rawdata = file_get_contents("php://input");
      }
      if (isset($_GET['action']) && isset($_GET['machineid'])) {
          PluginFusioninventoryCommunicationRest::handleFusionCommunication();
      } else if (!empty($rawdata)) {
          $pfCommunication->handleOCSCommunication($rawdata);
      }
       session_destroy();
    
  • 解壓縮xml文件
    $content_type = filter_input(INPUT_SERVER, "CONTENT_TYPE");
    if (!empty($xml)) {
    $compressmode = 'none';
    } else if ($content_type == "application/x-compress-zlib") {
    $xml = gzuncompress($rawdata);
    $compressmode = "zlib";
    } else if ($content_type == "application/x-compress-gzip") {
    $xml = $pfToolbox->gzdecode($rawdata);
    $compressmode = "gzip";
    } else if ($content_type == "application/xml") {
    $xml = $rawdata;
    $compressmode = 'none';
    }

  • 生成數(shù)組
    $_SESSION['plugin_fusioninventory_compressmode'] = $compressmode;
    // Convert XML into PHP array
    $arrayinventory = PluginFusioninventoryFormatconvert::XMLtoArray($pxml);

  • 寫(xiě)入數(shù)據(jù)庫(kù)
    $deviceid = '';
    if (isset($arrayinventory['DEVICEID'])) {
    $deviceid = $arrayinventory['DEVICEID'];
    }
    $agent = new PluginFusioninventoryAgent();
    $agents_id = $agent->importToken($arrayinventory);
    $communication->import($arrayinventory)

    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");
             $a_input['useragent'] = filter_input(INPUT_SERVER, "HTTP_USER_AGENT");
             $agents_id = $pfAgent->add($a_input);
             if ($agents_id) {
                return $agents_id;
             }
          } 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");
                $input['useragent'] = filter_input(INPUT_SERVER, "HTTP_USER_AGENT");
                $pfAgent->update($input);
                return $data['id'];
             }
          }
       }
       return 0;
    }
    function import($arrayinventory) {
    
       $pfAgent = new PluginFusioninventoryAgent();
    
       PluginFusioninventoryToolbox::logIfExtradebug(
          'pluginFusioninventory-communication',
          'Function import().'
       );
    
       $this->message = $arrayinventory;
       $errors = '';
    
       $xmltag = $this->message['QUERY'];
       if ($xmltag == "NETDISCOVERY") {
          $xmltag = "NETWORKDISCOVERY";
       }
       if ($xmltag == "SNMPQUERY"
               OR $xmltag == "SNMPINVENTORY") {
          $xmltag = "NETWORKINVENTORY";
       }
    
       if (!isset($_SESSION['plugin_fusioninventory_agents_id'])) {
          $agent = $pfAgent->infoByKey($this->message['DEVICEID']);
       } else {
          $agent = array('id' => $_SESSION['plugin_fusioninventory_agents_id']);
       }
       if ($xmltag == "PROLOG") {
          return FALSE;
       }
    
       if (isset($this->message['CONTENT']['MODULEVERSION'])) {
          $pfAgent->setAgentVersions($agent['id'],
                                     $xmltag,
                                     $this->message['CONTENT']['MODULEVERSION']);
       } else if (isset($this->message['CONTENT']['VERSIONCLIENT'])) {
          $version = str_replace("FusionInventory-Agent_",
                                 "",
                                 $this->message['CONTENT']['VERSIONCLIENT']);
          $pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
       }
    
       if (isset($this->message->CONTENT->MODULEVERSION)) {
          $pfAgent->setAgentVersions($agent['id'],
                                     $xmltag,
                                     (string)$this->message->CONTENT->MODULEVERSION);
       } else if (isset($this->message->CONTENT->VERSIONCLIENT)) {
          $version = str_replace("FusionInventory-Agent_",
                                 "",
                                 (string)$this->message->CONTENT->VERSIONCLIENT);
          $pfAgent->setAgentVersions($agent['id'], $xmltag, $version);
       }
    
       if (isset($_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"])) {
          $moduleClass = $_SESSION['glpi_plugin_fusioninventory']['xmltags']["$xmltag"];
          $moduleCommunication = new $moduleClass();
          $errors.=$moduleCommunication->import($this->message['DEVICEID'],
                  $this->message['CONTENT'],
                  $arrayinventory);
       } else {
          $errors.=__('Unattended element in', 'fusioninventory').' QUERY : *'.$xmltag."*\n";
       }
       $result=TRUE;
       // TODO manage this error ( = delete it)
       if ($errors != '') {
          echo $errors;
          if (isset($_SESSION['glpi_plugin_fusioninventory_processnumber'])) {
             $result=TRUE;
          } else {
             // It's PROLOG
             $result=FALSE;
          }
       }
       return $result;
    }
    

inventorycomputerinventory.class.php

/**
 * import data
 *
 * @global object $DB
 * @global array $CFG_GLPI
 * @param string $p_DEVICEID
 * @param array $a_CONTENT
 * @param array $arrayinventory
 * @return string errors
 */
function import($p_DEVICEID, $a_CONTENT, $arrayinventory)
{
    global $DB, $CFG_GLPI;

    $this->logArray($arrayinventory);

    $errors = '';
    $_SESSION["plugin_fusioninventory_entity"] = -1;

    // Prevent 2 computers with same name (Case of have the computer inventory 2 times in same time
    // and so we don't want it create 2 computers instead one)
    $name = '';
    if (isset($arrayinventory['CONTENT']['HARDWARE']['NAME'])) {
        $name = strtolower($arrayinventory['CONTENT']['HARDWARE']['NAME']);
    }

    // Clean all DB LOCK if exist more than 10 minutes
    $time = 600;
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventorynames` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventories` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblocksoftwares` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblocksoftwareversions` "
        . " WHERE `date` <  CURRENT_TIMESTAMP() - " . $time;
    $DB->query($query);

    // DB LOCK   數(shù)據(jù)庫(kù)加鎖操作
    $query = "INSERT INTO `glpi_plugin_fusioninventory_dblockinventorynames`
        SET `value`='" . $name . "'";
    $CFG_GLPI["use_log_in_files"] = FALSE;
    $start_time = date('U');
    while (!$DB->query($query)) {
        usleep(100000);
        if ((date('U') - $start_time) > 5) {
            $communication = new PluginFusioninventoryCommunication();
            $communication->setMessage("<?xml version='1.0' encoding='UTF-8'?>
     <REPLY>
     <ERROR>ERROR: Timeout for DB lock based on name</ERROR>
     </REPLY>");
            $communication->sendMessage($_SESSION['plugin_fusioninventory_compressmode']);
            exit;
        }
    }
    $CFG_GLPI["use_log_in_files"] = TRUE;
    $this->sendCriteria($p_DEVICEID, $arrayinventory);
    // DB UNLOCK 數(shù)據(jù)庫(kù)解鎖操作
    $query = "DELETE FROM `glpi_plugin_fusioninventory_dblockinventorynames`
        WHERE `value`='" . $name . "'";
    $DB->query($query);

    return $errors;
}


/**
 * Send Computer to inventoryruleimport
 *
 * @param string $p_DEVICEID
 * @param array $arrayinventory
 */
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->fillArrayInventory($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_computerinventory['fusioninventorycomputer']['oscomment'])) AND (!empty($a_computerinventory['fusioninventorycomputer']['oscomment']))) {
        $input['oscomment'] = $a_computerinventory['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'];
    }

    $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)

    // * 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);
    }
}
最后編輯于
?著作權(quán)歸作者所有,轉(zhuǎn)載或內(nèi)容合作請(qǐng)聯(lián)系作者
平臺(tái)聲明:文章內(nèi)容(如有圖片或視頻亦包括在內(nèi))由作者上傳并發(fā)布,文章內(nèi)容僅代表作者本人觀點(diǎn),簡(jiǎn)書(shū)系信息發(fā)布平臺(tái),僅提供信息存儲(chǔ)服務(wù)。
  • 序言:七十年代末,一起剝皮案震驚了整個(gè)濱河市,隨后出現(xiàn)的幾起案子,更是在濱河造成了極大的恐慌,老刑警劉巖,帶你破解...
    沈念sama閱讀 230,321評(píng)論 6 543
  • 序言:濱河連續(xù)發(fā)生了三起死亡事件,死亡現(xiàn)場(chǎng)離奇詭異,居然都是意外死亡,警方通過(guò)查閱死者的電腦和手機(jī),發(fā)現(xiàn)死者居然都...
    沈念sama閱讀 99,559評(píng)論 3 429
  • 文/潘曉璐 我一進(jìn)店門(mén),熙熙樓的掌柜王于貴愁眉苦臉地迎上來(lái),“玉大人,你說(shuō)我怎么就攤上這事。” “怎么了?”我有些...
    開(kāi)封第一講書(shū)人閱讀 178,442評(píng)論 0 383
  • 文/不壞的土叔 我叫張陵,是天一觀的道長(zhǎng)。 經(jīng)常有香客問(wèn)我,道長(zhǎng),這世上最難降的妖魔是什么? 我笑而不...
    開(kāi)封第一講書(shū)人閱讀 63,835評(píng)論 1 317
  • 正文 為了忘掉前任,我火速辦了婚禮,結(jié)果婚禮上,老公的妹妹穿的比我還像新娘。我一直安慰自己,他們只是感情好,可當(dāng)我...
    茶點(diǎn)故事閱讀 72,581評(píng)論 6 412
  • 文/花漫 我一把揭開(kāi)白布。 她就那樣靜靜地躺著,像睡著了一般。 火紅的嫁衣襯著肌膚如雪。 梳的紋絲不亂的頭發(fā)上,一...
    開(kāi)封第一講書(shū)人閱讀 55,922評(píng)論 1 328
  • 那天,我揣著相機(jī)與錄音,去河邊找鬼。 笑死,一個(gè)胖子當(dāng)著我的面吹牛,可吹牛的內(nèi)容都是我干的。 我是一名探鬼主播,決...
    沈念sama閱讀 43,931評(píng)論 3 447
  • 文/蒼蘭香墨 我猛地睜開(kāi)眼,長(zhǎng)吁一口氣:“原來(lái)是場(chǎng)噩夢(mèng)啊……” “哼!你這毒婦竟也來(lái)了?” 一聲冷哼從身側(cè)響起,我...
    開(kāi)封第一講書(shū)人閱讀 43,096評(píng)論 0 290
  • 序言:老撾萬(wàn)榮一對(duì)情侶失蹤,失蹤者是張志新(化名)和其女友劉穎,沒(méi)想到半個(gè)月后,有當(dāng)?shù)厝嗽跇?shù)林里發(fā)現(xiàn)了一具尸體,經(jīng)...
    沈念sama閱讀 49,639評(píng)論 1 336
  • 正文 獨(dú)居荒郊野嶺守林人離奇死亡,尸身上長(zhǎng)有42處帶血的膿包…… 初始之章·張勛 以下內(nèi)容為張勛視角 年9月15日...
    茶點(diǎn)故事閱讀 41,374評(píng)論 3 358
  • 正文 我和宋清朗相戀三年,在試婚紗的時(shí)候發(fā)現(xiàn)自己被綠了。 大學(xué)時(shí)的朋友給我發(fā)了我未婚夫和他白月光在一起吃飯的照片。...
    茶點(diǎn)故事閱讀 43,591評(píng)論 1 374
  • 序言:一個(gè)原本活蹦亂跳的男人離奇死亡,死狀恐怖,靈堂內(nèi)的尸體忽然破棺而出,到底是詐尸還是另有隱情,我是刑警寧澤,帶...
    沈念sama閱讀 39,104評(píng)論 5 364
  • 正文 年R本政府宣布,位于F島的核電站,受9級(jí)特大地震影響,放射性物質(zhì)發(fā)生泄漏。R本人自食惡果不足惜,卻給世界環(huán)境...
    茶點(diǎn)故事閱讀 44,789評(píng)論 3 349
  • 文/蒙蒙 一、第九天 我趴在偏房一處隱蔽的房頂上張望。 院中可真熱鬧,春花似錦、人聲如沸。這莊子的主人今日做“春日...
    開(kāi)封第一講書(shū)人閱讀 35,196評(píng)論 0 28
  • 文/蒼蘭香墨 我抬頭看了看天上的太陽(yáng)。三九已至,卻和暖如春,著一層夾襖步出監(jiān)牢的瞬間,已是汗流浹背。 一陣腳步聲響...
    開(kāi)封第一講書(shū)人閱讀 36,524評(píng)論 1 295
  • 我被黑心中介騙來(lái)泰國(guó)打工, 沒(méi)想到剛下飛機(jī)就差點(diǎn)兒被人妖公主榨干…… 1. 我叫王不留,地道東北人。 一個(gè)月前我還...
    沈念sama閱讀 52,322評(píng)論 3 400
  • 正文 我出身青樓,卻偏偏與公主長(zhǎng)得像,于是被迫代替她去往敵國(guó)和親。 傳聞我的和親對(duì)象是個(gè)殘疾皇子,可洞房花燭夜當(dāng)晚...
    茶點(diǎn)故事閱讀 48,554評(píng)論 2 379

推薦閱讀更多精彩內(nèi)容