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


PHP API::GraphPrototype方法代码示例

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


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

示例1: prepareDiscoveryRules

 /**
  * Get discovery rules related objects from database.
  *
  * @param array $items
  *
  * @return array
  */
 protected function prepareDiscoveryRules(array $items)
 {
     foreach ($items as &$item) {
         $item['itemPrototypes'] = array();
         $item['graphPrototypes'] = array();
         $item['triggerPrototypes'] = array();
         $item['hostPrototypes'] = array();
     }
     unset($item);
     // gather item prototypes
     $prototypes = API::ItemPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'output' => $this->dataFields['discoveryrule'], 'selectApplications' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => array('itemid'), 'inherited' => false, 'preservekeys' => true));
     // gather value maps
     $valueMapIds = zbx_objectValues($prototypes, 'valuemapid');
     $DbValueMaps = DBselect('SELECT vm.valuemapid, vm.name FROM valuemaps vm WHERE ' . dbConditionInt('vm.valuemapid', $valueMapIds));
     $valueMaps = array();
     while ($valueMap = DBfetch($DbValueMaps)) {
         $valueMaps[$valueMap['valuemapid']] = $valueMap['name'];
     }
     foreach ($prototypes as $prototype) {
         $prototype['valuemap'] = array();
         if ($prototype['valuemapid']) {
             $prototype['valuemap']['name'] = $valueMaps[$prototype['valuemapid']];
         }
         $items[$prototype['discoveryRule']['itemid']]['itemPrototypes'][] = $prototype;
     }
     // gather graph prototypes
     $graphs = API::GraphPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'inherited' => false, 'preservekeys' => true));
     $graphs = $this->prepareGraphs($graphs);
     foreach ($graphs as $graph) {
         $items[$graph['discoveryRule']['itemid']]['graphPrototypes'][] = $graph;
     }
     // gather trigger prototypes
     $triggers = API::TriggerPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'output' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectItems' => array('flags', 'type'), 'inherited' => false, 'preservekeys' => true, 'expandData' => true));
     foreach ($triggers as $trigger) {
         foreach ($trigger['items'] as $item) {
             if ($item['flags'] == ZBX_FLAG_DISCOVERY_CREATED || $item['type'] == ITEM_TYPE_HTTPTEST) {
                 continue 2;
             }
         }
         $trigger['expression'] = explode_exp($trigger['expression']);
         $items[$trigger['discoveryRule']['itemid']]['triggerPrototypes'][] = $trigger;
     }
     // gather host prototypes
     $hostPrototypes = API::HostPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'output' => API_OUTPUT_EXTEND, 'selectGroupLinks' => API_OUTPUT_EXTEND, 'selectGroupPrototypes' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectTemplates' => API_OUTPUT_EXTEND, 'inherited' => false, 'preservekeys' => true));
     // replace group prototype group IDs with references
     $groupIds = array();
     foreach ($hostPrototypes as $hostPrototype) {
         foreach ($hostPrototype['groupLinks'] as $groupLink) {
             $groupIds[$groupLink['groupid']] = $groupLink['groupid'];
         }
     }
     $groups = $this->getGroupsReferences($groupIds);
     // export the groups used in group prototypes
     $this->data['groups'] += $groups;
     foreach ($hostPrototypes as $hostPrototype) {
         foreach ($hostPrototype['groupLinks'] as &$groupLink) {
             $groupLink['groupid'] = $groups[$groupLink['groupid']];
         }
         unset($groupLink);
         $items[$hostPrototype['discoveryRule']['itemid']]['hostPrototypes'][] = $hostPrototype;
     }
     return $items;
 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:70,代码来源:CConfigurationExport.php

示例2: unlink


//.........这里部分代码省略.........
                 info(_s('Unlinked: Item prototype "%1$s" on "%2$s".', $item['name'], $item['host']));
             }
         }
     }
     /* }}} ITEMS, DISCOVERY RULES */
     // host prototypes
     // we need only to unlink host prototypes. in case of unlink and clear they will be deleted together with LLD rules.
     if (!$clear && isset($items[ZBX_FLAG_DISCOVERY_RULE])) {
         $discoveryRuleIds = array_keys($items[ZBX_FLAG_DISCOVERY_RULE]);
         $hostPrototypes = DBfetchArrayAssoc(DBSelect('SELECT DISTINCT h.hostid,h.host,h3.host AS parent_host' . ' FROM hosts h' . ' INNER JOIN host_discovery hd ON h.hostid=hd.hostid' . ' INNER JOIN hosts h2 ON h.templateid=h2.hostid' . ' INNER JOIN host_discovery hd2 ON h.hostid=hd.hostid' . ' INNER JOIN items i ON hd.parent_itemid=i.itemid' . ' INNER JOIN hosts h3 ON i.hostid=h3.hostid' . ' WHERE ' . dbConditionInt('hd.parent_itemid', $discoveryRuleIds)), 'hostid');
         if ($hostPrototypes) {
             DB::update('hosts', array('values' => array('templateid' => 0), 'where' => array('hostid' => array_keys($hostPrototypes))));
             DB::update('group_prototype', array('values' => array('templateid' => 0), 'where' => array('hostid' => array_keys($hostPrototypes))));
             foreach ($hostPrototypes as $hostPrototype) {
                 info(_s('Unlinked: Host prototype "%1$s" on "%2$s".', $hostPrototype['host'], $hostPrototype['parent_host']));
             }
         }
     }
     /* GRAPHS {{{ */
     $sqlFrom = ' graphs g,hosts h';
     $sqlWhere = ' EXISTS (' . 'SELECT ggi.graphid' . ' FROM graphs_items ggi,items ii' . ' WHERE ggi.graphid=g.templateid' . ' AND ii.itemid=ggi.itemid' . ' AND ' . dbConditionInt('ii.hostid', $templateids) . ')' . ' AND ' . dbConditionInt('g.flags', $flags);
     if (!is_null($targetids)) {
         $sqlFrom = ' graphs g,graphs_items gi,items i,hosts h';
         $sqlWhere .= ' AND ' . dbConditionInt('i.hostid', $targetids) . ' AND gi.itemid=i.itemid' . ' AND g.graphid=gi.graphid' . ' AND h.hostid=i.hostid';
     }
     $sql = 'SELECT DISTINCT g.graphid,g.name,g.flags,h.name as host' . ' FROM ' . $sqlFrom . ' WHERE ' . $sqlWhere;
     $dbGraphs = DBSelect($sql);
     $graphs = array(ZBX_FLAG_DISCOVERY_NORMAL => array(), ZBX_FLAG_DISCOVERY_PROTOTYPE => array());
     while ($graph = DBfetch($dbGraphs)) {
         $graphs[$graph['flags']][$graph['graphid']] = array('name' => $graph['name'], 'graphid' => $graph['graphid'], 'host' => $graph['host']);
     }
     if (!empty($graphs[ZBX_FLAG_DISCOVERY_PROTOTYPE])) {
         if ($clear) {
             $result = API::GraphPrototype()->delete(array_keys($graphs[ZBX_FLAG_DISCOVERY_PROTOTYPE]), true);
             if (!$result) {
                 self::exception(ZBX_API_ERROR_INTERNAL, _('Cannot unlink and clear graph prototypes'));
             }
         } else {
             DB::update('graphs', array('values' => array('templateid' => 0), 'where' => array('graphid' => array_keys($graphs[ZBX_FLAG_DISCOVERY_PROTOTYPE]))));
             foreach ($graphs[ZBX_FLAG_DISCOVERY_PROTOTYPE] as $graph) {
                 info(_s('Unlinked: Graph prototype "%1$s" on "%2$s".', $graph['name'], $graph['host']));
             }
         }
     }
     if (!empty($graphs[ZBX_FLAG_DISCOVERY_NORMAL])) {
         if ($clear) {
             $result = API::Graph()->delete(array_keys($graphs[ZBX_FLAG_DISCOVERY_NORMAL]), true);
             if (!$result) {
                 self::exception(ZBX_API_ERROR_INTERNAL, _('Cannot unlink and clear graphs.'));
             }
         } else {
             DB::update('graphs', array('values' => array('templateid' => 0), 'where' => array('graphid' => array_keys($graphs[ZBX_FLAG_DISCOVERY_NORMAL]))));
             foreach ($graphs[ZBX_FLAG_DISCOVERY_NORMAL] as $graph) {
                 info(_s('Unlinked: Graph "%1$s" on "%2$s".', $graph['name'], $graph['host']));
             }
         }
     }
     /* }}} GRAPHS */
     // http tests
     $sqlWhere = '';
     if (!is_null($targetids)) {
         $sqlWhere = ' AND ' . dbConditionInt('ht1.hostid', $targetids);
     }
     $sql = 'SELECT DISTINCT ht1.httptestid,ht1.name,h.name as host' . ' FROM httptest ht1' . ' INNER JOIN httptest ht2 ON ht2.httptestid=ht1.templateid' . ' INNER JOIN hosts h ON h.hostid=ht1.hostid' . ' WHERE ' . dbConditionInt('ht2.hostid', $templateids) . $sqlWhere;
     $dbHttpTests = DBSelect($sql);
     $httpTests = array();
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:67,代码来源:CHostGeneral.php

示例3: reset

        $graph = reset($graphs);
        order_result($graph['hosts'], 'name');
        $graph['host'] = reset($graph['hosts']);
        $caption = $graph['host']['name'] . NAME_DELIMITER . $graph['name'];
    }
    if ($this->data['screen']['templateid']) {
        $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&templated_hosts=1&only_hostid=' . $this->data['screen']['templateid'] . '&writeonly=1", 800, 450);', 'formlist');
    } else {
        $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&real_hosts=1&with_graphs=1&writeonly=1", 800, 450);', 'formlist');
    }
    $screenFormList->addVar('resourceid', $id);
    $screenFormList->addRow(_('Graph name'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, true), $selectButton), false, null, 'nowrap');
} elseif ($resourceType == SCREEN_RESOURCE_LLD_GRAPH) {
    $caption = '';
    $id = 0;
    $graphPrototypes = API::GraphPrototype()->get(array('output' => array('name'), 'graphids' => $resourceId, 'selectHosts' => array('name')));
    if ($graphPrototypes) {
        $id = $resourceId;
        $graphPrototype = reset($graphPrototypes);
        order_result($graphPrototype['hosts'], 'name');
        $graphPrototype['host'] = reset($graphPrototype['hosts']);
        $caption = $graphPrototype['host']['name'] . NAME_DELIMITER . $graphPrototype['name'];
    }
    if ($this->data['screen']['templateid']) {
        $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graph_prototypes&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&only_hostid=' . $this->data['screen']['templateid'] . '&templated_hosts=1&writeonly=1", 800, 450);', 'formlist');
    } else {
        $selectButton = new CButton('select', _('Select'), 'javascript: return PopUp("popup.php?srctbl=graph_prototypes&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $screenForm->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&real_hosts=1&writeonly=1", 800, 450);', 'formlist');
    }
    $screenFormList->addVar('resourceid', $id);
    $screenFormList->addRow(_('Graph name'), array(new CTextBox('caption', $caption, ZBX_TEXTBOX_STANDARD_SIZE, true), $selectButton), false, null, 'nowrap');
    $screenFormList->addRow(_('Max columns'), new CNumericBox('max_columns', $maxColumns, 3, false, false, false));
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:configuration.screen.constructor.edit.php

示例4: delete

 /**
  * Delete Item prototypes.
  *
  * @param int|string|array $prototypeids
  * @param bool             $nopermissions
  *
  * @return array
  */
 public function delete($prototypeids, $nopermissions = false)
 {
     if (empty($prototypeids)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     $prototypeids = zbx_toHash($prototypeids);
     $options = array('itemids' => $prototypeids, 'editable' => true, 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('name'));
     $delItemPrototypes = $this->get($options);
     // TODO: remove $nopermissions hack
     if (!$nopermissions) {
         foreach ($prototypeids as $prototypeid) {
             if (!isset($delItemPrototypes[$prototypeid])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
             }
             if ($delItemPrototypes[$prototypeid]['templateid'] != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete templated items'));
             }
         }
     }
     // first delete child items
     $parentItemids = $prototypeids;
     $childPrototypeids = array();
     do {
         $dbItems = DBselect('SELECT itemid FROM items WHERE ' . dbConditionInt('templateid', $parentItemids));
         $parentItemids = array();
         while ($dbItem = DBfetch($dbItems)) {
             $parentItemids[$dbItem['itemid']] = $dbItem['itemid'];
             $childPrototypeids[$dbItem['itemid']] = $dbItem['itemid'];
         }
     } while (!empty($parentItemids));
     $options = array('output' => API_OUTPUT_EXTEND, 'itemids' => $childPrototypeids, 'nopermissions' => true, 'preservekeys' => true, 'selectHosts' => array('name'));
     $delItemPrototypesChilds = $this->get($options);
     $delItemPrototypes = array_merge($delItemPrototypes, $delItemPrototypesChilds);
     $prototypeids = array_merge($prototypeids, $childPrototypeids);
     // delete graphs with this item prototype
     $delGraphPrototypes = API::GraphPrototype()->get(array('itemids' => $prototypeids, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => true, 'preservekeys' => true));
     if (!empty($delGraphPrototypes)) {
         $result = API::GraphPrototype()->delete(zbx_objectValues($delGraphPrototypes, 'graphid'), true);
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete graph prototype'));
         }
     }
     // check if any graphs are referencing this item
     $this->checkGraphReference($prototypeids);
     // CREATED ITEMS
     $createdItems = array();
     $sql = 'SELECT itemid FROM item_discovery WHERE ' . dbConditionInt('parent_itemid', $prototypeids);
     $dbItems = DBselect($sql);
     while ($item = DBfetch($dbItems)) {
         $createdItems[$item['itemid']] = $item['itemid'];
     }
     if (!empty($createdItems)) {
         $result = API::Item()->delete($createdItems, true);
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete items created by low level discovery.'));
         }
     }
     // TRIGGER PROTOTYPES
     $delTriggerPrototypes = API::TriggerPrototype()->get(array('itemids' => $prototypeids, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => true, 'preservekeys' => true));
     if (!empty($delTriggerPrototypes)) {
         $result = API::TriggerPrototype()->delete(zbx_objectValues($delTriggerPrototypes, 'triggerid'), true);
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot delete trigger prototype'));
         }
     }
     // ITEM PROTOTYPES
     DB::delete('items', array('itemid' => $prototypeids));
     // TODO: remove info from API
     foreach ($delItemPrototypes as $item) {
         $host = reset($item['hosts']);
         info(_s('Deleted: Item prototype "%1$s" on "%2$s".', $item['name'], $host['name']));
     }
     return array('prototypeids' => $prototypeids);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:82,代码来源:CItemPrototype.php

示例5: prepareDiscoveryRules

 /**
  * Get discovery rules related objects from database.
  *
  * @param array $items
  *
  * @return array
  */
 protected function prepareDiscoveryRules(array $items)
 {
     foreach ($items as &$item) {
         $item['itemPrototypes'] = array();
         $item['graphPrototypes'] = array();
         $item['triggerPrototypes'] = array();
     }
     unset($item);
     // gather item prototypes
     $prototypes = API::ItemPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'output' => array('hostid', 'multiplier', 'type', 'snmp_community', 'snmp_oid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'delta', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'formula', 'valuemapid', 'delay_flex', 'params', 'ipmi_sensor', 'data_type', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'interfaceid', 'port', 'description', 'inventory_link', 'flags'), 'selectApplications' => API_OUTPUT_EXTEND, 'inherited' => false, 'preservekeys' => true));
     // gather value maps
     $valueMapIds = zbx_objectValues($prototypes, 'valuemapid');
     $DbValueMaps = DBselect('SELECT vm.valuemapid, vm.name FROM valuemaps vm WHERE ' . dbConditionInt('vm.valuemapid', $valueMapIds));
     $valueMaps = array();
     while ($valueMap = DBfetch($DbValueMaps)) {
         $valueMaps[$valueMap['valuemapid']] = $valueMap['name'];
     }
     foreach ($prototypes as $prototype) {
         $prototype['valuemap'] = array();
         if ($prototype['valuemapid']) {
             $prototype['valuemap']['name'] = $valueMaps[$prototype['valuemapid']];
         }
         $items[$prototype['parent_itemid']]['itemPrototypes'][] = $prototype;
     }
     // gather graph prototypes
     $graphs = API::GraphPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND, 'inherited' => false, 'preservekeys' => true));
     $graphs = $this->prepareGraphs($graphs);
     foreach ($graphs as $graph) {
         $items[$graph['discoveryRule']['itemid']]['graphPrototypes'][] = $graph;
     }
     // gather trigger prototypes
     $triggers = API::TriggerPrototype()->get(array('discoveryids' => zbx_objectValues($items, 'itemid'), 'output' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectItems' => array('flags', 'type'), 'inherited' => false, 'preservekeys' => true, 'expandData' => true));
     foreach ($triggers as $trigger) {
         foreach ($trigger['items'] as $item) {
             if ($item['flags'] == ZBX_FLAG_DISCOVERY_CREATED || $item['type'] == ITEM_TYPE_HTTPTEST) {
                 continue 2;
             }
         }
         $trigger['expression'] = explode_exp($trigger['expression']);
         $items[$trigger['discoveryRule']['itemid']]['triggerPrototypes'][] = $trigger;
     }
     return $items;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:50,代码来源:CConfigurationExport.php

示例6: copyGraphPrototypes

 /**
  * Copies all of the graphs from the source discovery to the target discovery rule.
  *
  * @throws APIException if graph saving fails
  *
  * @param array $srcDiscovery    The source discovery rule to copy from
  * @param array $dstDiscovery    The target discovery rule to copy to
  *
  * @return array
  */
 protected function copyGraphPrototypes(array $srcDiscovery, array $dstDiscovery)
 {
     // fetch source graphs
     $srcGraphs = API::GraphPrototype()->get(array('discoveryids' => $srcDiscovery['itemid'], 'output' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'selectHosts' => API_OUTPUT_REFER, 'preservekeys' => true));
     if (!$srcGraphs) {
         return array();
     }
     $srcItemIds = array();
     foreach ($srcGraphs as $key => $graph) {
         // skip graphs with items from multiple hosts
         if (count($graph['hosts']) > 1) {
             unset($srcGraphs[$key]);
             continue;
         }
         // skip graphs with http items
         if (httpItemExists($graph['gitems'])) {
             unset($srcGraphs[$key]);
             continue;
         }
         // save all used item ids to map them to the new items
         foreach ($graph['gitems'] as $item) {
             $srcItemIds[$item['itemid']] = $item['itemid'];
         }
         if ($graph['ymin_itemid']) {
             $srcItemIds[$graph['ymin_itemid']] = $graph['ymin_itemid'];
         }
         if ($graph['ymax_itemid']) {
             $srcItemIds[$graph['ymax_itemid']] = $graph['ymax_itemid'];
         }
     }
     // fetch source items
     $items = API::Item()->get(array('itemids' => $srcItemIds, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'filter' => array('flags' => null)));
     $srcItems = array();
     $itemKeys = array();
     foreach ($items as $item) {
         $srcItems[$item['itemid']] = $item;
         $itemKeys[$item['key_']] = $item['key_'];
     }
     // fetch newly cloned items
     $newItems = API::Item()->get(array('hostids' => $dstDiscovery['hostid'], 'filter' => array('key_' => $itemKeys, 'flags' => null), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     $items = array_merge($dstDiscovery['items'], $newItems);
     $dstItems = array();
     foreach ($items as $item) {
         $dstItems[$item['key_']] = $item;
     }
     $dstGraphs = $srcGraphs;
     foreach ($dstGraphs as &$graph) {
         unset($graph['graphid']);
         unset($graph['templateid']);
         foreach ($graph['gitems'] as &$gitem) {
             // replace the old item with the new one with the same key
             $item = $srcItems[$gitem['itemid']];
             $gitem['itemid'] = $dstItems[$item['key_']]['itemid'];
             unset($gitem['gitemid'], $gitem['graphid']);
         }
         // replace the old axis items with the new one with the same key
         if ($graph['ymin_itemid']) {
             $yMinSrcItem = $srcItems[$graph['ymin_itemid']];
             $graph['ymin_itemid'] = $dstItems[$yMinSrcItem['key_']]['itemid'];
         }
         if ($graph['ymax_itemid']) {
             $yMaxSrcItem = $srcItems[$graph['ymax_itemid']];
             $graph['ymax_itemid'] = $dstItems[$yMaxSrcItem['key_']]['itemid'];
         }
     }
     // save graphs
     $rs = API::Graph()->create($dstGraphs);
     if (!$rs) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Cannot clone graph prototypes.'));
     }
     return $rs;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:82,代码来源:CDiscoveryRule.php

示例7: order_result

         // skip trigger prototypes with web items
         if (httpItemExists($triggerPrototype['items'])) {
             continue;
         }
         $prototypeList[$triggerPrototype['triggerid']] = $triggerPrototype['description'];
     }
     if ($prototypeList) {
         order_result($prototypeList);
         $listBox = new CListBox('triggerprototypes', null, 8);
         $listBox->setAttribute('disabled', 'disabled');
         $listBox->addItems($prototypeList);
         $hostList->addRow(_('Trigger prototypes'), $listBox);
     }
 }
 // Graph prototypes
 $hostGraphPrototypes = API::GraphPrototype()->get(array('hostids' => $_REQUEST['hostid'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'selectHosts' => array('hostid'), 'output' => array('graphid', 'name')));
 if (!empty($hostGraphPrototypes)) {
     $prototypeList = array();
     foreach ($hostGraphPrototypes as $graphPrototype) {
         if (count($graphPrototype['hosts']) == 1) {
             $prototypeList[$graphPrototype['graphid']] = $graphPrototype['name'];
         }
     }
     order_result($prototypeList);
     $listBox = new CListBox('graphPrototypes', null, 8);
     $listBox->setAttribute('disabled', 'disabled');
     $listBox->addItems($prototypeList);
     $hostList->addRow(_('Graph prototypes'), $listBox);
 }
 // host prototypes
 $hostPrototypes = API::HostPrototype()->get(array('discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'output' => array('hostid', 'name')));
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:configuration.host.edit.php

示例8: checkInput


//.........这里部分代码省略.........
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect value "%1$s" for "%2$s" field: must be between %3$s and %4$s.', $screenItem['elements'], 'elements', 1, 100));
                     }
                     break;
             }
         }
         // check 'max_columns' parameter for LLD screen resources:
         // is set and valid for create method, and is valid for update method, if set
         $dbScreenItem = isset($screenItem['screenitemid']) ? $dbScreenItems[$screenItem['screenitemid']] : null;
         $lldResources = array(SCREEN_RESOURCE_LLD_GRAPH, SCREEN_RESOURCE_LLD_SIMPLE_GRAPH);
         if (in_array($screenItem['resourcetype'], $lldResources)) {
             $set = isset($screenItem['max_columns']);
             $valid = $set && $this->isValidMaxColumns($screenItem['max_columns']);
             $error = $dbScreenItem ? $set && !$valid : !$set || !$valid;
             if ($error) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect max columns provided for screen element.'));
             }
         }
         if (isset($validStyles[$screenItem['resourcetype']]) && !in_array($screenItem['style'], $validStyles[$screenItem['resourcetype']])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect style provided for screen element.'));
         }
     }
     // check host groups
     if ($hostGroupsIds) {
         $dbHostGroups = API::HostGroup()->get(array('output' => array('groupid'), 'groupids' => $hostGroupsIds, 'editable' => true, 'preservekeys' => true));
         foreach ($hostGroupsIds as $hostGroupsId) {
             if (!isset($dbHostGroups[$hostGroupsId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host group ID "%1$s" provided for screen element.', $hostGroupsId));
             }
         }
     }
     // check hosts
     if ($hostIds) {
         $dbHosts = API::Host()->get(array('output' => array('hostid'), 'hostids' => $hostIds, 'editable' => true, 'preservekeys' => true));
         foreach ($hostIds as $hostId) {
             if (!isset($dbHosts[$hostId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect host ID "%1$s" provided for screen element.', $hostId));
             }
         }
     }
     // check graphs
     if ($graphIds) {
         $dbGraphs = API::Graph()->get(array('output' => array('graphid'), 'graphids' => $graphIds, 'editable' => true, 'preservekeys' => true));
         foreach ($graphIds as $graphId) {
             if (!isset($dbGraphs[$graphId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect graph ID "%1$s" provided for screen element.', $graphId));
             }
         }
     }
     // check graph prototypes
     if ($graphPrototypeIds) {
         $dbGraphPrototypes = API::GraphPrototype()->get(array('output' => array('graphid'), 'graphids' => $graphPrototypeIds, 'editable' => true, 'preservekeys' => true));
         foreach ($graphPrototypeIds as $graphPrototypeId) {
             if (!isset($dbGraphPrototypes[$graphPrototypeId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect graph prototype ID "%1$s" provided for screen element.', $graphPrototypeId));
             }
         }
     }
     // check items
     if ($itemIds) {
         $dbItems = API::Item()->get(array('output' => array('itemid'), 'itemids' => $itemIds, 'editable' => true, 'preservekeys' => true, 'webitems' => true));
         foreach ($itemIds as $itemId) {
             if (!isset($dbItems[$itemId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect item ID "%1$s" provided for screen element.', $itemId));
             }
         }
     }
     // check item prototypes
     if ($itemPrototypeIds) {
         $dbItemPrototypes = API::ItemPrototype()->get(array('output' => array('itemid'), 'itemids' => $itemPrototypeIds, 'editable' => true, 'preservekeys' => true));
         foreach ($itemPrototypeIds as $itemPrototypeId) {
             if (!isset($dbItemPrototypes[$itemPrototypeId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect item prototype ID "%1$s" provided for screen element.', $itemPrototypeId));
             }
         }
     }
     // check maps
     if ($mapIds) {
         $dbMaps = API::Map()->get(array('output' => array('sysmapid'), 'sysmapids' => $mapIds, 'editable' => true, 'preservekeys' => true));
         foreach ($mapIds as $mapId) {
             if (!isset($dbMaps[$mapId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect map ID "%1$s" provided for screen element.', $mapId));
             }
         }
     }
     // check screens
     if ($screenIds) {
         $dbScreens = API::Screen()->get(array('output' => array('screenid'), 'screenids' => $screenIds, 'editable' => true, 'preservekeys' => true));
         if (count($dbScreens) < count($screenIds)) {
             $dbTemplateScreens = API::TemplateScreen()->get(array('output' => array('screenid'), 'screenids' => $screenIds, 'editable' => true, 'preservekeys' => true));
             if ($dbTemplateScreens) {
                 $dbScreens = zbx_array_merge($dbScreens, $dbTemplateScreens);
             }
         }
         foreach ($screenIds as $screenId) {
             if (!isset($dbScreens[$screenId])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, _s('Incorrect screen ID "%1$s" provided for screen element.', $screenId));
             }
         }
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CScreenItem.php

示例9: reset

        $graph = reset($graphs);
        order_result($graph['hosts'], 'name');
        $graph['host'] = reset($graph['hosts']);
        $caption = $graph['host']['name'] . NAME_DELIMITER . $graph['name'];
    }
    if ($this->data['screen']['templateid']) {
        $selectButton = (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $form->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&templated_hosts=1&only_hostid=' . $this->data['screen']['templateid'] . '");');
    } else {
        $selectButton = (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('javascript: return PopUp("popup.php?srctbl=graphs&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $form->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&real_hosts=1&with_graphs=1");');
    }
    $form->addVar('resourceid', $id);
    $screenFormList->addRow(_('Graph'), [(new CTextBox('caption', $caption, true))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $selectButton]);
} elseif ($resourceType == SCREEN_RESOURCE_LLD_GRAPH) {
    $caption = '';
    $id = 0;
    $graphPrototypes = API::GraphPrototype()->get(['output' => ['name'], 'graphids' => $resourceId, 'selectHosts' => ['name']]);
    if ($graphPrototypes) {
        $id = $resourceId;
        $graphPrototype = reset($graphPrototypes);
        order_result($graphPrototype['hosts'], 'name');
        $graphPrototype['host'] = reset($graphPrototype['hosts']);
        $caption = $graphPrototype['host']['name'] . NAME_DELIMITER . $graphPrototype['name'];
    }
    if ($this->data['screen']['templateid']) {
        $selectButton = (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('javascript: return PopUp("popup.php?srctbl=graph_prototypes&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $form->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&only_hostid=' . $this->data['screen']['templateid'] . '&templated_hosts=1");');
    } else {
        $selectButton = (new CButton('select', _('Select')))->addClass(ZBX_STYLE_BTN_GREY)->onClick('javascript: return PopUp("popup.php?srctbl=graph_prototypes&srcfld1=graphid&srcfld2=name' . '&dstfrm=' . $form->getName() . '&dstfld1=resourceid&dstfld2=caption' . '&real_hosts=1");');
    }
    $form->addVar('resourceid', $id);
    $screenFormList->addRow(_('Graph prototype'), [(new CTextBox('caption', $caption, true))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH), (new CDiv())->addClass(ZBX_STYLE_FORM_INPUT_MARGIN), $selectButton]);
    $screenFormList->addRow(_('Max columns'), (new CNumericBox('max_columns', $maxColumns, 3, false, false, false))->setWidth(ZBX_TEXTAREA_NUMERIC_STANDARD_WIDTH));
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:monitoring.screen.constructor.edit.php

示例10: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $itemIds = array_keys($result);
     // adding items
     if (!is_null($options['selectItems'])) {
         if ($options['selectItems'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'parent_itemid', 'itemid', 'item_discovery');
             $items = API::ItemPrototype()->get(array('output' => $options['selectItems'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $items, 'items', $options['limitSelects']);
         } else {
             $items = API::ItemPrototype()->get(array('discoveryids' => $itemIds, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true));
             $items = zbx_toHash($items, 'parent_itemid');
             foreach ($result as $itemid => $item) {
                 $result[$itemid]['items'] = isset($items[$itemid]) ? $items[$itemid]['rowscount'] : 0;
             }
         }
     }
     // adding triggers
     if (!is_null($options['selectTriggers'])) {
         if ($options['selectTriggers'] != API_OUTPUT_COUNT) {
             $relationMap = new CRelationMap();
             $res = DBselect('SELECT id.parent_itemid,f.triggerid' . ' FROM item_discovery id,items i,functions f' . ' WHERE ' . dbConditionInt('id.parent_itemid', $itemIds) . ' AND id.itemid=i.itemid' . ' AND i.itemid=f.itemid');
             while ($relation = DBfetch($res)) {
                 $relationMap->addRelation($relation['parent_itemid'], $relation['triggerid']);
             }
             $triggers = API::TriggerPrototype()->get(array('output' => $options['selectTriggers'], 'triggerids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $triggers, 'triggers', $options['limitSelects']);
         } else {
             $triggers = API::TriggerPrototype()->get(array('discoveryids' => $itemIds, 'countOutput' => true, 'groupCount' => true));
             $triggers = zbx_toHash($triggers, 'parent_itemid');
             foreach ($result as $itemid => $item) {
                 $result[$itemid]['triggers'] = isset($triggers[$itemid]) ? $triggers[$itemid]['rowscount'] : 0;
             }
         }
     }
     // adding graphs
     if (!is_null($options['selectGraphs'])) {
         if ($options['selectGraphs'] != API_OUTPUT_COUNT) {
             $relationMap = new CRelationMap();
             $res = DBselect('SELECT id.parent_itemid,gi.graphid' . ' FROM item_discovery id,items i,graphs_items gi' . ' WHERE ' . dbConditionInt('id.parent_itemid', $itemIds) . ' AND id.itemid=i.itemid' . ' AND i.itemid=gi.itemid');
             while ($relation = DBfetch($res)) {
                 $relationMap->addRelation($relation['parent_itemid'], $relation['graphid']);
             }
             $graphs = API::GraphPrototype()->get(array('output' => $options['selectGraphs'], 'graphids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $graphs, 'graphs', $options['limitSelects']);
         } else {
             $graphs = API::GraphPrototype()->get(array('discoveryids' => $itemIds, 'countOutput' => true, 'groupCount' => true));
             $graphs = zbx_toHash($graphs, 'parent_itemid');
             foreach ($result as $itemid => $item) {
                 $result[$itemid]['graphs'] = isset($graphs[$itemid]) ? $graphs[$itemid]['rowscount'] : 0;
             }
         }
     }
     // adding hosts
     if ($options['selectHostPrototypes'] !== null) {
         if ($options['selectHostPrototypes'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'parent_itemid', 'hostid', 'host_discovery');
             $hostPrototypes = API::HostPrototype()->get(array('output' => $options['selectHostPrototypes'], 'hostids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
             $result = $relationMap->mapMany($result, $hostPrototypes, 'hostPrototypes', $options['limitSelects']);
         } else {
             $hostPrototypes = API::HostPrototype()->get(array('discoveryids' => $itemIds, 'nopermissions' => true, 'countOutput' => true, 'groupCount' => true));
             $hostPrototypes = zbx_toHash($hostPrototypes, 'parent_itemid');
             foreach ($result as $itemid => $item) {
                 $result[$itemid]['hostPrototypes'] = isset($hostPrototypes[$itemid]) ? $hostPrototypes[$itemid]['rowscount'] : 0;
             }
         }
     }
     if ($options['selectFilter'] !== null) {
         $formulaRequested = $this->outputIsRequested('formula', $options['selectFilter']);
         $evalFormulaRequested = $this->outputIsRequested('eval_formula', $options['selectFilter']);
         $conditionsRequested = $this->outputIsRequested('conditions', $options['selectFilter']);
         $filters = array();
         foreach ($result as $rule) {
             $filters[$rule['itemid']] = array('evaltype' => $rule['evaltype'], 'formula' => isset($rule['formula']) ? $rule['formula'] : '');
         }
         // adding conditions
         if ($formulaRequested || $evalFormulaRequested || $conditionsRequested) {
             $conditions = API::getApiService()->select('item_condition', array('output' => array('item_conditionid', 'macro', 'value', 'itemid', 'operator'), 'filter' => array('itemid' => $itemIds), 'preservekeys' => true, 'sortfield' => 'item_conditionid'));
             $relationMap = $this->createRelationMap($conditions, 'itemid', 'item_conditionid');
             $filters = $relationMap->mapMany($filters, $conditions, 'conditions');
             foreach ($filters as &$filter) {
                 // in case of a custom expression - use the given formula
                 if ($filter['evaltype'] == CONDITION_EVAL_TYPE_EXPRESSION) {
                     $formula = $filter['formula'];
                 } else {
                     // sort the conditions by macro before generating the formula
                     $conditions = zbx_toHash($filter['conditions'], 'item_conditionid');
                     $conditions = order_macros($conditions, 'macro');
                     $formulaConditions = array();
                     foreach ($conditions as $condition) {
                         $formulaConditions[$condition['item_conditionid']] = $condition['macro'];
                     }
                     $formula = CConditionHelper::getFormula($formulaConditions, $filter['evaltype']);
                 }
                 // generate formulaids from the effective formula
                 $formulaIds = CConditionHelper::getFormulaIds($formula);
                 foreach ($filter['conditions'] as &$condition) {
                     $condition['formulaid'] = $formulaIds[$condition['item_conditionid']];
                 }
//.........这里部分代码省略.........
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:101,代码来源:CDiscoveryRule.php

示例11: array

 if ($multiselect) {
     $header = array(array(new CCheckBox('all_graphs', null, "javascript: checkAll('" . $form->getName() . "', 'all_graphs', 'graphs');"), _('Description')), _('Graph type'));
 } else {
     $header = array(_('Name'), _('Graph type'));
 }
 $table->setHeader($header);
 if ($pageFilter->hostsSelected) {
     $options = array('output' => API_OUTPUT_EXTEND, 'hostids' => $hostid, 'selectHosts' => array('name'), 'preservekeys' => true);
     if (!is_null($writeonly)) {
         $options['editable'] = true;
     }
     if (!is_null($templated)) {
         $options['templated'] = $templated;
     }
     if ($graphPrototypesPopup) {
         $graphs = API::GraphPrototype()->get($options);
     } else {
         $graphs = API::Graph()->get($options);
     }
     order_result($graphs, 'name');
 } else {
     $graphs = array();
 }
 foreach ($graphs as $graph) {
     $host = reset($graph['hosts']);
     $graph['hostname'] = $host['name'];
     $description = new CSpan($graph['name'], 'link');
     $graph['name'] = $graph['hostname'] . NAME_DELIMITER . $graph['name'];
     if ($multiselect) {
         $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($graph['graphid']) . ');';
     } else {
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:popup.php

示例12: order_result

            // skip trigger prototypes with web items
            if (httpItemExists($triggerPrototype['items'])) {
                continue;
            }
            $prototypeList[$triggerPrototype['triggerid']] = $triggerPrototype['description'];
        }
        if ($prototypeList) {
            order_result($prototypeList);
            $listBox = new CListBox('triggerprototypes', null, 8);
            $listBox->setAttribute('disabled', 'disabled');
            $listBox->addItems($prototypeList);
            $hostList->addRow(_('Trigger prototypes'), $listBox);
        }
    }
    // Graph prototypes
    $hostGraphPrototypes = API::GraphPrototype()->get(array('hostids' => $_REQUEST['hostid'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'selectHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND));
    if (!empty($hostGraphPrototypes)) {
        $prototypeList = array();
        foreach ($hostGraphPrototypes as $graphPrototype) {
            if (count($graphPrototype['hosts']) == 1) {
                $prototypeList[$graphPrototype['graphid']] = $graphPrototype['name'];
            }
        }
        order_result($prototypeList);
        $listBox = new CListBox('graphPrototypes', null, 8);
        $listBox->setAttribute('disabled', 'disabled');
        $listBox->addItems($prototypeList);
        $hostList->addRow(_('Graph prototypes'), $listBox);
    }
}
$divTabs->addTab('hostTab', _('Host'), $hostList);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:configuration.host.edit.php

示例13: addRelatedObjects

 public function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $itemids = array_keys($result);
     // adding applications
     if ($options['selectApplications'] !== null && $options['selectApplications'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'itemid', 'applicationid', 'items_applications');
         $applications = API::Application()->get(['output' => $options['selectApplications'], 'applicationids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
         $result = $relationMap->mapMany($result, $applications, 'applications');
     }
     // adding application prototypes
     if ($options['selectApplicationPrototypes'] !== null && $options['selectApplicationPrototypes'] != API_OUTPUT_COUNT) {
         $pkFieldId = $this->pk('application_prototype');
         $outputFields = [$pkFieldId => $this->fieldId($pkFieldId, 'ap')];
         if (is_array($options['selectApplicationPrototypes'])) {
             foreach ($options['selectApplicationPrototypes'] as $field) {
                 if ($this->hasField($field, 'application_prototype')) {
                     $outputFields[$field] = $this->fieldId($field, 'ap');
                 }
             }
             $outputFields = implode(',', $outputFields);
         } else {
             $outputFields = 'ap.*';
         }
         $relationMap = $this->createRelationMap($result, 'itemid', 'application_prototypeid', 'item_application_prototype');
         $application_prototypes = DBfetchArray(DBselect('SELECT ' . $outputFields . ' FROM application_prototype ap' . ' WHERE ' . dbConditionInt('ap.application_prototypeid', $relationMap->getRelatedIds())));
         $application_prototypes = zbx_toHash($application_prototypes, 'application_prototypeid');
         $result = $relationMap->mapMany($result, $application_prototypes, 'applicationPrototypes');
     }
     // adding triggers
     if (!is_null($options['selectTriggers'])) {
         if ($options['selectTriggers'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'itemid', 'triggerid', 'functions');
             $triggers = API::TriggerPrototype()->get(['output' => $options['selectTriggers'], 'triggerids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
             if (!is_null($options['limitSelects'])) {
                 order_result($triggers, 'description');
             }
             $result = $relationMap->mapMany($result, $triggers, 'triggers', $options['limitSelects']);
         } else {
             $triggers = API::TriggerPrototype()->get(['countOutput' => true, 'groupCount' => true, 'itemids' => $itemids]);
             $triggers = zbx_toHash($triggers, 'itemid');
             foreach ($result as $itemid => $item) {
                 if (isset($triggers[$itemid])) {
                     $result[$itemid]['triggers'] = $triggers[$itemid]['rowscount'];
                 } else {
                     $result[$itemid]['triggers'] = 0;
                 }
             }
         }
     }
     // adding graphs
     if (!is_null($options['selectGraphs'])) {
         if ($options['selectGraphs'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'itemid', 'graphid', 'graphs_items');
             $graphs = API::GraphPrototype()->get(['output' => $options['selectGraphs'], 'graphids' => $relationMap->getRelatedIds(), 'preservekeys' => true]);
             if (!is_null($options['limitSelects'])) {
                 order_result($graphs, 'name');
             }
             $result = $relationMap->mapMany($result, $graphs, 'graphs', $options['limitSelects']);
         } else {
             $graphs = API::GraphPrototype()->get(['countOutput' => true, 'groupCount' => true, 'itemids' => $itemids]);
             $graphs = zbx_toHash($graphs, 'itemid');
             foreach ($result as $itemid => $item) {
                 if (isset($graphs[$itemid])) {
                     $result[$itemid]['graphs'] = $graphs[$itemid]['rowscount'];
                 } else {
                     $result[$itemid]['graphs'] = 0;
                 }
             }
         }
     }
     // adding discoveryrule
     if ($options['selectDiscoveryRule'] !== null && $options['selectDiscoveryRule'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'itemid', 'parent_itemid', 'item_discovery');
         $discoveryRules = API::DiscoveryRule()->get(['output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true]);
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     return $result;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:79,代码来源:CItemPrototype.php

示例14: CListBox

         $listBox = (new CListBox('itemsPrototypes', null, 8))->setAttribute('disabled', 'disabled')->addItems($prototypeList);
         $templateList->addRow(_('Item prototypes'), $listBox);
     }
     // Trigger prototypes
     $hostTriggerPrototypes = API::TriggerPrototype()->get(['hostids' => $data['templateId'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'output' => API_OUTPUT_EXTEND]);
     if (!empty($hostTriggerPrototypes)) {
         $prototypeList = [];
         foreach ($hostTriggerPrototypes as $triggerPrototype) {
             $prototypeList[$triggerPrototype['triggerid']] = $triggerPrototype['description'];
         }
         order_result($prototypeList);
         $listBox = (new CListBox('triggerprototypes', null, 8))->setAttribute('disabled', 'disabled')->addItems($prototypeList);
         $templateList->addRow(_('Trigger prototypes'), $listBox);
     }
     // Graph prototypes
     $hostGraphPrototypes = API::GraphPrototype()->get(['hostids' => $data['templateId'], 'discoveryids' => $hostDiscoveryRuleids, 'inherited' => false, 'output' => API_OUTPUT_EXTEND]);
     if (!empty($hostGraphPrototypes)) {
         $prototypeList = [];
         foreach ($hostGraphPrototypes as $graphPrototype) {
             $prototypeList[$graphPrototype['graphid']] = $graphPrototype['name'];
         }
         order_result($prototypeList);
         $listBox = (new CListBox('graphPrototypes', null, 8))->setAttribute('disabled', 'disabled')->addItems($prototypeList);
         $templateList->addRow(_('Graph prototypes'), $listBox);
     }
 }
 // screens
 $screens = API::TemplateScreen()->get(['inherited' => false, 'templateids' => $data['templateId'], 'output' => ['screenid', 'name']]);
 if (!empty($screens)) {
     $screensList = [];
     foreach ($screens as $screen) {
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:configuration.template.edit.php

示例15: getGraphPrototype

 /**
  * Resolves and retrieves effective graph prototype used in this screen item.
  *
  * @return array|bool
  */
 protected function getGraphPrototype()
 {
     if ($this->graphPrototype === null) {
         $defaultOptions = ['output' => ['graphid', 'name', 'graphtype', 'show_legend', 'show_3d', 'templated'], 'selectDiscoveryRule' => ['hostid']];
         $options = [];
         /*
          * If screen item is dynamic or is templated screen, real graph prototype is looked up by "name"
          * used as resource ID for this screen item and by current host.
          */
         if (($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM || $this->isTemplatedScreen) && $this->hostid) {
             $currentGraphPrototype = API::GraphPrototype()->get(['output' => ['name'], 'graphids' => [$this->screenitem['resourceid']]]);
             $currentGraphPrototype = reset($currentGraphPrototype);
             $options['hostids'] = [$this->hostid];
             $options['filter'] = ['name' => $currentGraphPrototype['name']];
         } else {
             $options['graphids'] = [$this->screenitem['resourceid']];
         }
         $options = zbx_array_merge($defaultOptions, $options);
         $selectedGraphPrototype = API::GraphPrototype()->get($options);
         $this->graphPrototype = reset($selectedGraphPrototype);
     }
     return $this->graphPrototype;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:28,代码来源:CScreenLldGraph.php


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