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


PHP API::Trigger方法代码示例

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


在下文中一共展示了API::Trigger方法的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()
 {
     // 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

示例4: bodyToString

 public function bodyToString()
 {
     $this->cleanItems();
     $config = select_config();
     // array of triggers (not classified, information, warning, average, high, disaster) in problem state
     $triggersProblemState = [];
     // number of triggers in OK state
     $triggersOkState = 0;
     $options = ['output' => ['triggerid', 'priority', 'value'], 'monitored' => true, 'skipDependent' => true];
     if ($this->groupid != 0) {
         $options['groupids'] = $this->groupid;
     }
     $triggers = API::Trigger()->get($options);
     foreach ($triggers as $trigger) {
         switch ($trigger['value']) {
             case TRIGGER_VALUE_TRUE:
                 if (!array_key_exists($trigger['priority'], $triggersProblemState)) {
                     $triggersProblemState[$trigger['priority']] = 0;
                 }
                 $triggersProblemState[$trigger['priority']]++;
                 break;
             case TRIGGER_VALUE_FALSE:
                 $triggersOkState++;
         }
     }
     $severityCells = [getSeverityCell(null, $config, $triggersOkState . SPACE . _('Ok'), true)];
     for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
         $severityCount = isset($triggersProblemState[$severity]) ? $triggersProblemState[$severity] : 0;
         $severityCells[] = getSeverityCell($severity, $config, $severityCount . SPACE . getSeverityName($severity, $config), !$severityCount);
     }
     if ($this->style == STYLE_HORIZONTAL) {
         $this->addRow($severityCells);
     } else {
         foreach ($severityCells as $severityCell) {
             $this->addRow($severityCell);
         }
     }
     return parent::bodyToString();
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:39,代码来源:CTriggersInfo.php

示例5: make_latest_issues

/**
 * Create DIV with latest problem triggers.
 *
 * If no sortfield and sortorder are defined, the sort indicater in the column name will not be displayed.
 *
 * @param array  $filter['screenid']
 * @param array  $filter['groupids']
 * @param array  $filter['hostids']
 * @param array  $filter['maintenance']
 * @param int    $filter['extAck']
 * @param int    $filter['severity']
 * @param int    $filter['limit']
 * @param string $filter['sortfield']
 * @param string $filter['sortorder']
 * @param string $filter['backUrl']
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = array())
{
    // hide the sort indicator if no sortfield and sortorder are given
    $showSortIndicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (!isset($filter['sortfield'])) {
        $filter['sortfield'] = 'lastchange';
    }
    if (!isset($filter['sortorder'])) {
        $filter['sortorder'] = ZBX_SORT_DOWN;
    }
    $options = array('groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE));
    $triggers = API::Trigger()->get(array_merge($options, array('withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'output' => array('triggerid', 'state', 'error', 'url', 'expression', 'description', 'priority', 'lastchange'), 'selectHosts' => array('hostid', 'name'), 'selectLastEvent' => array('eventid', 'acknowledged', 'objectid', 'clock', 'ns'), 'sortfield' => $filter['sortfield'], 'sortorder' => $filter['sortorder'], 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT)));
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggersTotalCount = API::Trigger()->get(array_merge($options, array('countOutput' => true)));
    // get acknowledges
    $eventIds = array();
    foreach ($triggers as $trigger) {
        if ($trigger['lastEvent']) {
            $eventIds[] = $trigger['lastEvent']['eventid'];
        }
    }
    if ($eventIds) {
        $eventAcknowledges = API::Event()->get(array('eventids' => $eventIds, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true));
    }
    foreach ($triggers as $tnum => $trigger) {
        // if trigger is lost (broken expression) we skip it
        if (empty($trigger['hosts'])) {
            unset($triggers[$tnum]);
            continue;
        }
        $host = reset($trigger['hosts']);
        $trigger['hostid'] = $host['hostid'];
        $trigger['hostname'] = $host['name'];
        if ($trigger['lastEvent']) {
            $trigger['lastEvent']['acknowledges'] = isset($eventAcknowledges[$trigger['lastEvent']['eventid']]) ? $eventAcknowledges[$trigger['lastEvent']['eventid']]['acknowledges'] : null;
        }
        $triggers[$tnum] = $trigger;
    }
    $hostIds = zbx_objectValues($triggers, 'hostid');
    // get hosts
    $hosts = API::Host()->get(array('hostids' => $hostIds, 'output' => array('hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'), 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true));
    // actions
    $actions = getEventActionsStatHints($eventIds);
    // ack params
    $ackParams = isset($filter['screenid']) ? array('screenid' => $filter['screenid']) : array();
    $config = select_config();
    // indicator of sort field
    if ($showSortIndicator) {
        $sortDiv = new CDiv(SPACE, $filter['sortorder'] === ZBX_SORT_DOWN ? 'icon_sortdown default_cursor' : 'icon_sortup default_cursor');
        $sortDiv->addStyle('float: left');
        $hostHeaderDiv = new CDiv(array(_('Host'), SPACE));
        $hostHeaderDiv->addStyle('float: left');
        $issueHeaderDiv = new CDiv(array(_('Issue'), SPACE));
        $issueHeaderDiv->addStyle('float: left');
        $lastChangeHeaderDiv = new CDiv(array(_('Time'), SPACE));
        $lastChangeHeaderDiv->addStyle('float: left');
    }
    $table = new CTableInfo(_('No events found.'));
    $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, $showSortIndicator && $filter['sortfield'] === 'hostname' ? array($hostHeaderDiv, $sortDiv) : _('Host'), $showSortIndicator && $filter['sortfield'] === 'priority' ? array($issueHeaderDiv, $sortDiv) : _('Issue'), $showSortIndicator && $filter['sortfield'] === 'lastchange' ? array($lastChangeHeaderDiv, $sortDiv) : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
    $scripts = API::Script()->getScriptsByHosts($hostIds);
    // triggers
    foreach ($triggers as $trigger) {
        $host = $hosts[$trigger['hostid']];
        $hostName = new CSpan($host['name'], 'link_menu');
        $hostName->setMenuPopup(getMenuPopupHost($host, $scripts[$host['hostid']]));
        // add maintenance icon with hint if host is in maintenance
        $maintenanceIcon = null;
        if ($host['maintenance_status']) {
            $maintenanceIcon = new CDiv(null, 'icon-maintenance-abs');
            // get maintenance
            $maintenances = API::Maintenance()->get(array('maintenanceids' => $host['maintenanceid'], 'output' => API_OUTPUT_EXTEND, 'limit' => 1));
            if ($maintenance = reset($maintenances)) {
                $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                if (isset($maintenance['description'])) {
                    // double quotes mandatory
                    $hint .= "\n" . $maintenance['description'];
                }
                $maintenanceIcon->setHint($hint);
                $maintenanceIcon->addClass('pointer');
            }
            $hostName->addClass('left-to-icon-maintenance-abs');
        }
//.........这里部分代码省略.........
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:blocks.inc.php

示例6: access_deny

$trigger = API::Trigger()->get(['triggerids' => $_REQUEST['triggerid'], 'output' => API_OUTPUT_EXTEND, 'expandDescription' => true]);
if (!$trigger) {
    access_deny();
}
$trigger = reset($trigger);
/*
 * Actions
 */
if (hasRequest('update')) {
    DBstart();
    $result = DBexecute('UPDATE triggers' . ' SET comments=' . zbx_dbstr(getRequest('comments')) . ' WHERE triggerid=' . zbx_dbstr(getRequest('triggerid')));
    $trigger['comments'] = $_REQUEST['comments'];
    if ($result) {
        add_audit(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_TRIGGER, _('Trigger') . ' [' . $_REQUEST['triggerid'] . '] [' . $trigger['description'] . '] ' . _('Comments') . ' [' . $_REQUEST['comments'] . ']');
    }
    $result = DBend($result);
    show_messages($result, _('Description updated'), _('Cannot update description'));
} elseif (isset($_REQUEST['cancel'])) {
    jsRedirect('tr_status.php');
    exit;
}
/*
 * Display
 */
$triggerEditable = API::Trigger()->get(['triggerids' => $_REQUEST['triggerid'], 'output' => ['triggerid'], 'editable' => true]);
$data = ['triggerid' => getRequest('triggerid'), 'trigger' => $trigger, 'isTriggerEditable' => !empty($triggerEditable), 'isCommentExist' => !empty($trigger['comments'])];
// render view
$triggerCommentView = new CView('monitoring.triggerComment', $data);
$triggerCommentView->render();
$triggerCommentView->show();
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:tr_comments.php

示例7: 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

示例8: addRelatedObjects

 protected function addRelatedObjects(array $options, array $result)
 {
     $result = parent::addRelatedObjects($options, $result);
     $eventIds = array_keys($result);
     // adding hosts
     if ($options['selectHosts'] !== null && $options['selectHosts'] != API_OUTPUT_COUNT) {
         // trigger events
         if ($options['object'] == EVENT_OBJECT_TRIGGER) {
             $query = DBselect('SELECT e.eventid,i.hostid' . ' FROM events e,functions f,items i' . ' WHERE ' . dbConditionInt('e.eventid', $eventIds) . ' AND e.objectid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND e.object=' . zbx_dbstr($options['object']) . ' AND e.source=' . zbx_dbstr($options['source']));
         } elseif ($options['object'] == EVENT_OBJECT_ITEM || $options['object'] == EVENT_OBJECT_LLDRULE) {
             $query = DBselect('SELECT e.eventid,i.hostid' . ' FROM events e,items i' . ' WHERE ' . dbConditionInt('e.eventid', $eventIds) . ' AND e.objectid=i.itemid' . ' AND e.object=' . zbx_dbstr($options['object']) . ' AND e.source=' . zbx_dbstr($options['source']));
         }
         $relationMap = new CRelationMap();
         while ($relation = DBfetch($query)) {
             $relationMap->addRelation($relation['eventid'], $relation['hostid']);
         }
         $hosts = API::Host()->get(array('output' => $options['selectHosts'], 'hostids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
         $result = $relationMap->mapMany($result, $hosts, 'hosts');
     }
     // adding the related object
     if ($options['selectRelatedObject'] !== null && $options['selectRelatedObject'] != API_OUTPUT_COUNT && $options['object'] != EVENT_OBJECT_AUTOREGHOST) {
         $relationMap = new CRelationMap();
         foreach ($result as $event) {
             $relationMap->addRelation($event['eventid'], $event['objectid']);
         }
         switch ($options['object']) {
             case EVENT_OBJECT_TRIGGER:
                 $api = API::Trigger();
                 break;
             case EVENT_OBJECT_DHOST:
                 $api = API::DHost();
                 break;
             case EVENT_OBJECT_DSERVICE:
                 $api = API::DService();
                 break;
             case EVENT_OBJECT_ITEM:
                 $api = API::Item();
                 break;
             case EVENT_OBJECT_LLDRULE:
                 $api = API::DiscoveryRule();
                 break;
         }
         $objects = $api->get(array('output' => $options['selectRelatedObject'], $api->pkOption() => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true));
         $result = $relationMap->mapOne($result, $objects, 'relatedObject');
     }
     // adding alerts
     if ($options['select_alerts'] !== null && $options['select_alerts'] != API_OUTPUT_COUNT) {
         $relationMap = $this->createRelationMap($result, 'eventid', 'alertid', 'alerts');
         $alerts = API::Alert()->get(array('output' => $options['select_alerts'], 'selectMediatypes' => API_OUTPUT_EXTEND, 'alertids' => $relationMap->getRelatedIds(), 'nopermissions' => true, 'preservekeys' => true, 'sortfield' => 'clock', 'sortorder' => ZBX_SORT_DOWN));
         $result = $relationMap->mapMany($result, $alerts, 'alerts');
     }
     // adding acknowledges
     if ($options['select_acknowledges'] !== null) {
         if ($options['select_acknowledges'] != API_OUTPUT_COUNT) {
             // create the base query
             $sqlParts = API::getApiService()->createSelectQueryParts('acknowledges', 'a', array('output' => $this->outputExtend($options['select_acknowledges'], array('acknowledgeid', 'eventid', 'clock')), 'filter' => array('eventid' => $eventIds)));
             $sqlParts['order'][] = 'a.clock DESC';
             // if the user data is requested via extended output or specified fields, join the users table
             $userFields = array('alias', 'name', 'surname');
             $requestUserData = array();
             foreach ($userFields as $userField) {
                 if ($this->outputIsRequested($userField, $options['select_acknowledges'])) {
                     $requestUserData[] = $userField;
                 }
             }
             if ($requestUserData) {
                 foreach ($requestUserData as $userField) {
                     $sqlParts = $this->addQuerySelect('u.' . $userField, $sqlParts);
                 }
                 $sqlParts['from'][] = 'users u';
                 $sqlParts['where'][] = 'a.userid=u.userid';
             }
             $acknowledges = DBFetchArrayAssoc(DBselect($this->createSelectQueryFromParts($sqlParts)), 'acknowledgeid');
             $relationMap = $this->createRelationMap($acknowledges, 'eventid', 'acknowledgeid');
             $acknowledges = $this->unsetExtraFields($acknowledges, array('eventid', 'acknowledgeid', 'clock'), $options['select_acknowledges']);
             $result = $relationMap->mapMany($result, $acknowledges, 'acknowledges');
         } else {
             $acknowledges = DBFetchArrayAssoc(DBselect('SELECT COUNT(a.acknowledgeid) AS rowscount,a.eventid' . ' FROM acknowledges a' . ' WHERE ' . dbConditionInt('a.eventid', $eventIds) . ' GROUP BY a.eventid'), 'eventid');
             foreach ($result as &$event) {
                 if (isset($acknowledges[$event['eventid']])) {
                     $event['acknowledges'] = $acknowledges[$event['eventid']]['rowscount'];
                 } else {
                     $event['acknowledges'] = 0;
                 }
             }
             unset($event);
         }
     }
     return $result;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:90,代码来源:CEvent.php

示例9: CTableInfo

** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
**/
$table = (new CTableInfo())->setHeader([_('Host group'), _('Without problems'), _('With problems'), _('Total')]);
// get host groups
$groups = API::HostGroup()->get(['output' => ['groupid', 'name'], 'groupids' => $data['filter']['groupids'], 'hostids' => isset($data['filter']['hostids']) ? $data['filter']['hostids'] : null, 'monitored_hosts' => true, 'preservekeys' => true]);
CArrayHelper::sort($groups, ['name']);
// get hosts
$hosts = API::Host()->get(['output' => ['hostid', 'name'], 'selectGroups' => ['groupid'], 'groupids' => array_keys($groups), 'hostids' => isset($data['filter']['hostids']) ? $data['filter']['hostids'] : null, 'filter' => ['maintenance_status' => $data['filter']['maintenance']], 'monitored_hosts' => true, 'preservekeys' => true]);
CArrayHelper::sort($hosts, ['name']);
// get triggers
$triggers = API::Trigger()->get(['output' => ['triggerid', 'priority'], 'selectHosts' => ['hostid'], 'search' => $data['filter']['trigger_name'] !== '' ? ['description' => $data['filter']['trigger_name']] : null, 'filter' => ['priority' => $data['filter']['severity'], 'value' => TRIGGER_VALUE_TRUE], 'maintenance' => $data['filter']['maintenance'], 'monitored' => true]);
if ($data['filter']['extAck']) {
    $hosts_with_unack_triggers = [];
    $triggers_unack = API::Trigger()->get(['output' => ['triggerid'], 'selectHosts' => ['hostid'], 'search' => $data['filter']['trigger_name'] !== '' ? ['description' => $data['filter']['trigger_name']] : null, 'filter' => ['priority' => $data['filter']['severity'], 'value' => TRIGGER_VALUE_TRUE], 'withLastEventUnacknowledged' => true, 'maintenance' => $data['filter']['maintenance'], 'monitored' => true, 'preservekeys' => true]);
    foreach ($triggers_unack as $tunack) {
        foreach ($tunack['hosts'] as $unack_host) {
            $hosts_with_unack_triggers[$unack_host['hostid']] = $unack_host['hostid'];
        }
    }
}
$hosts_data = [];
$problematic_host_list = [];
$lastUnack_host_list = [];
$highest_severity = [];
$highest_severity2 = [];
foreach ($triggers as $trigger) {
    foreach ($trigger['hosts'] as $trigger_host) {
        if (!isset($hosts[$trigger_host['hostid']])) {
            continue;
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:monitoring.widget.hosts.view.php

示例10: processTriggers

 /**
  * Import triggers.
  */
 protected function processTriggers()
 {
     $allTriggers = $this->getFormattedTriggers();
     if (empty($allTriggers)) {
         return;
     }
     $triggersToCreate = array();
     $triggersToUpdate = array();
     $triggersToCreateDependencies = array();
     foreach ($allTriggers as $trigger) {
         $triggerId = $this->referencer->resolveTrigger($trigger['description'], $trigger['expression']);
         if ($triggerId) {
             $deps = array();
             foreach ($trigger['dependencies'] as $dependency) {
                 $depTriggerId = $this->referencer->resolveTrigger($dependency['name'], $dependency['expression']);
                 if (!$depTriggerId) {
                     throw new Exception(_s('Trigger "%1$s" depends on trigger "%2$s", which does not exist.', $trigger['description'], $dependency['name']));
                 }
                 $deps[] = array('triggerid' => $depTriggerId);
             }
             $trigger['dependencies'] = $deps;
             $trigger['triggerid'] = $triggerId;
             $triggersToUpdate[] = $trigger;
         } else {
             $triggersToCreateDependencies[] = $trigger['dependencies'];
             unset($trigger['dependencies']);
             $triggersToCreate[] = $trigger;
         }
     }
     $triggerDependencies = array();
     $newTriggers = array();
     if ($this->options['triggers']['createMissing'] && $triggersToCreate) {
         $newTriggerIds = API::Trigger()->create($triggersToCreate);
         foreach ($newTriggerIds['triggerids'] as $tnum => $triggerId) {
             $trigger = $triggersToCreate[$tnum];
             $this->referencer->addTriggerRef($trigger['description'], $trigger['expression'], $triggerId);
             $newTriggers[$triggerId] = $trigger;
         }
     }
     // if we have new triggers with dependencies and they were created, create their dependencies
     if ($triggersToCreateDependencies && isset($newTriggerIds)) {
         foreach ($newTriggerIds['triggerids'] as $tnum => $triggerId) {
             $deps = array();
             foreach ($triggersToCreateDependencies[$tnum] as $dependency) {
                 $depTriggerId = $this->referencer->resolveTrigger($dependency['name'], $dependency['expression']);
                 if (!$depTriggerId) {
                     $trigger = $newTriggers[$triggerId];
                     throw new Exception(_s('Trigger "%1$s" depends on trigger "%2$s", which does not exist.', $trigger['description'], $dependency['name']));
                 }
                 $deps[] = array('triggerid' => $depTriggerId);
             }
             if (!empty($deps)) {
                 $triggerDependencies[] = array('triggerid' => $triggerId, 'dependencies' => $deps);
             }
         }
     }
     if ($this->options['triggers']['updateExisting'] && $triggersToUpdate) {
         API::Trigger()->update($triggersToUpdate);
     }
     if ($triggerDependencies) {
         API::Trigger()->update($triggerDependencies);
     }
     // refresh triggers because template triggers can be inherited to host and used in maps
     $this->referencer->refreshTriggers();
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:68,代码来源:CConfigurationImport.php

示例11: get

 /**
  * Get Template data
  *
  * @param array $options
  * @return array|boolean Template data as array or false if error
  */
 public function get($options = array())
 {
     $result = array();
     $nodeCheck = false;
     $userType = self::$userData['type'];
     $userid = self::$userData['userid'];
     // allowed columns for sorting
     $sortColumns = array('hostid', 'host', 'name');
     // allowed output options for [ select_* ] params
     $subselectsAllowedOutputs = array(API_OUTPUT_REFER, API_OUTPUT_EXTEND);
     $sqlParts = array('select' => array('templates' => 'h.hostid'), 'from' => array('hosts' => 'hosts h'), 'where' => array('h.status=' . HOST_STATUS_TEMPLATE), 'group' => array(), 'order' => array(), 'limit' => null);
     $defOptions = array('nodeids' => null, 'groupids' => null, 'templateids' => null, 'parentTemplateids' => null, 'hostids' => null, 'graphids' => null, 'itemids' => null, 'triggerids' => null, 'with_items' => null, 'with_triggers' => null, 'with_graphs' => null, 'editable' => null, 'nopermissions' => null, 'filter' => null, 'search' => '', 'searchByAny' => null, 'startSearch' => null, 'excludeSearch' => null, 'searchWildcardsEnabled' => null, 'output' => API_OUTPUT_REFER, 'selectGroups' => null, 'selectHosts' => null, 'selectTemplates' => null, 'selectParentTemplates' => null, 'selectItems' => null, 'selectDiscoveries' => null, 'selectTriggers' => null, 'selectGraphs' => null, 'selectApplications' => null, 'selectMacros' => null, 'selectScreens' => 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']['templates']);
         $dbTable = DB::getSchema('hosts');
         $sqlParts['select']['hostid'] = 'h.hostid';
         foreach ($options['output'] as $field) {
             if ($field == 'templateid') {
                 continue;
             }
             if (isset($dbTable['fields'][$field])) {
                 $sqlParts['select'][$field] = 'h.' . $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 h.hostid=hgg.hostid' . ' GROUP BY hgg.hostid' . ' HAVING MIN(r.permission)>=' . $permission . ')';
     }
     // nodeids
     $nodeids = !is_null($options['nodeids']) ? $options['nodeids'] : get_current_nodeid();
     // 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']['hgh'] = 'hg.hostid=h.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['hg'] = 'hg.groupid';
         }
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('hg.groupid', $nodeids);
         }
     }
     // templateids
     if (!is_null($options['templateids'])) {
         zbx_value2array($options['templateids']);
         $sqlParts['where']['templateid'] = dbConditionInt('h.hostid', $options['templateids']);
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('h.hostid', $nodeids);
         }
     }
     // parentTemplateids
     if (!is_null($options['parentTemplateids'])) {
         zbx_value2array($options['parentTemplateids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['parentTemplateid'] = 'ht.templateid as parentTemplateid';
         }
         $sqlParts['from']['hosts_templates'] = 'hosts_templates ht';
         $sqlParts['where'][] = dbConditionInt('ht.templateid', $options['parentTemplateids']);
         $sqlParts['where']['hht'] = 'h.hostid=ht.hostid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['templateid'] = 'ht.templateid';
         }
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('ht.templateid', $nodeids);
         }
     }
     // hostids
     if (!is_null($options['hostids'])) {
         zbx_value2array($options['hostids']);
         if ($options['output'] != API_OUTPUT_SHORTEN) {
             $sqlParts['select']['linked_hostid'] = 'ht.hostid as linked_hostid';
         }
         $sqlParts['from']['hosts_templates'] = 'hosts_templates ht';
         $sqlParts['where'][] = dbConditionInt('ht.hostid', $options['hostids']);
         $sqlParts['where']['hht'] = 'h.hostid=ht.templateid';
         if (!is_null($options['groupCount'])) {
             $sqlParts['group']['ht'] = 'ht.hostid';
         }
         if (!$nodeCheck) {
             $nodeCheck = true;
             $sqlParts['where'][] = DBin_node('ht.hostid', $nodeids);
         }
//.........这里部分代码省略.........
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:101,代码来源:CTemplate.php

示例12: selectTriggers

 /**
  * Select trigger ids for previously added trigger names/expressions.
  */
 protected function selectTriggers()
 {
     if (!empty($this->triggers)) {
         $this->triggersRefs = array();
         $dbTriggers = API::Trigger()->get(array('output' => array('triggerid', 'expression', 'description'), 'filter' => array('description' => array_keys($this->triggers), 'flags' => array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_PROTOTYPE, ZBX_FLAG_DISCOVERY_CREATED)), 'editable' => true));
         foreach ($dbTriggers as $dbTrigger) {
             $dbTriggerExpression = explode_exp($dbTrigger['expression']);
             if (isset($this->triggers[$dbTrigger['description']][$dbTriggerExpression])) {
                 $this->triggersRefs[$dbTrigger['description']][$dbTriggerExpression] = $dbTrigger['triggerid'];
             }
         }
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:16,代码来源:CImportReferencer.php

示例13: validateAddDependencies

 /**
  * Validates the input for the addDependencies() method.
  *
  * @param array  $triggerPrototypes
  * @param string $triggerPrototypes[]['triggerid']
  * @param array  $triggerPrototypes[]['dependencies']
  * @param string $triggerPrototypes[]['dependencies'][]['triggerid']
  *
  * @throws APIException if the given dependencies are invalid.
  */
 protected function validateAddDependencies(array $triggerPrototypes)
 {
     $depTriggerIds = [];
     foreach ($triggerPrototypes as $triggerPrototype) {
         if (!array_key_exists('dependencies', $triggerPrototype)) {
             continue;
         }
         foreach ($triggerPrototype['dependencies'] as $dependency) {
             $depTriggerIds[$dependency['triggerid']] = $dependency['triggerid'];
         }
     }
     if (!$depTriggerIds) {
         return;
     }
     // Check if given IDs are actual trigger prototypes and get discovery rules if they are.
     $depTriggerPrototypes = $this->get(['output' => ['triggerid'], 'selectDiscoveryRule' => ['itemid'], 'triggerids' => $depTriggerIds, 'preservekeys' => true]);
     if ($depTriggerPrototypes) {
         // Get current trigger prototype discovery rules.
         $dRules = $this->get(['output' => ['triggerid'], 'selectDiscoveryRule' => ['itemid'], 'triggerids' => zbx_objectValues($triggerPrototypes, 'triggerid'), 'preservekeys' => true]);
         foreach ($triggerPrototypes as $triggerPrototype) {
             if (!array_key_exists('dependencies', $triggerPrototype)) {
                 continue;
             }
             $dRuleId = $dRules[$triggerPrototype['triggerid']]['discoveryRule']['itemid'];
             // Check if current trigger prototype rules match dependent trigger prototype rules.
             foreach ($triggerPrototype['dependencies'] as $dependency) {
                 if (isset($depTriggerPrototypes[$dependency['triggerid']])) {
                     $depTriggerDRuleId = $depTriggerPrototypes[$dependency['triggerid']]['discoveryRule']['itemid'];
                     if (bccomp($depTriggerDRuleId, $dRuleId) != 0) {
                         self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
                     }
                 }
             }
         }
     }
     // Check other dependency IDs if those are normal triggers.
     $triggers = API::Trigger()->get(['output' => ['triggerid'], 'triggerids' => $depTriggerIds, 'filter' => ['flags' => [ZBX_FLAG_DISCOVERY_NORMAL]]]);
     if (!$depTriggerPrototypes && !$triggers) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
     }
     $this->checkDependencies($triggerPrototypes);
     $this->checkDependencyParents($triggerPrototypes);
     $this->checkDependencyDuplicates($triggerPrototypes);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:54,代码来源:CTriggerPrototype.php

示例14: resolveTriggerExpressionUserMacro

 /**
  * Resolve user macros in trigger expression.
  *
  * @param string $triggers[$triggerid]['expression']
  *
  * @return array
  */
 public function resolveTriggerExpressionUserMacro(array $triggers)
 {
     $usermacros = [];
     $macro_values = [];
     $types = ['usermacros' => true];
     // Find macros.
     foreach ($triggers as $triggerid => $trigger) {
         $matched_macros = $this->extractMacros([$trigger['expression']], $types);
         if ($matched_macros['usermacros']) {
             $usermacros[$triggerid] = ['hostids' => [], 'macros' => $matched_macros['usermacros']];
         }
     }
     if ($usermacros) {
         // Get hosts for triggers.
         $db_triggers = API::Trigger()->get(['output' => [], 'selectHosts' => ['hostid'], 'triggerids' => array_keys($usermacros), 'preservekeys' => true]);
         foreach ($usermacros as $triggerid => &$usermacros_data) {
             if (array_key_exists($triggerid, $db_triggers)) {
                 $usermacros_data['hostids'] = zbx_objectValues($db_triggers[$triggerid]['hosts'], 'hostid');
             }
         }
         unset($usermacros_data);
         // Get user macros values.
         foreach ($this->getUserMacros($usermacros) as $triggerid => $usermacros_data) {
             $macro_values[$triggerid] = array_key_exists($triggerid, $macro_values) ? array_merge($macro_values[$triggerid], $usermacros_data['macros']) : $usermacros_data['macros'];
         }
     }
     $types = $this->transformToPositionTypes($types);
     // Replace macros to value.
     foreach ($triggers as $triggerid => &$trigger) {
         $matched_macros = $this->getMacroPositions($trigger['expression'], $types);
         foreach (array_reverse($matched_macros, true) as $pos => $macro) {
             $trigger['expression'] = substr_replace($trigger['expression'], $macro_values[$triggerid][$macro], $pos, strlen($macro));
         }
     }
     unset($trigger);
     return $triggers;
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:44,代码来源:CMacrosResolver.php

示例15: getLastEvents

function getLastEvents($options)
{
    if (!isset($options['limit'])) {
        $options['limit'] = 15;
    }
    $triggerOptions = array('filter' => array(), 'skipDependent' => 1, 'selectHosts' => array('hostid', 'host'), 'output' => API_OUTPUT_EXTEND, 'sortfield' => 'lastchange', 'sortorder' => ZBX_SORT_DOWN, 'limit' => $options['triggerLimit']);
    $eventOptions = array('source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'output' => API_OUTPUT_EXTEND, 'sortfield' => array('clock', 'eventid'), 'sortorder' => ZBX_SORT_DOWN);
    if (isset($options['eventLimit'])) {
        $eventOptions['limit'] = $options['eventLimit'];
    }
    if (isset($options['nodeids'])) {
        $triggerOptions['nodeids'] = $options['nodeids'];
    }
    if (isset($options['priority'])) {
        $triggerOptions['filter']['priority'] = $options['priority'];
    }
    if (isset($options['monitored'])) {
        $triggerOptions['monitored'] = $options['monitored'];
    }
    if (isset($options['lastChangeSince'])) {
        $triggerOptions['lastChangeSince'] = $options['lastChangeSince'];
        $eventOptions['time_from'] = $options['lastChangeSince'];
    }
    if (isset($options['value'])) {
        $triggerOptions['filter']['value'] = $options['value'];
        $eventOptions['value'] = $options['value'];
    }
    // triggers
    $triggers = API::Trigger()->get($triggerOptions);
    $triggers = zbx_toHash($triggers, 'triggerid');
    // events
    $eventOptions['objectids'] = zbx_objectValues($triggers, 'triggerid');
    $events = API::Event()->get($eventOptions);
    $sortClock = array();
    $sortEvent = array();
    foreach ($events as $enum => $event) {
        if (!isset($triggers[$event['objectid']])) {
            continue;
        }
        $events[$enum]['trigger'] = $triggers[$event['objectid']];
        $events[$enum]['host'] = reset($events[$enum]['trigger']['hosts']);
        $sortClock[$enum] = $event['clock'];
        $sortEvent[$enum] = $event['eventid'];
        //expanding description for the state where event was
        $merged_event = array_merge($event, $triggers[$event['objectid']]);
        $events[$enum]['trigger']['description'] = CMacrosResolverHelper::resolveEventDescription($merged_event);
    }
    array_multisort($sortClock, SORT_DESC, $sortEvent, SORT_DESC, $events);
    return $events;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:50,代码来源:events.inc.php


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