当前位置: 首页>>代码示例>>PHP>>正文


PHP API::HostInterface方法代码示例

本文整理汇总了PHP中API::HostInterface方法的典型用法代码示例。如果您正苦于以下问题:PHP API::HostInterface方法的具体用法?PHP API::HostInterface怎么用?PHP API::HostInterface使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::HostInterface方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getItemFormData


//.........这里部分代码省略.........
        $data['interfaceid'] = $data['item']['interfaceid'];
        $data['type'] = $data['item']['type'];
        $data['snmp_community'] = $data['item']['snmp_community'];
        $data['snmp_oid'] = $data['item']['snmp_oid'];
        $data['port'] = $data['item']['port'];
        $data['value_type'] = $data['item']['value_type'];
        $data['data_type'] = $data['item']['data_type'];
        $data['trapper_hosts'] = $data['item']['trapper_hosts'];
        $data['units'] = $data['item']['units'];
        $data['valuemapid'] = $data['item']['valuemapid'];
        $data['multiplier'] = $data['item']['multiplier'];
        $data['hostid'] = $data['item']['hostid'];
        $data['params'] = $data['item']['params'];
        $data['snmpv3_contextname'] = $data['item']['snmpv3_contextname'];
        $data['snmpv3_securityname'] = $data['item']['snmpv3_securityname'];
        $data['snmpv3_securitylevel'] = $data['item']['snmpv3_securitylevel'];
        $data['snmpv3_authprotocol'] = $data['item']['snmpv3_authprotocol'];
        $data['snmpv3_authpassphrase'] = $data['item']['snmpv3_authpassphrase'];
        $data['snmpv3_privprotocol'] = $data['item']['snmpv3_privprotocol'];
        $data['snmpv3_privpassphrase'] = $data['item']['snmpv3_privpassphrase'];
        $data['ipmi_sensor'] = $data['item']['ipmi_sensor'];
        $data['authtype'] = $data['item']['authtype'];
        $data['username'] = $data['item']['username'];
        $data['password'] = $data['item']['password'];
        $data['publickey'] = $data['item']['publickey'];
        $data['privatekey'] = $data['item']['privatekey'];
        $data['logtimefmt'] = $data['item']['logtimefmt'];
        $data['new_application'] = getRequest('new_application', '');
        if (!$data['is_discovery_rule']) {
            $data['formula'] = $data['item']['formula'];
        }
        if (!$data['limited'] || !isset($_REQUEST['form_refresh'])) {
            $data['delay'] = $data['item']['delay'];
            if (($data['type'] == ITEM_TYPE_TRAPPER || $data['type'] == ITEM_TYPE_SNMPTRAP) && $data['delay'] == 0) {
                $data['delay'] = ZBX_ITEM_DELAY_DEFAULT;
            }
            $data['history'] = $data['item']['history'];
            $data['status'] = $data['item']['status'];
            $data['delta'] = $data['item']['delta'];
            $data['trends'] = $data['item']['trends'];
            $db_delay_flex = $data['item']['delay_flex'];
            if (isset($db_delay_flex)) {
                $arr_of_dellays = explode(';', $db_delay_flex);
                foreach ($arr_of_dellays as $one_db_delay) {
                    $arr_of_delay = explode('/', $one_db_delay);
                    if (!isset($arr_of_delay[0]) || !isset($arr_of_delay[1])) {
                        continue;
                    }
                    array_push($data['delay_flex'], array('delay' => $arr_of_delay[0], 'period' => $arr_of_delay[1]));
                }
            }
            $data['applications'] = array_unique(zbx_array_merge($data['applications'], get_applications_by_itemid($data['itemid'])));
        }
    }
    // applications
    if (count($data['applications']) == 0) {
        array_push($data['applications'], 0);
    }
    $data['db_applications'] = DBfetchArray(DBselect('SELECT DISTINCT a.applicationid,a.name' . ' FROM applications a' . ' WHERE a.hostid=' . zbx_dbstr($data['hostid'])));
    order_result($data['db_applications'], 'name');
    // interfaces
    $data['interfaces'] = API::HostInterface()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND));
    // valuemapid
    if ($data['limited']) {
        if (!empty($data['valuemapid'])) {
            if ($map_data = DBfetch(DBselect('SELECT v.name FROM valuemaps v WHERE v.valuemapid=' . zbx_dbstr($data['valuemapid'])))) {
                $data['valuemaps'] = $map_data['name'];
            }
        }
    } else {
        $data['valuemaps'] = DBfetchArray(DBselect('SELECT v.* FROM valuemaps v'));
        order_result($data['valuemaps'], 'name');
    }
    // possible host inventories
    if (empty($data['parent_discoveryid'])) {
        $data['possibleHostInventories'] = getHostInventories();
        // get already populated fields by other items
        $data['alreadyPopulated'] = API::item()->get(array('output' => array('inventory_link'), 'filter' => array('hostid' => $data['hostid']), 'nopermissions' => true));
        $data['alreadyPopulated'] = zbx_toHash($data['alreadyPopulated'], 'inventory_link');
    }
    // template
    $data['is_template'] = isTemplate($data['hostid']);
    // unset snmpv3 fields
    if ($data['type'] != ITEM_TYPE_SNMPV3) {
        $data['snmpv3_contextname'] = '';
        $data['snmpv3_securityname'] = '';
        $data['snmpv3_securitylevel'] = ITEM_SNMPV3_SECURITYLEVEL_NOAUTHNOPRIV;
        $data['snmpv3_authprotocol'] = ITEM_AUTHPROTOCOL_MD5;
        $data['snmpv3_authpassphrase'] = '';
        $data['snmpv3_privprotocol'] = ITEM_PRIVPROTOCOL_DES;
        $data['snmpv3_privpassphrase'] = '';
    }
    // unset ssh auth fields
    if ($data['type'] != ITEM_TYPE_SSH) {
        $data['authtype'] = ITEM_AUTHTYPE_PASSWORD;
        $data['publickey'] = '';
        $data['privatekey'] = '';
    }
    return $data;
}
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:forms.inc.php

示例2: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $hostids = array_keys($result);
     // adding inventories
     if ($options['selectInventory'] !== null) {
         $relationMap = $this->createRelationMap($result, 'hostid', 'hostid');
         $inventory = API::getApiService()->select('host_inventory', ['output' => $options['selectInventory'], 'filter' => ['hostid' => $hostids]]);
         $result = $relationMap->mapOne($result, zbx_toHash($inventory, 'hostid'), 'inventory');
     }
     // adding hostinterfaces
     if ($options['selectInterfaces'] !== null) {
         if ($options['selectInterfaces'] != API_OUTPUT_COUNT) {
             $interfaces = API::HostInterface()->get(['output' => $this->outputExtend($options['selectInterfaces'], ['hostid', 'interfaceid']), 'hostids' => $hostids, 'nopermissions' => true, 'preservekeys' => true]);
             // we need to order interfaces for proper linkage and viewing
             order_result($interfaces, 'interfaceid', ZBX_SORT_UP);
             $relationMap = $this->createRelationMap($interfaces, 'hostid', 'interfaceid');
             $interfaces = $this->unsetExtraFields($interfaces, ['hostid', 'interfaceid'], $options['selectInterfaces']);
             $result = $relationMap->mapMany($result, $interfaces, 'interfaces', $options['limitSelects']);
         } else {
             $interfaces = API::HostInterface()->get(['hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true]);
             $interfaces = zbx_toHash($interfaces, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['interfaces'] = isset($interfaces[$hostid]) ? $interfaces[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding screens
     if ($options['selectScreens'] !== null) {
         if ($options['selectScreens'] != API_OUTPUT_COUNT) {
             $screens = API::TemplateScreen()->get(['output' => $this->outputExtend($options['selectScreens'], ['hostid']), 'hostids' => $hostids, 'nopermissions' => true]);
             if (!is_null($options['limitSelects'])) {
                 order_result($screens, 'name');
             }
             // inherited screens do not have a unique screenid, so we're building a map using array keys
             $relationMap = new CRelationMap();
             foreach ($screens as $key => $screen) {
                 $relationMap->addRelation($screen['hostid'], $key);
             }
             $screens = $this->unsetExtraFields($screens, ['hostid'], $options['selectScreens']);
             $result = $relationMap->mapMany($result, $screens, 'screens', $options['limitSelects']);
         } else {
             $screens = API::TemplateScreen()->get(['hostids' => $hostids, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true]);
             $screens = zbx_toHash($screens, 'hostid');
             foreach ($result as $hostid => $host) {
                 $result[$hostid]['screens'] = isset($screens[$hostid]) ? $screens[$hostid]['rowscount'] : 0;
             }
         }
     }
     // adding discovery rule
     if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) {
         // discovered items
         $discoveryRules = DBFetchArray(DBselect('SELECT hd.hostid,hd2.parent_itemid' . ' FROM host_discovery hd,host_discovery hd2' . ' WHERE ' . dbConditionInt('hd.hostid', $hostids) . ' AND hd.parent_hostid=hd2.hostid'));
         $relationMap = $this->createRelationMap($discoveryRules, 'hostid', 'parent_itemid');
         $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     // adding host discovery
     if ($options['selectHostDiscovery'] !== null) {
         $hostDiscoveries = API::getApiService()->select('host_discovery', ['output' => $this->outputExtend($options['selectHostDiscovery'], ['hostid']), 'filter' => ['hostid' => $hostids], 'preservekeys' => true]);
         $relationMap = $this->createRelationMap($hostDiscoveries, 'hostid', 'hostid');
         $hostDiscoveries = $this->unsetExtraFields($hostDiscoveries, ['hostid'], $options['selectHostDiscovery']);
         $result = $relationMap->mapOne($result, $hostDiscoveries, 'hostDiscovery');
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:66,代码来源:CHost.php

示例3: addInterfaceIds

 /**
  * For existing hosts we need to set an interfaceid for existing interfaces or they will be added.
  *
  * @param array $xmlHosts    hosts from XML for which interfaces will be added
  *
  * @return array
  */
 protected function addInterfaceIds(array $xmlHosts)
 {
     $dbInterfaces = API::HostInterface()->get(array('hostids' => zbx_objectValues($xmlHosts, 'hostid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     // build lookup maps for:
     // - interfaces per host
     // - default (primary) interface ids per host per interface type
     $dbHostInterfaces = array();
     $dbHostMainInterfaceIds = array();
     foreach ($dbInterfaces as $dbInterface) {
         $dbHostId = $dbInterface['hostid'];
         $dbHostInterfaces[$dbHostId][] = $dbInterface;
         if ($dbInterface['main'] == INTERFACE_PRIMARY) {
             $dbHostMainInterfaceIds[$dbHostId][$dbInterface['type']] = $dbInterface['interfaceid'];
         }
     }
     foreach ($xmlHosts as &$xmlHost) {
         // if interfaces in XML are empty then do not touch existing interfaces
         if (!$xmlHost['interfaces']) {
             unset($xmlHost['interfaces']);
             continue;
         }
         $xmlHostId = $xmlHost['hostid'];
         $currentDbHostMainInterfaceIds = isset($dbHostMainInterfaceIds[$xmlHostId]) ? $dbHostMainInterfaceIds[$xmlHostId] : array();
         $reusedInterfaceIds = array();
         foreach ($xmlHost['interfaces'] as &$xmlHostInterface) {
             $xmlHostInterfaceType = $xmlHostInterface['type'];
             // check if an existing interfaceid from current host can be reused
             // in case there is default (primary) interface in current host with same type
             if ($xmlHostInterface['main'] == INTERFACE_PRIMARY && isset($currentDbHostMainInterfaceIds[$xmlHostInterfaceType])) {
                 $dbHostInterfaceId = $currentDbHostMainInterfaceIds[$xmlHostInterfaceType];
                 $xmlHostInterface['interfaceid'] = $dbHostInterfaceId;
                 $reusedInterfaceIds[$dbHostInterfaceId] = true;
             }
         }
         unset($xmlHostInterface);
         // loop through all interfaces of current host and take interfaceids from ones that
         // match completely, ignoring hosts from XML with set interfaceids and ignoring hosts
         // from DB with reused interfaceids
         foreach ($xmlHost['interfaces'] as &$xmlHostInterface) {
             foreach ($dbHostInterfaces[$xmlHostId] as $dbHostInterface) {
                 $dbHostInterfaceId = $dbHostInterface['interfaceid'];
                 if (!isset($xmlHostInterface['interfaceid']) && !isset($reusedInterfaceIds[$dbHostInterfaceId]) && $dbHostInterface['ip'] == $xmlHostInterface['ip'] && $dbHostInterface['dns'] == $xmlHostInterface['dns'] && $dbHostInterface['useip'] == $xmlHostInterface['useip'] && $dbHostInterface['port'] == $xmlHostInterface['port'] && $dbHostInterface['type'] == $xmlHostInterface['type'] && $dbHostInterface['bulk'] == $xmlHostInterface['bulk']) {
                     $xmlHostInterface['interfaceid'] = $dbHostInterfaceId;
                     $reusedInterfaceIds[$dbHostInterfaceId] = true;
                     break;
                 }
             }
         }
         unset($xmlHostInterface);
     }
     unset($xmlHost);
     return $xmlHosts;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:60,代码来源:CHostImporter.php

示例4: checkInput

 /**
  * Check items data.
  *
  * Any system field passed to the function will be unset.
  *
  * @throw APIException
  *
  * @param array $items passed by reference
  * @param bool  $update
  *
  * @return void
  */
 protected function checkInput(array &$items, $update = false)
 {
     if ($update) {
         $itemDbFields = array('itemid' => null);
         $dbItemsFields = array('itemid', 'templateid');
         foreach ($this->fieldRules as $field => $rule) {
             if (!isset($rule['system'])) {
                 $dbItemsFields[] = $field;
             }
         }
         $dbItems = $this->get(array('output' => $dbItemsFields, 'itemids' => zbx_objectValues($items, 'itemid'), 'editable' => true, 'preservekeys' => true));
         $dbHosts = API::Host()->get(array('output' => array('hostid', 'status', 'name'), 'hostids' => zbx_objectValues($dbItems, 'hostid'), 'templated_hosts' => true, 'editable' => true, 'selectApplications' => API_OUTPUT_REFER, 'preservekeys' => true));
     } else {
         $itemDbFields = array('name' => null, 'key_' => null, 'hostid' => null, 'type' => null, 'value_type' => null, 'delay' => '0', 'delay_flex' => '');
         $dbHosts = API::Host()->get(array('output' => array('hostid', 'status', 'name'), 'hostids' => zbx_objectValues($items, 'hostid'), 'templated_hosts' => true, 'editable' => true, 'selectApplications' => API_OUTPUT_REFER, 'preservekeys' => true));
     }
     // interfaces
     $interfaces = API::HostInterface()->get(array('output' => array('interfaceid', 'hostid', 'type'), 'hostids' => zbx_objectValues($dbHosts, 'hostid'), 'nopermissions' => true, 'preservekeys' => true));
     if ($update) {
         $updateDiscoveredValidator = new CUpdateDiscoveredValidator(array('allowed' => array('itemid', 'status'), 'messageAllowedField' => _('Cannot update "%1$s" for a discovered item.')));
         foreach ($items as $item) {
             // check permissions
             if (!isset($dbItems[$item['itemid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             // discovered fields, except status, cannot be updated
             $this->checkPartialValidator($item, $updateDiscoveredValidator, $dbItems[$item['itemid']]);
         }
         $items = $this->extendObjects($this->tableName(), $items, array('name'));
     }
     foreach ($items as $inum => &$item) {
         $item = $this->clearValues($item);
         $fullItem = $items[$inum];
         if (!check_db_fields($itemDbFields, $item)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to function.'));
         }
         if ($update) {
             check_db_fields($dbItems[$item['itemid']], $fullItem);
             $this->checkNoParameters($item, array('templateid', 'state'), _('Cannot update "%1$s" for item "%2$s".'), $item['name']);
             // apply rules
             foreach ($this->fieldRules as $field => $rules) {
                 if (0 != $fullItem['templateid'] && isset($rules['template']) || isset($rules['system'])) {
                     unset($item[$field]);
                 }
             }
             if (!isset($item['key_'])) {
                 $item['key_'] = $fullItem['key_'];
             }
             if (!isset($item['hostid'])) {
                 $item['hostid'] = $fullItem['hostid'];
             }
             // if a templated item is being assigned to an interface with a different type, ignore it
             $itemInterfaceType = itemTypeInterface($dbItems[$item['itemid']]['type']);
             if ($fullItem['templateid'] && isset($item['interfaceid']) && isset($interfaces[$item['interfaceid']]) && $itemInterfaceType !== INTERFACE_TYPE_ANY && $interfaces[$item['interfaceid']]['type'] != $itemInterfaceType) {
                 unset($item['interfaceid']);
             }
         } else {
             if (!isset($dbHosts[$item['hostid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             check_db_fields($itemDbFields, $fullItem);
             $this->checkNoParameters($item, array('templateid', 'state'), _('Cannot set "%1$s" for item "%2$s".'), $item['name']);
         }
         $host = $dbHosts[$fullItem['hostid']];
         if ($fullItem['type'] == ITEM_TYPE_ZABBIX_ACTIVE) {
             $item['delay_flex'] = '';
         }
         if ($fullItem['value_type'] == ITEM_VALUE_TYPE_STR) {
             $item['delta'] = 0;
         }
         if ($fullItem['value_type'] != ITEM_VALUE_TYPE_UINT64) {
             $item['data_type'] = 0;
         }
         // check if the item requires an interface
         $itemInterfaceType = itemTypeInterface($fullItem['type']);
         if ($itemInterfaceType !== false && $host['status'] != HOST_STATUS_TEMPLATE) {
             if (!$fullItem['interfaceid']) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No interface found.'));
             } elseif (!isset($interfaces[$fullItem['interfaceid']]) || bccomp($interfaces[$fullItem['interfaceid']]['hostid'], $fullItem['hostid']) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Item uses host interface from non-parent host.'));
             } elseif ($itemInterfaceType !== INTERFACE_TYPE_ANY && $interfaces[$fullItem['interfaceid']]['type'] != $itemInterfaceType) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Item uses incorrect interface type.'));
             }
         } else {
             $item['interfaceid'] = 0;
         }
         // item key
         if ($fullItem['type'] == ITEM_TYPE_DB_MONITOR && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_DB_MONITOR) == 0 || $fullItem['type'] == ITEM_TYPE_SSH && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_SSH) == 0 || $fullItem['type'] == ITEM_TYPE_TELNET && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_TELNET) == 0 || $fullItem['type'] == ITEM_TYPE_JMX && strcmp($fullItem['key_'], ZBX_DEFAULT_KEY_JMX) == 0) {
//.........这里部分代码省略.........
开发者ID:hujingguang,项目名称:work,代码行数:101,代码来源:CItemGeneral.php

示例5: array

    if (!empty($data['templates'])) {
        $getLinkedTemplates = API::Template()->get(array('templateids' => $data['templates'], 'output' => array('templateid', 'name')));
        foreach ($getLinkedTemplates as $getLinkedTemplate) {
            $data['linkedTemplates'][] = array('id' => $getLinkedTemplate['templateid'], 'name' => $getLinkedTemplate['name']);
        }
    }
    $hostForm = new CView('configuration.host.massupdate', $data);
    $hostsWidget->addItem($hostForm->render());
} elseif (isset($_REQUEST['form'])) {
    $hostsWidget->addPageHeader(_('CONFIGURATION OF HOSTS'));
    $data = array();
    if ($hostId = get_request('hostid', 0)) {
        $hostsWidget->addItem(get_header_host_table('', $_REQUEST['hostid']));
        $dbHosts = API::Host()->get(array('hostids' => $hostId, 'selectGroups' => API_OUTPUT_EXTEND, 'selectParentTemplates' => array('templateid', 'name'), 'selectMacros' => API_OUTPUT_EXTEND, 'selectInventory' => true, 'selectDiscoveryRule' => array('name', 'itemid'), 'output' => API_OUTPUT_EXTEND));
        $dbHost = reset($dbHosts);
        $dbHost['interfaces'] = API::HostInterface()->get(array('hostids' => $hostId, 'output' => API_OUTPUT_EXTEND, 'selectItems' => array('type'), 'sortfield' => 'interfaceid', 'preservekeys' => true));
        $data['dbHost'] = $dbHost;
    }
    $hostForm = new CView('configuration.host.edit', $data);
    $hostsWidget->addItem($hostForm->render());
    $rootClass = 'host-edit';
    if (get_request('hostid') && $dbHost['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
        $rootClass .= ' host-edit-discovered';
    }
    $hostsWidget->setRootClass($rootClass);
} else {
    $displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0;
    $frmForm = new CForm();
    $frmForm->cleanItems();
    $frmForm->addItem(new CDiv(array(new CSubmit('form', _('Create host')), new CButton('form', _('Import'), 'redirect("conf.import.php?rules_preset=host")'))));
    $frmForm->addItem(new CVar('groupid', $_REQUEST['groupid'], 'filter_groupid_id'));
开发者ID:micromachine,项目名称:RackTables-ZABBIX-bridge,代码行数:31,代码来源:hosts.php

示例6: addInterfaceIds

 /**
  * For existing hosts we need to set an interfaceid for existing interfaces or they will be added.
  *
  * @param array $hosts
  *
  * @return array
  */
 protected function addInterfaceIds(array $hosts)
 {
     $dbInterfaces = API::HostInterface()->get(array('hostids' => zbx_objectValues($hosts, 'hostid'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     foreach ($dbInterfaces as $dbInterface) {
         foreach ($hosts as $hnum => $host) {
             if (!empty($host['interfaces']) && idcmp($host['hostid'], $dbInterface['hostid'])) {
                 foreach ($host['interfaces'] as $inum => $interface) {
                     if ($dbInterface['ip'] == $interface['ip'] && $dbInterface['dns'] == $interface['dns'] && $dbInterface['useip'] == $interface['useip'] && $dbInterface['port'] == $interface['port'] && $dbInterface['type'] == $interface['type'] && $dbInterface['main'] == $interface['main']) {
                         $hosts[$hnum]['interfaces'][$inum]['interfaceid'] = $dbInterface['interfaceid'];
                         break;
                     }
                 }
             }
             if (empty($hosts[$hnum]['interfaces'])) {
                 unset($hosts[$hnum]['interfaces']);
             }
         }
     }
     return $hosts;
 }
开发者ID:hujingguang,项目名称:work,代码行数:27,代码来源:CHostImporter.php

示例7: massRemove

 /**
  * Additionally allows to remove interfaces from hosts.
  *
  * Checks write permissions for hosts.
  *
  * Additional supported $data parameters are:
  * - interfaces  - an array of interfaces to delete from the hosts
  *
  * @param array $data
  *
  * @return array
  */
 public function massRemove(array $data)
 {
     $hostids = zbx_toArray($data['hostids']);
     // check permissions
     if (!$this->isWritable($hostids)) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.'));
     }
     if (isset($data['interfaces'])) {
         $options = array('hostids' => $hostids, 'interfaces' => zbx_toArray($data['interfaces']));
         API::HostInterface()->massRemove($options);
     }
     // rename the "templates" parameter to the common "templates_link"
     if (isset($data['templateids'])) {
         $data['templateids_link'] = $data['templateids'];
         unset($data['templateids']);
     }
     $data['templateids'] = array();
     return parent::massRemove($data);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:CHost.php

示例8: get


//.........这里部分代码省略.........
         }
     }
     if (!is_null($options['countOutput'])) {
         return $result;
     }
     /*
      * Adding objects
      */
     // adding hosts
     if (!is_null($options['selectHosts'])) {
         if (is_array($options['selectHosts']) || str_in_array($options['selectHosts'], $subselectsAllowedOutputs)) {
             $objParams = array('nodeids' => $options['nodeids'], 'itemids' => $itemids, 'templated_hosts' => true, 'output' => $options['selectHosts'], 'nopermissions' => true, 'preservekeys' => true);
             $hosts = API::Host()->get($objParams);
             foreach ($hosts as $host) {
                 $hitems = $host['items'];
                 unset($host['items']);
                 foreach ($hitems as $item) {
                     $result[$item['itemid']]['hosts'][] = $host;
                 }
             }
             $templates = API::Template()->get($objParams);
             foreach ($templates as $template) {
                 $titems = $template['items'];
                 unset($template['items']);
                 foreach ($titems as $item) {
                     $result[$item['itemid']]['hosts'][] = $template;
                 }
             }
         }
     }
     // adding interfaces
     if (!is_null($options['selectInterfaces'])) {
         if (is_array($options['selectInterfaces']) || str_in_array($options['selectInterfaces'], $subselectsAllowedOutputs)) {
             $interfaces = API::HostInterface()->get(array('nodeids' => $options['nodeids'], 'itemids' => $itemids, 'output' => $options['selectInterfaces'], 'nopermissions' => true, 'preservekeys' => true));
             foreach ($interfaces as $interface) {
                 $hitems = $interface['items'];
                 unset($interface['items']);
                 foreach ($hitems as $item) {
                     $result[$item['itemid']]['interfaces'][] = $interface;
                 }
             }
         }
     }
     // adding triggers
     if (!is_null($options['selectTriggers'])) {
         $objParams = array('nodeids' => $options['nodeids'], 'itemids' => $itemids, 'preservekeys' => true);
         if (in_array($options['selectTriggers'], $subselectsAllowedOutputs)) {
             $objParams['output'] = $options['selectTriggers'];
             $triggers = API::Trigger()->get($objParams);
             if (!is_null($options['limitSelects'])) {
                 order_result($triggers, 'description');
             }
             foreach ($triggers as $triggerid => $trigger) {
                 unset($triggers[$triggerid]['items']);
                 $count = array();
                 foreach ($trigger['items'] as $item) {
                     // skip trigger assignment for unwanted items from other hosts
                     if (!isset($result[$item['itemid']])) {
                         continue;
                     }
                     if (!is_null($options['limitSelects'])) {
                         if (!isset($count[$item['itemid']])) {
                             $count[$item['itemid']] = 0;
                         }
                         $count[$item['itemid']]++;
                         if ($count[$item['itemid']] > $options['limitSelects']) {
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:67,代码来源:CItem.php

示例9: checkMainInterfacesOnDelete

 private function checkMainInterfacesOnDelete(array $interfaceIds)
 {
     $this->checkIfInterfaceHasItems($interfaceIds);
     $hostids = array();
     $dbResult = DBselect('SELECT DISTINCT i.hostid FROM interface i WHERE ' . dbConditionInt('i.interfaceid', $interfaceIds));
     while ($hostData = DBfetch($dbResult)) {
         $hostids[$hostData['hostid']] = $hostData['hostid'];
     }
     $dbInterfaces = API::HostInterface()->get(array('hostids' => $hostids, 'output' => array('hostid', 'main', 'type'), 'preservekeys' => true, 'nopermissions' => true));
     foreach ($interfaceIds as $interfaceId) {
         unset($dbInterfaces[$interfaceId]);
     }
     $this->checkMainInterfaces($dbInterfaces);
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:14,代码来源:CHostInterface.php

示例10: checkInput

 /**
  * Check items data.
  *
  * Any system field passed to the function will be unset.
  *
  * @throw APIException
  *
  * @param array $items passed by reference
  * @param bool  $update
  *
  * @return void
  */
 protected function checkInput(array &$items, $update = false)
 {
     if ($update) {
         $itemDbFields = ['itemid' => null];
         $dbItemsFields = ['itemid', 'templateid'];
         foreach ($this->fieldRules as $field => $rule) {
             if (!isset($rule['system'])) {
                 $dbItemsFields[] = $field;
             }
         }
         $dbItems = $this->get(['output' => $dbItemsFields, 'itemids' => zbx_objectValues($items, 'itemid'), 'editable' => true, 'preservekeys' => true]);
         $dbHosts = API::Host()->get(['output' => ['hostid', 'status', 'name'], 'hostids' => zbx_objectValues($dbItems, 'hostid'), 'templated_hosts' => true, 'editable' => true, 'selectApplications' => ['applicationid', 'flags'], 'preservekeys' => true]);
     } else {
         $itemDbFields = ['name' => null, 'key_' => null, 'hostid' => null, 'type' => null, 'value_type' => null, 'delay' => '0', 'delay_flex' => ''];
         $dbHosts = API::Host()->get(['output' => ['hostid', 'status', 'name'], 'hostids' => zbx_objectValues($items, 'hostid'), 'templated_hosts' => true, 'editable' => true, 'selectApplications' => ['applicationid', 'flags'], 'preservekeys' => true]);
     }
     // interfaces
     $interfaces = API::HostInterface()->get(['output' => ['interfaceid', 'hostid', 'type'], 'hostids' => zbx_objectValues($dbHosts, 'hostid'), 'nopermissions' => true, 'preservekeys' => true]);
     if ($update) {
         $updateDiscoveredValidator = new CUpdateDiscoveredValidator(['allowed' => ['itemid', 'status'], 'messageAllowedField' => _('Cannot update "%2$s" for a discovered item "%1$s".')]);
         foreach ($items as $item) {
             // check permissions
             if (!isset($dbItems[$item['itemid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             $dbItem = $dbItems[$item['itemid']];
             $itemName = isset($item['name']) ? $item['name'] : $dbItem['name'];
             // discovered fields, except status, cannot be updated
             $updateDiscoveredValidator->setObjectName($itemName);
             $this->checkPartialValidator($item, $updateDiscoveredValidator, $dbItem);
         }
         $items = $this->extendObjects($this->tableName(), $items, ['name', 'flags']);
     }
     $item_key_parser = new CItemKey();
     foreach ($items as $inum => &$item) {
         $item = $this->clearValues($item);
         $fullItem = $items[$inum];
         if (!check_db_fields($itemDbFields, $item)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to function.'));
         }
         if ($update) {
             check_db_fields($dbItems[$item['itemid']], $fullItem);
             $this->checkNoParameters($item, ['templateid', 'state'], _('Cannot update "%1$s" for item "%2$s".'), $item['name']);
             // apply rules
             foreach ($this->fieldRules as $field => $rules) {
                 if (0 != $fullItem['templateid'] && isset($rules['template']) || isset($rules['system'])) {
                     unset($item[$field]);
                     // For templated item and fields that should not be modified, use the value from DB.
                     if (array_key_exists($field, $dbItems[$item['itemid']]) && array_key_exists($field, $fullItem)) {
                         $fullItem[$field] = $dbItems[$item['itemid']][$field];
                     }
                 }
             }
             if (!isset($item['key_'])) {
                 $item['key_'] = $fullItem['key_'];
             }
             if (!isset($item['hostid'])) {
                 $item['hostid'] = $fullItem['hostid'];
             }
             // if a templated item is being assigned to an interface with a different type, ignore it
             $itemInterfaceType = itemTypeInterface($dbItems[$item['itemid']]['type']);
             if ($fullItem['templateid'] && isset($item['interfaceid']) && isset($interfaces[$item['interfaceid']]) && $itemInterfaceType !== INTERFACE_TYPE_ANY && $interfaces[$item['interfaceid']]['type'] != $itemInterfaceType) {
                 unset($item['interfaceid']);
             }
         } else {
             if (!isset($dbHosts[$item['hostid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             check_db_fields($itemDbFields, $fullItem);
             $this->checkNoParameters($item, ['templateid', 'state'], _('Cannot set "%1$s" for item "%2$s".'), $item['name']);
         }
         $host = $dbHosts[$fullItem['hostid']];
         if ($fullItem['type'] == ITEM_TYPE_ZABBIX_ACTIVE) {
             $item['delay_flex'] = '';
         }
         if ($fullItem['value_type'] == ITEM_VALUE_TYPE_STR) {
             $item['delta'] = 0;
         }
         if ($fullItem['value_type'] != ITEM_VALUE_TYPE_UINT64) {
             $item['data_type'] = 0;
         }
         // For non-numeric types, whichever value was entered in trends field, is overwritten to zero.
         if ($fullItem['value_type'] == ITEM_VALUE_TYPE_STR || $fullItem['value_type'] == ITEM_VALUE_TYPE_LOG || $fullItem['value_type'] == ITEM_VALUE_TYPE_TEXT) {
             $item['trends'] = 0;
         }
         // check if the item requires an interface
         $itemInterfaceType = itemTypeInterface($fullItem['type']);
         if ($itemInterfaceType !== false && $host['status'] != HOST_STATUS_TEMPLATE) {
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:CItemGeneral.php

示例11: CView

    $hostView = new CView('configuration.host.massupdate', $data);
} elseif (hasRequest('form')) {
    $data = ['form' => getRequest('form', ''), 'hostid' => getRequest('hostid', 0), 'clone_hostid' => getRequest('clone_hostid', 0), 'groupid' => getRequest('groupid', 0), 'flags' => getRequest('flags', ZBX_FLAG_DISCOVERY_NORMAL), 'host' => getRequest('host', ''), 'visiblename' => getRequest('visiblename', ''), 'groups' => getRequest('groups', []), 'newgroup' => getRequest('newgroup', ''), 'interfaces' => getRequest('interfaces', []), 'mainInterfaces' => getRequest('mainInterfaces', []), 'description' => getRequest('description', ''), 'proxy_hostid' => getRequest('proxy_hostid', 0), 'status' => getRequest('status', HOST_STATUS_NOT_MONITORED), 'templates' => getRequest('templates', []), 'clear_templates' => getRequest('clear_templates', []), 'original_templates' => [], 'linked_templates' => [], 'ipmi_authtype' => getRequest('ipmi_authtype', IPMI_AUTHTYPE_DEFAULT), 'ipmi_privilege' => getRequest('ipmi_privilege', IPMI_PRIVILEGE_USER), 'ipmi_username' => getRequest('ipmi_username', ''), 'ipmi_password' => getRequest('ipmi_password', ''), 'macros' => $macros, 'show_inherited_macros' => getRequest('show_inherited_macros', 0), 'inventory_mode' => getRequest('inventory_mode', $config['default_inventory_mode']), 'host_inventory' => getRequest('host_inventory', []), 'inventory_items' => [], 'tls_connect' => getRequest('tls_connect', HOST_ENCRYPTION_NONE), 'tls_accept' => getRequest('tls_accept', HOST_ENCRYPTION_NONE), 'tls_issuer' => getRequest('tls_issuer', ''), 'tls_subject' => getRequest('tls_subject', ''), 'tls_psk_identity' => getRequest('tls_psk_identity', ''), 'tls_psk' => getRequest('tls_psk', '')];
    if (!hasRequest('form_refresh')) {
        if ($data['hostid'] != 0) {
            $dbHosts = API::Host()->get(['output' => ['hostid', 'proxy_hostid', 'host', 'name', 'status', 'ipmi_authtype', 'ipmi_privilege', 'ipmi_username', 'ipmi_password', 'flags', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk'], 'selectGroups' => ['groupid'], 'selectParentTemplates' => ['templateid'], 'selectMacros' => ['hostmacroid', 'macro', 'value'], 'selectDiscoveryRule' => ['itemid', 'name'], 'selectInventory' => true, 'hostids' => [$data['hostid']]]);
            $dbHost = reset($dbHosts);
            $data['flags'] = $dbHost['flags'];
            if ($data['flags'] == ZBX_FLAG_DISCOVERY_CREATED) {
                $data['discoveryRule'] = $dbHost['discoveryRule'];
            }
            // Host
            $data['host'] = $dbHost['host'];
            $data['visiblename'] = $dbHost['name'];
            $data['groups'] = zbx_objectValues($dbHost['groups'], 'groupid');
            $data['interfaces'] = API::HostInterface()->get(['output' => ['interfaceid', 'main', 'type', 'useip', 'ip', 'dns', 'port', 'bulk'], 'selectItems' => ['type'], 'hostids' => [$data['hostid']], 'sortfield' => 'interfaceid']);
            $data['description'] = $dbHost['description'];
            $data['proxy_hostid'] = $dbHost['proxy_hostid'];
            $data['status'] = $dbHost['status'];
            // Templates
            $data['templates'] = zbx_objectValues($dbHost['parentTemplates'], 'templateid');
            $data['original_templates'] = array_combine($data['templates'], $data['templates']);
            // IPMI
            $data['ipmi_authtype'] = $dbHost['ipmi_authtype'];
            $data['ipmi_privilege'] = $dbHost['ipmi_privilege'];
            $data['ipmi_username'] = $dbHost['ipmi_username'];
            $data['ipmi_password'] = $dbHost['ipmi_password'];
            // Macros
            $data['macros'] = $dbHost['macros'];
            // Interfaces
            foreach ($data['interfaces'] as &$interface) {
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:hosts.php

示例12: parseMain


//.........这里部分代码省略.........
             }
             $current_hostid = isset($processedHostIds[$host_db['host']]) ? $processedHostIds[$host_db['host']] : false;
             if (!$current_hostid) {
                 continue;
             }
             $oldVersionInput = $host_db['status'] != HOST_STATUS_TEMPLATE;
             // TEMPLATES {{{
             if (!empty($rules['templateLinkage']['createMissing'])) {
                 $templates = $xpath->query('templates/template', $host);
                 $templateLinkage = array();
                 foreach ($templates as $template) {
                     $options = array('filter' => array('host' => $template->nodeValue), 'output' => array('templateid'), 'editable' => true);
                     $current_template = API::Template()->get($options);
                     if (empty($current_template)) {
                         throw new Exception(_s('No permission for template "%1$s".', $template->nodeValue));
                     }
                     $current_template = reset($current_template);
                     $templateLinkage[] = $current_template;
                 }
                 if ($templateLinkage) {
                     $result = API::Template()->massAdd(array('hosts' => array('hostid' => $current_hostid), 'templates' => $templateLinkage));
                     if (!$result) {
                         throw new Exception();
                     }
                 }
             }
             // }}} TEMPLATES
             // ITEMS {{{
             if ($rules['items']['updateExisting'] || $rules['items']['createMissing'] || $rules['applications']['createMissing']) {
                 // applications are located under items in version 1.8,
                 // so we need to get item list in any of these cases
                 $items = $xpath->query('items/item', $host);
                 if ($oldVersionInput) {
                     $interfaces = API::HostInterface()->get(array('hostids' => $current_hostid, 'output' => API_OUTPUT_EXTEND));
                     // we must know interface ids to assign them to items
                     $agent_interface_id = null;
                     $ipmi_interface_id = null;
                     $snmp_interfaces = array();
                     // hash 'port' => 'interfaceid'
                     foreach ($interfaces as $interface) {
                         switch ($interface['type']) {
                             case INTERFACE_TYPE_AGENT:
                                 $agent_interface_id = $interface['interfaceid'];
                                 break;
                             case INTERFACE_TYPE_IPMI:
                                 $ipmi_interface_id = $interface['interfaceid'];
                                 break;
                             case INTERFACE_TYPE_SNMP:
                                 $snmp_interfaces[$interface['port']] = $interface['interfaceid'];
                                 break;
                         }
                     }
                 }
                 // if this is an export from 1.8, we need to make some adjustments to items
                 // cycle each XML item
                 foreach ($items as $item) {
                     if ($rules['items']['updateExisting'] || $rules['items']['createMissing']) {
                         $item_db = self::mapXML2arr($item, XML_TAG_ITEM);
                         $item_db['hostid'] = $current_hostid;
                         // item needs interfaces
                         if ($oldVersionInput) {
                             // 'snmp_port' column was renamed to 'port'
                             if ($item_db['snmp_port'] != 0) {
                                 // zabbix agent items have no ports
                                 $item_db['port'] = $item_db['snmp_port'];
                             }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:67,代码来源:CXmlImport18.php

示例13: update

 public function update($proxies)
 {
     $proxies = zbx_toArray($proxies);
     $proxyids = array();
     $this->checkInput($proxies, __FUNCTION__);
     $proxyUpdate = array();
     $hostUpdate = array();
     foreach ($proxies as $proxy) {
         $proxyids[] = $proxy['proxyid'];
         $proxyUpdate[] = array('values' => $proxy, 'where' => array('hostid' => $proxy['proxyid']));
         if (!isset($proxy['hosts'])) {
             continue;
         }
         $hostUpdate[] = array('values' => array('proxy_hostid' => 0), 'where' => array('proxy_hostid' => $proxy['proxyid']));
         $hostids = zbx_objectValues($proxy['hosts'], 'hostid');
         $hostUpdate[] = array('values' => array('proxy_hostid' => $proxy['proxyid']), 'where' => array('hostid' => $hostids));
         // if this is an active proxy - delete it's interface;
         if (isset($proxy['status']) && $proxy['status'] == HOST_STATUS_PROXY_ACTIVE) {
             $interfaces = API::HostInterface()->get(array('output' => API_OUTPUT_REFER, 'hostids' => $proxy['hostid']));
             $interfaceids = zbx_objectValues($interfaces, 'interfaceid');
             if ($interfaceids) {
                 API::HostInterface()->delete($interfaceids);
             }
         } elseif (isset($proxy['interfaces']) && is_array($proxy['interfaces'])) {
             $proxy['interfaces'][0]['hostid'] = $proxy['hostid'];
             if (isset($proxy['interfaces'][0]['interfaceid'])) {
                 $result = API::HostInterface()->update($proxy['interfaces']);
             } else {
                 $result = API::HostInterface()->create($proxy['interfaces']);
             }
             if (!$result) {
                 self::exception(ZBX_API_ERROR_INTERNAL, _('Proxy interface update failed.'));
             }
         }
     }
     DB::update('hosts', $proxyUpdate);
     DB::update('hosts', $hostUpdate);
     return array('proxyids' => $proxyids);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:39,代码来源:CProxy.php

示例14: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $proxyIds = array_keys($result);
     // selectHosts
     if ($options['selectHosts'] !== null && $options['selectHosts'] != API_OUTPUT_COUNT) {
         $hosts = API::Host()->get(array('output' => $this->outputExtend('hosts', array('hostid', 'proxy_hostid'), $options['selectHosts']), 'nodeids' => $options['nodeids'], 'proxyids' => $proxyIds, 'preservekeys' => true));
         $relationMap = $this->createRelationMap($hosts, 'proxy_hostid', 'hostid');
         $hosts = $this->unsetExtraFields($hosts, array('proxy_hostid', 'hostid'), $options['selectHosts']);
         $result = $relationMap->mapMany($result, $hosts, 'hosts');
     }
     // adding host interface
     if ($options['selectInterface'] !== null && $options['selectInterface'] != API_OUTPUT_COUNT) {
         $interfaces = API::HostInterface()->get(array('output' => $this->outputExtend('interface', array('interfaceid', 'hostid'), $options['selectInterface']), 'nodeids' => $options['nodeids'], 'hostids' => $proxyIds, 'nopermissions' => true, 'preservekeys' => true));
         $relationMap = $this->createRelationMap($interfaces, 'hostid', 'interfaceid');
         $interfaces = $this->unsetExtraFields($interfaces, array('hostid', 'interfaceid'), $options['selectInterface']);
         $result = $relationMap->mapOne($result, $interfaces, 'interface');
         foreach ($result as $key => $proxy) {
             if (!empty($proxy['interface'])) {
                 $result[$key]['interface'] = $proxy['interface'];
             }
         }
     }
     // adding host interfaces (deprecated)
     if ($options['selectInterfaces'] !== null && $options['selectInterfaces'] != API_OUTPUT_COUNT) {
         $interfaces = API::HostInterface()->get(array('output' => $this->outputExtend('interface', array('interfaceid', 'hostid'), $options['selectInterfaces']), 'nodeids' => $options['nodeids'], 'hostids' => $proxyIds, 'nopermissions' => true, 'preservekeys' => true));
         $relationMap = $this->createRelationMap($interfaces, 'hostid', 'interfaceid');
         $interfaces = $this->unsetExtraFields($interfaces, array('hostid', 'interfaceid'), $options['selectInterfaces']);
         $result = $relationMap->mapOne($result, $interfaces, 'interfaces');
         foreach ($result as $key => $proxy) {
             if (!empty($proxy['interfaces'])) {
                 $result[$key]['interfaces'] = array($proxy['interfaces']);
             }
         }
     }
     return $result;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:37,代码来源:CProxy.php

示例15: parseMain


//.........这里部分代码省略.........
             // TEMPLATES {{{
             if (!empty($rules['templateLinkage']['createMissing'])) {
                 $templates = $xpath->query('templates/template', $host);
                 $templateLinkage = array();
                 foreach ($templates as $template) {
                     $options = array('filter' => array('host' => $template->nodeValue), 'output' => array('templateid'), 'editable' => true);
                     $current_template = API::Template()->get($options);
                     if (empty($current_template)) {
                         throw new Exception(_s('No permission for template "%1$s".', $template->nodeValue));
                     }
                     $current_template = reset($current_template);
                     $templateLinkage[] = $current_template;
                 }
                 if ($templateLinkage) {
                     $result = API::Template()->massAdd(array('hosts' => array('hostid' => $current_hostid), 'templates' => $templateLinkage));
                     if (!$result) {
                         throw new Exception();
                     }
                 }
             }
             // }}} TEMPLATES
             // ITEMS {{{
             if (!empty($rules['items']['updateExisting']) || !empty($rules['items']['createMissing'])) {
                 $items = $xpath->query('items/item', $host);
                 // if this is an export from 1.8, we need to make some adjustments to items
                 if ($old_version_input) {
                     if (!$interfaces_created_with_host) {
                         // if host had another interfaces, we are not touching them: they remain as is
                         foreach ($interfaces as $i => $interface) {
                             // interface was not already created
                             if (!isset($interface['interfaceid'])) {
                                 // creating interface
                                 $interface['hostid'] = $current_hostid;
                                 $ids = API::HostInterface()->create($interface);
                                 if ($ids === false) {
                                     throw new Exception();
                                 }
                                 $interfaces[$i]['interfaceid'] = reset($ids['interfaceids']);
                             }
                         }
                     } else {
                         $options = array('hostids' => $current_hostid, 'output' => API_OUTPUT_EXTEND);
                         $interfaces = API::HostInterface()->get($options);
                     }
                     // we must know interface ids to assign them to items
                     $agent_interface_id = null;
                     $ipmi_interface_id = null;
                     $snmp_interfaces = array();
                     // hash 'port' => 'iterfaceid'
                     foreach ($interfaces as $interface) {
                         switch ($interface['type']) {
                             case INTERFACE_TYPE_AGENT:
                                 $agent_interface_id = $interface['interfaceid'];
                                 break;
                             case INTERFACE_TYPE_IPMI:
                                 $ipmi_interface_id = $interface['interfaceid'];
                                 break;
                             case INTERFACE_TYPE_SNMP:
                                 $snmp_interfaces[$interface['port']] = $interface['interfaceid'];
                                 break;
                         }
                     }
                 }
                 foreach ($items as $item) {
                     $item_db = self::mapXML2arr($item, XML_TAG_ITEM);
                     $item_db['hostid'] = $current_hostid;
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:67,代码来源:CXmlImport18.php


注:本文中的API::HostInterface方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。