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


PHP API::Application方法代码示例

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


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

示例1: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // fetch hosts
     $hosts = API::Host()->get(['output' => ['hostid', 'status'], 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true]);
     $hostids = array_keys($hosts);
     $options = ['output' => ['triggerid', 'expression', 'description', 'url', 'value', 'priority', 'lastchange', 'flags'], 'selectHosts' => ['hostid', 'name', 'status'], 'selectItems' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'hostids' => $hostids, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description', 'preservekeys' => true];
     // application filter
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(['output' => [], 'hostids' => $hostids, 'search' => ['name' => $this->screenitem['application']], 'preservekeys' => true]);
         $options['applicationids'] = array_keys($applications);
     }
     $triggers = API::Trigger()->get($options);
     $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers);
     /*
      * Each screen cell with "Triggers overview" depends on one specific group which in this case is 'resourceid'.
      * Pass it as 'groupid' to menu pop-up "Events" link.
      */
     foreach ($triggers as &$trigger) {
         $trigger['groupid'] = $this->screenitem['resourceid'];
     }
     unset($trigger);
     $groups = API::HostGroup()->get(['output' => ['name'], 'groupids' => [$this->screenitem['resourceid']]]);
     $header = (new CDiv([new CTag('h4', true, _('Triggers overview')), (new CList())->addItem([_('Group'), ':', SPACE, $groups[0]['name']])]))->addClass(ZBX_STYLE_DASHBRD_WIDGET_HEAD);
     $table = getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid);
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput(new CUiWidget(uniqid(), [$header, $table, $footer]));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:32,代码来源:CScreenTriggersOverview.php

示例2: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // fetch hosts
     $hosts = API::Host()->get(array('output' => array('hostid', 'status'), 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true));
     $hostIds = array_keys($hosts);
     $options = array('output' => array('description', 'expression', 'priority', 'url', 'value', 'triggerid', 'lastchange', 'flags'), 'selectHosts' => array('hostid', 'name', 'status'), 'hostids' => $hostIds, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description');
     // application filter
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostIds, 'search' => array('name' => $this->screenitem['application'])));
         $options['applicationids'] = zbx_objectValues($applications, 'applicationid');
     }
     $triggers = API::Trigger()->get($options);
     return $this->getOutput(getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid));
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:19,代码来源:CScreenTriggersOverview.php

示例3: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $hostids = array();
     $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid']));
     while ($dbHostGroup = DBfetch($dbHostGroups)) {
         $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid'];
     }
     // application filter
     $applicationIds = null;
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostids, 'search' => array('name' => $this->screenitem['application'])));
         $applicationIds = zbx_objectValues($applications, 'applicationid');
     }
     return $this->getOutput(getItemsDataOverview($hostids, $applicationIds, $this->screenitem['style']));
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:20,代码来源:CScreenDataOverview.php

示例4: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     $hostids = [];
     $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid FROM hosts_groups hg WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid']));
     while ($dbHostGroup = DBfetch($dbHostGroups)) {
         $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid'];
     }
     // application filter
     $applicationIds = null;
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(['output' => ['applicationid'], 'hostids' => $hostids, 'search' => ['name' => $this->screenitem['application']]]);
         $applicationIds = zbx_objectValues($applications, 'applicationid');
     }
     $groups = API::HostGroup()->get(['output' => ['name'], 'groupids' => [$this->screenitem['resourceid']]]);
     $header = (new CDiv([new CTag('h4', true, _('Data overview')), (new CList())->addItem([_('Group'), ':', SPACE, $groups[0]['name']])]))->addClass(ZBX_STYLE_DASHBRD_WIDGET_HEAD);
     $table = getItemsDataOverview($hostids, $applicationIds, $this->screenitem['style']);
     $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
     return $this->getOutput(new CUiWidget(uniqid(), [$header, $table, $footer]));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:24,代码来源:CScreenDataOverview.php

示例5: get

 /**
  * Process screen.
  *
  * @return CDiv (screen inside container)
  */
 public function get()
 {
     // fetch hosts
     $hosts = API::Host()->get(array('output' => array('hostid', 'status'), 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true));
     $hostIds = array_keys($hosts);
     $options = array('output' => array('description', 'expression', 'priority', 'url', 'value', 'triggerid', 'lastchange', 'flags'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectItems' => array('itemid', 'hostid', 'name', 'key_', 'value_type'), 'hostids' => $hostIds, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description');
     // application filter
     if ($this->screenitem['application'] !== '') {
         $applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostIds, 'search' => array('name' => $this->screenitem['application'])));
         $options['applicationids'] = zbx_objectValues($applications, 'applicationid');
     }
     $triggers = API::Trigger()->get($options);
     /*
      * Each screen cell with "Triggers overview" depends on one specific group which in this case is 'resourceid'.
      * Pass it as 'groupid' to menu pop-up "Events" link.
      */
     foreach ($triggers as &$trigger) {
         $trigger['groupid'] = $this->screenitem['resourceid'];
     }
     unset($trigger);
     return $this->getOutput(getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid));
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:27,代码来源:CScreenTriggersOverview.php

示例6: 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(array('output' => $options['selectApplications'], 'applicationids' => $relationMap->getRelatedIds(), 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $applications, 'applications');
     }
     // adding interfaces
     if ($options['selectInterfaces'] !== null && $options['selectInterfaces'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'itemid', 'interfaceid');
         $interfaces = API::HostInterface()->get(array('output' => $options['selectInterfaces'], 'interfaceids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $interfaces, 'interfaces');
     }
     // adding triggers
     if (!is_null($options['selectTriggers'])) {
         if ($options['selectTriggers'] != API_OUTPUT_COUNT) {
             $relationMap = $this->createRelationMap($result, 'itemid', 'triggerid', 'functions');
             $triggers = API::Trigger()->get(array('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::Trigger()->get(array('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::Graph()->get(array('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::Graph()->get(array('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 = new CRelationMap();
         // discovered items
         $dbRules = DBselect('SELECT id1.itemid,id2.parent_itemid' . ' FROM item_discovery id1,item_discovery id2,items i' . ' WHERE ' . dbConditionInt('id1.itemid', $itemids) . ' AND id1.parent_itemid=id2.itemid' . ' AND i.itemid=id1.itemid' . ' AND i.flags=' . ZBX_FLAG_DISCOVERY_CREATED);
         while ($rule = DBfetch($dbRules)) {
             $relationMap->addRelation($rule['itemid'], $rule['parent_itemid']);
         }
         // item prototypes
         // TODO: this should not be in the item API
         $dbRules = DBselect('SELECT id.parent_itemid,id.itemid' . ' FROM item_discovery id,items i' . ' WHERE ' . dbConditionInt('id.itemid', $itemids) . ' AND i.itemid=id.itemid' . ' AND i.flags=' . ZBX_FLAG_DISCOVERY_PROTOTYPE);
         while ($rule = DBfetch($dbRules)) {
             $relationMap->addRelation($rule['itemid'], $rule['parent_itemid']);
         }
         $discoveryRules = API::DiscoveryRule()->get(array('output' => $options['selectDiscoveryRule'], 'itemids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
         $result = $relationMap->mapOne($result, $discoveryRules, 'discoveryRule');
     }
     // adding item discovery
     if ($options['selectItemDiscovery'] !== null) {
         $itemDiscoveries = API::getApiService()->select('item_discovery', array('output' => $this->outputExtend($options['selectItemDiscovery'], array('itemdiscoveryid', 'itemid')), 'filter' => array('itemid' => array_keys($result)), 'preservekeys' => true));
         $relationMap = $this->createRelationMap($itemDiscoveries, 'itemid', 'itemdiscoveryid');
         $itemDiscoveries = $this->unsetExtraFields($itemDiscoveries, array('itemid', 'itemdiscoveryid'), $options['selectItemDiscovery']);
         $result = $relationMap->mapOne($result, $itemDiscoveries, 'itemDiscovery');
     }
     // adding history data
     $requestedOutput = array();
     if ($this->outputIsRequested('lastclock', $options['output'])) {
         $requestedOutput['lastclock'] = true;
     }
     if ($this->outputIsRequested('lastns', $options['output'])) {
         $requestedOutput['lastns'] = true;
     }
     if ($this->outputIsRequested('lastvalue', $options['output'])) {
         $requestedOutput['lastvalue'] = true;
     }
     if ($this->outputIsRequested('prevvalue', $options['output'])) {
         $requestedOutput['prevvalue'] = true;
     }
     if ($requestedOutput) {
         $history = Manager::History()->getLast($result, 2, ZBX_HISTORY_PERIOD);
         foreach ($result as &$item) {
             $lastHistory = isset($history[$item['itemid']][0]) ? $history[$item['itemid']][0] : null;
//.........这里部分代码省略.........
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:101,代码来源:CItem.php

示例7: foreach

     $i = 1;
     foreach ($steps as $snum => $step) {
         $steps[$snum]['no'] = $i++;
         $stepid = isset($step['httpstepid']) ? $step['httpstepid'] : null;
         if (!is_null($stepid)) {
             $steps[$snum]['webstepid'] = $stepid;
             unset($steps[$snum]['httpstepid']);
         }
     }
 }
 $httpTest = array('hostid' => $_REQUEST['hostid'], 'name' => $_REQUEST['name'], 'authentication' => $_REQUEST['authentication'], 'delay' => $_REQUEST['delay'], 'status' => $_REQUEST['status'], 'agent' => $_REQUEST['agent'], 'macros' => $_REQUEST['macros'], 'steps' => $steps);
 $db_app_result = DBselect('SELECT a.applicationid' . ' FROM applications a' . ' WHERE a.name=' . zbx_dbstr($_REQUEST['application']) . ' AND a.hostid=' . $_REQUEST['hostid']);
 if ($applicationid = DBfetch($db_app_result)) {
     $httpTest['applicationid'] = $applicationid['applicationid'];
 } else {
     $result = API::Application()->create(array('name' => $_REQUEST['application'], 'hostid' => $_REQUEST['hostid']));
     if (!$result) {
         throw new Exception(_('Cannot add new application.') . ' [ ' . $application . ' ]');
     } else {
         $httpTest['applicationid'] = reset($result['applicationids']);
     }
 }
 if ($_REQUEST['authentication'] != HTTPTEST_AUTH_NONE) {
     $httpTest['http_user'] = $_REQUEST['http_user'];
     $httpTest['http_password'] = $_REQUEST['http_password'];
 } else {
     $httpTest['http_user'] = '';
     $httpTest['http_password'] = '';
 }
 if (isset($_REQUEST['httptestid'])) {
     $httpTest['httptestid'] = $httptestid = $_REQUEST['httptestid'];
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:httpconf.php

示例8: processApplications

 /**
  * Import applications.
  */
 protected function processApplications()
 {
     $allApplciations = $this->getFormattedApplications();
     if (empty($allApplciations)) {
         return;
     }
     $applicationsToCreate = array();
     foreach ($allApplciations as $host => $applications) {
         if (!$this->referencer->isProcessedHost($host)) {
             continue;
         }
         $hostid = $this->referencer->resolveHostOrTemplate($host);
         foreach ($applications as $application) {
             $application['hostid'] = $hostid;
             $appId = $this->referencer->resolveApplication($hostid, $application['name']);
             if (!$appId) {
                 $applicationsToCreate[] = $application;
             }
         }
     }
     // create the applications and create a hash hostid->name->applicationid
     if (!empty($applicationsToCreate)) {
         $newApplicationsIds = API::Application()->create($applicationsToCreate);
         foreach ($newApplicationsIds['applicationids'] as $anum => $applicationId) {
             $application = $applicationsToCreate[$anum];
             $this->referencer->addApplicationRef($application['hostid'], $application['name'], $applicationId);
         }
     }
     // refresh applications because templated ones can be inherited to host and used in items
     $this->referencer->refreshApplications();
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:34,代码来源:CConfigurationImport.php

示例9: CView

    $applicationView = new CView('configuration.application.edit', $data);
    $applicationView->render();
    $applicationView->show();
} else {
    $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name'));
    $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
    CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
    CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
    $pageFilter = new CPageFilter(array('groups' => array('editable' => true, 'with_hosts_and_templates' => true), 'hosts' => array('editable' => true, 'templated_hosts' => true), 'hostid' => getRequest('hostid'), 'groupid' => getRequest('groupid')));
    $data = array('pageFilter' => $pageFilter, 'sort' => $sortField, 'sortorder' => $sortOrder, 'hostid' => $pageFilter->hostid, 'groupid' => $pageFilter->groupid);
    if ($pageFilter->hostsSelected) {
        // get application ids
        $applications = API::Application()->get(array('hostids' => $pageFilter->hostid > 0 ? $pageFilter->hostid : null, 'groupids' => $pageFilter->groupid > 0 ? $pageFilter->groupid : null, 'output' => array('applicationid'), 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1));
        $applicationIds = zbx_objectValues($applications, 'applicationid');
        // get applications
        $data['applications'] = API::Application()->get(array('applicationids' => $applicationIds, 'output' => API_OUTPUT_EXTEND, 'selectItems' => array('itemid'), 'selectHost' => array('hostid', 'name')));
        order_result($data['applications'], $sortField, $sortOrder);
        // fetch template application source parents
        $applicationSourceParentIds = getApplicationSourceParentIds($applicationIds);
        $parentAppIds = array();
        foreach ($applicationSourceParentIds as $applicationParentIds) {
            foreach ($applicationParentIds as $parentId) {
                $parentAppIds[$parentId] = $parentId;
            }
        }
        if ($parentAppIds) {
            $parentTemplates = DBfetchArrayAssoc(DBselect('SELECT a.applicationid,h.hostid,h.name' . ' FROM applications a,hosts h' . ' WHERE a.hostid=h.hostid' . ' AND ' . dbConditionInt('a.applicationid', $parentAppIds)), 'applicationid');
            foreach ($data['applications'] as &$application) {
                if ($application['templateids'] && isset($applicationSourceParentIds[$application['applicationid']])) {
                    foreach ($applicationSourceParentIds[$application['applicationid']] as $parentAppId) {
                        $application['sourceTemplates'][] = $parentTemplates[$parentAppId];
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:applications.php

示例10: elseif

} elseif (isset($_REQUEST['save']) && $_REQUEST['form_hostid'] > 0) {
    $delay_flex = get_request('delay_flex', array());
    $db_delay_flex = '';
    foreach ($delay_flex as $value) {
        $db_delay_flex .= $value['delay'] . '/' . $value['period'] . ';';
    }
    $db_delay_flex = trim($db_delay_flex, ';');
    $applications = get_request('applications', array());
    $application = reset($applications);
    if (empty($application)) {
        array_shift($applications);
    }
    DBstart();
    $result = true;
    if (!zbx_empty($_REQUEST['new_application'])) {
        $new_appid = API::Application()->create(array('name' => $_REQUEST['new_application'], 'hostid' => $_REQUEST['form_hostid']));
        if ($new_appid) {
            $new_appid = reset($new_appid['applicationids']);
            $applications[$new_appid] = $new_appid;
        } else {
            $result = false;
        }
    }
    if ($result) {
        $item = array('name' => get_request('name'), 'description' => get_request('description'), 'key_' => get_request('key'), 'hostid' => get_request('form_hostid'), 'interfaceid' => get_request('interfaceid', 0), 'delay' => get_request('delay'), 'history' => get_request('history'), 'status' => get_request('status'), 'type' => get_request('type'), 'snmp_community' => get_request('snmp_community'), 'snmp_oid' => get_request('snmp_oid'), 'value_type' => get_request('value_type'), 'trapper_hosts' => get_request('trapper_hosts'), 'port' => get_request('port'), 'units' => get_request('units'), 'multiplier' => get_request('multiplier', 0), 'delta' => get_request('delta'), 'snmpv3_securityname' => get_request('snmpv3_securityname'), 'snmpv3_securitylevel' => get_request('snmpv3_securitylevel'), 'snmpv3_authpassphrase' => get_request('snmpv3_authpassphrase'), 'snmpv3_privpassphrase' => get_request('snmpv3_privpassphrase'), 'formula' => get_request('formula'), 'trends' => get_request('trends'), 'logtimefmt' => get_request('logtimefmt'), 'valuemapid' => get_request('valuemapid'), 'delay_flex' => $db_delay_flex, 'authtype' => get_request('authtype'), 'username' => get_request('username'), 'password' => get_request('password'), 'publickey' => get_request('publickey'), 'privatekey' => get_request('privatekey'), 'params' => get_request('params'), 'ipmi_sensor' => get_request('ipmi_sensor'), 'data_type' => get_request('data_type'), 'applications' => $applications, 'inventory_link' => get_request('inventory_link'));
        if (isset($_REQUEST['itemid'])) {
            $db_item = get_item_by_itemid_limited($_REQUEST['itemid']);
            $db_item['applications'] = get_applications_by_itemid($_REQUEST['itemid']);
            foreach ($item as $field => $value) {
                if ($item[$field] == $db_item[$field]) {
                    unset($item[$field]);
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:31,代码来源:items.php

示例11: parseMain


//.........这里部分代码省略.........
                 }
             }
         }
         // delete missing items
         if ($rules['items']['deleteMissing']) {
             $dbItems = API::Item()->get(array('output' => array('itemid', 'key_', 'hostid'), 'hostids' => $processedHostIds, 'preservekeys' => true, 'nopermissions' => true, 'inherited' => false, 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_NORMAL)));
             $itemIdsXML = array();
             foreach ($dbItems as $dbItem) {
                 if (isset($itemsXML[$dbItem['hostid']][$dbItem['key_']])) {
                     $itemIdsXML[$dbItem['itemid']] = $dbItem['itemid'];
                 }
             }
             $itemsToDelete = array_diff_key($dbItems, $itemIdsXML);
             if ($itemsToDelete) {
                 API::Item()->delete(array_keys($itemsToDelete));
             }
         }
         // delete missing applications
         if ($rules['applications']['deleteMissing']) {
             $applicationsXML = array();
             foreach ($hosts as $host) {
                 $host_db = self::mapXML2arr($host, XML_TAG_HOST);
                 $current_hostid = isset($processedHostIds[$host_db['host']]) ? $processedHostIds[$host_db['host']] : false;
                 if ($current_hostid) {
                     $items = $xpath->query('items/item', $host);
                     foreach ($items as $item) {
                         $applications = $xpath->query('applications/application', $item);
                         foreach ($applications as $application) {
                             $applicationsXML[$current_hostid][$application->nodeValue] = $application->nodeValue;
                         }
                     }
                 }
             }
             $dbApplications = API::Application()->get(array('output' => array('applicationid', 'hostid', 'name'), 'hostids' => $processedHostIds, 'preservekeys' => true, 'nopermissions' => true, 'inherited' => false));
             $applicationsIdsXML = array();
             foreach ($dbApplications as $dbApplication) {
                 if (isset($applicationsXML[$dbApplication['hostid']][$dbApplication['name']])) {
                     $applicationsIdsXML[$dbApplication['applicationid']] = $dbApplication['applicationid'];
                 }
             }
             $applicationsToDelete = array_diff_key($dbApplications, $applicationsIdsXML);
             if ($applicationsToDelete) {
                 API::Application()->delete(array_keys($applicationsToDelete));
             }
         }
         // cycle each host again and create/update other objects
         foreach ($hosts as $host) {
             $host_db = self::mapXML2arr($host, XML_TAG_HOST);
             if (!isset($host_db['status'])) {
                 $host_db['status'] = HOST_STATUS_TEMPLATE;
             }
             $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));
                     }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:67,代码来源:CXmlImport18.php

示例12: isset

     }
     break;
 case 'templates':
     $templates = API::Template()->get(array('editable' => isset($data['editable']) ? $data['editable'] : null, 'output' => array('templateid', 'name'), 'search' => isset($data['search']) ? array('name' => $data['search']) : null, 'limit' => $config['search_limit']));
     if ($templates) {
         CArrayHelper::sort($templates, array(array('field' => 'name', 'order' => ZBX_SORT_UP)));
         if (isset($data['limit'])) {
             $templates = array_slice($templates, 0, $data['limit']);
         }
         foreach ($templates as $template) {
             $result[] = array('id' => $template['templateid'], 'name' => $template['name']);
         }
     }
     break;
 case 'applications':
     $applications = API::Application()->get(array('hostids' => zbx_toArray($data['hostid']), 'output' => array('applicationid', 'name'), 'search' => isset($data['search']) ? array('name' => $data['search']) : null, 'limit' => $config['search_limit']));
     if ($applications) {
         CArrayHelper::sort($applications, array(array('field' => 'name', 'order' => ZBX_SORT_UP)));
         if (isset($data['limit'])) {
             $applications = array_slice($applications, 0, $data['limit']);
         }
         foreach ($applications as $application) {
             $result[] = array('id' => $application['applicationid'], 'name' => $application['name']);
         }
     }
     break;
 case 'triggers':
     $triggers = API::Trigger()->get(array('editable' => isset($data['editable']) ? $data['editable'] : null, 'output' => array('triggerid', 'description'), 'selectHosts' => array('name'), 'search' => isset($data['search']) ? array('description' => $data['search']) : null, 'limit' => $config['search_limit']));
     if ($triggers) {
         CArrayHelper::sort($triggers, array(array('field' => 'description', 'order' => ZBX_SORT_UP)));
         if (isset($data['limit'])) {
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:31,代码来源:jsrpc.php

示例13: CForm

 $form = new CForm();
 $form->setName('applicationform');
 $form->setAttribute('id', 'applications');
 $table = new CTableInfo(_('No applications found.'));
 $table->setHeader(array($multiselect ? new CCheckBox('allApplications', null, "javascript: checkAll('" . $form->getName() . "', 'allApplications', 'applications');") : null, _('Name')));
 $options = array('output' => array('applicationid', 'name'), 'nodeids' => $nodeId, 'hostids' => $hostid, 'expandData' => true);
 if (is_null($hostid)) {
     $options['groupids'] = $groupid;
 }
 if (!is_null($writeonly)) {
     $options['editable'] = true;
 }
 if (!is_null($templated)) {
     $options['templated'] = $templated;
 }
 $apps = API::Application()->get($options);
 CArrayHelper::sort($apps, array('name'));
 $data = array();
 $parentId = $dstfld1 ? zbx_jsvalue($dstfld1) : 'null';
 foreach ($apps as &$app) {
     $name = new CSpan($app['name'], 'link');
     $name->attr('id', 'spanid' . $app['applicationid']);
     $jsAction = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($app['applicationid']) . ', ' . $parentId . ');';
     if ($multiselect) {
         $checkBox = new CCheckBox('applications[' . zbx_jsValue('applicationid') . ']', null, null, $app['applicationid']);
     }
     $name->setAttribute('onclick', $jsAction . ' jQuery(this).removeAttr("onclick");');
     $data[$app['applicationid']] = array('id' => $app['applicationid'], 'name' => $app['name'], 'prefix' => get_node_name_by_elid($app['applicationid'], null, NAME_DELIMITER));
     $table->addRow(array($multiselect ? $checkBox : null, $name));
 }
 unset($app);
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:popup.php

示例14: get

 /**
  * Get items data.
  *
  * @param array $options
  * @param array $options['itemids']
  * @param array $options['hostids']
  * @param array $options['groupids']
  * @param array $options['triggerids']
  * @param array $options['applicationids']
  * @param boolean $options['status']
  * @param boolean $options['templated_items']
  * @param boolean $options['editable']
  * @param boolean $options['count']
  * @param string $options['pattern']
  * @param int $options['limit']
  * @param string $options['order']
  *
  * @return array|int item data as array or false if error
  */
 public function get($options = array())
 {
     $result = array();
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     // allowed columns for sorting
     $sortColumns = array('itemid', 'name', 'key_', 'delay', 'history', 'trends', 'type', 'status');
     // allowed output options for [ select_* ] params
     $subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND, API_OUTPUT_CUSTOM);
     $sqlParts = array('select' => array('items' => 'i.itemid'), 'from' => array('items' => 'items i'), 'where' => array('webtype' => 'i.type<>' . ITEM_TYPE_HTTPTEST, 'flags' => 'i.flags IN (' . ZBX_FLAG_DISCOVERY_NORMAL . ',' . ZBX_FLAG_DISCOVERY_CREATED . ')'), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'groupids' => null, 'templateids' => null, 'hostids' => null, 'proxyids' => null, 'itemids' => null, 'interfaceids' => null, 'graphids' => null, 'triggerids' => null, 'applicationids' => null, 'webitems' => null, 'inherited' => null, 'templated' => null, 'monitored' => null, 'editable' => null, 'nopermissions' => null, 'group' => null, 'host' => null, 'application' => null, 'with_triggers' => null, 'filter' => null, 'search' => null, 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectHosts' => null, 'selectInterfaces' => null, 'selectTriggers' => null, 'selectGraphs' => null, 'selectApplications' => null, 'selectDiscoveryRule' => null, 'selectItemDiscovery' => null, 'countOutput' => null, 'groupCount' => null, 'preservekeys' => null, 'sortfield' => '', 'sortorder' => '', 'limit' => null, 'limitSelects' => null);
     $options = zbx_array_merge($defOptions, $options);
     if (is_array($options['output'])) {
         unset($sqlParts['select']['items']);
         $dbTable = DB::getSchema('items');
         $sqlParts['select']['itemid'] = 'i.itemid';
         foreach ($options['output'] as $field) {
             if (isset($dbTable['fields'][$field])) {
                 $sqlParts['select'][$field] = 'i.' . $field;
             }
         }
         $options['output'] = API_OUTPUT_CUSTOM;
     }
     // editable + permission check
     if ($userType != USER_TYPE_SUPER_ADMIN && !$options['nopermissions']) {
         $permission = $options['editable'] ? PERM_READ_WRITE : PERM_READ_ONLY;
         $userGroups = getUserGroupsByUserId($userid);
         $sqlParts['where'][] = 'EXISTS (' . 'SELECT NULL' . ' FROM hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE i.hostid=hgg.hostid' . ' GROUP BY hgg.hostid' . ' HAVING MIN(r.permission)>=' . $permission . ')';
     }
     // itemids
     if (!is_null($options['itemids'])) {
         zbx_value2array($options['itemids']);
         $sqlParts['where']['itemid'] = dbConditionInt('i.itemid', $options['itemids']);
     }
     // templateids
     if (!is_null($options['templateids'])) {
         zbx_value2array($options['templateids']);
         if (!is_null($options['hostids'])) {
             zbx_value2array($options['hostids']);
             $options['hostids'] = array_merge($options['hostids'], $options['templateids']);
         } else {
             $options['hostids'] = $options['templateids'];
         }
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         if ($options['output'] != API_OUTPUT_EXTEND) {
             $sqlParts['select']['hostid'] = 'i.hostid';
         }
         $sqlParts['where']['hostid'] = dbConditionInt('i.hostid', $options['hostids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['i'] = 'i.hostid';
         }
     }
     // interfaceids
     if (!is_null($options['interfaceids'])) {
         zbx_value2array($options['interfaceids']);
         if ($options['output'] != API_OUTPUT_EXTEND) {
             $sqlParts['select']['interfaceid'] = 'i.interfaceid';
         }
         $sqlParts['where']['interfaceid'] = dbConditionInt('i.interfaceid', $options['interfaceids']);
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['i'] = 'i.interfaceid';
         }
     }
     // groupids
     if (!is_null($options['groupids'])) {
         zbx_value2array($options['groupids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['groupid'] = 'hg.groupid';
         }
         $sqlParts['from']['hosts_groups'] = 'hosts_groups hg';
         $sqlParts['where'][] = dbConditionInt('hg.groupid', $options['groupids']);
         $sqlParts['where'][] = 'hg.hostid=i.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['hg'] = 'hg.groupid';
         }
     }
     // proxyids
     if (!is_null($options['proxyids'])) {
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CItem.php

示例15: CDiv

    $hostList->addRow(_('IPMI interfaces'), (new CDiv($ifTab))->addClass(ZBX_STYLE_TABLE_FORMS_SEPARATOR)->setAttribute('data-type', 'ipmi')->setWidth(ZBX_HOST_INTERFACE_WIDTH));
}
$hostList->addRow(_('Description'), (new CTextArea('description', $data['description']))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH));
// Proxy
if ($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED) {
    $proxy = new CComboBox('proxy_hostid', $data['proxy_hostid'], null, [0 => _('(no proxy)')] + $data['proxies']);
    $proxy->setEnabled($data['flags'] != ZBX_FLAG_DISCOVERY_CREATED);
} else {
    $proxy = (new CTextBox(null, $data['proxy_hostid'] != 0 ? $data['proxies'][$data['proxy_hostid']] : _('(no proxy)'), true))->setWidth(ZBX_TEXTAREA_STANDARD_WIDTH);
    $hostList->addVar('proxy_hostid', $data['proxy_hostid']);
}
$hostList->addRow(_('Monitored by proxy'), $proxy);
$hostList->addRow(_('Enabled'), (new CCheckBox('status', HOST_STATUS_MONITORED))->setChecked($data['status'] == HOST_STATUS_MONITORED));
if ($data['clone_hostid'] != 0) {
    // host applications
    $hostApps = API::Application()->get(['output' => ['name'], 'hostids' => [$data['clone_hostid']], 'inherited' => false, 'preservekeys' => true, 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]);
    if ($hostApps) {
        $applicationsList = [];
        foreach ($hostApps as $hostAppId => $hostApp) {
            $applicationsList[$hostAppId] = $hostApp['name'];
        }
        order_result($applicationsList);
        $listBox = new CListBox('applications', null, 8);
        $listBox->setAttribute('disabled', 'disabled');
        $listBox->addItems($applicationsList);
        $hostList->addRow(_('Applications'), $listBox);
    }
    // host items
    $hostItems = API::Item()->get(['output' => ['itemid', 'hostid', 'key_', 'name'], 'hostids' => [$data['clone_hostid']], 'inherited' => false, 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]);
    if ($hostItems) {
        $hostItems = CMacrosResolverHelper::resolveItemNames($hostItems);
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:configuration.host.edit.php


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