glpi电脑,软件数据库分析

查询电脑

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

电脑表结构关系
        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

软件表结构关系
    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`

查询磁盘信息

磁盘信息表结构
        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'

网络端口

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

网络端口表结构
        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


杀毒软件表结构
        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

遍历查询每个 devicecontrols_id 的具体信息

    SELECT
        *
    FROM
        `glpi_devicecontrols`
    WHERE
        `glpi_devicecontrols`.`id` = '3'
    LIMIT 1 
单个control id 对应的control具体信息

查询所有devices control信息

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

上报数据导入功能流程

  • 接收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';
    }

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

  • 写入数据库
    $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   数据库加锁操作
    $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 数据库解锁操作
    $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);
    }
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 206,723评论 6 481
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 88,485评论 2 382
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 152,998评论 0 344
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 55,323评论 1 279
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 64,355评论 5 374
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 49,079评论 1 285
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 38,389评论 3 400
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 37,019评论 0 259
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 43,519评论 1 300
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 35,971评论 2 325
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 38,100评论 1 333
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 33,738评论 4 324
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 39,293评论 3 307
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 30,289评论 0 19
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 31,517评论 1 262
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 45,547评论 2 354
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 42,834评论 2 345

推荐阅读更多精彩内容