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


PHP CMacrosResolverHelper::resolveTriggerUrls方法代码示例

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


在下文中一共展示了CMacrosResolverHelper::resolveTriggerUrls方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: 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['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 $backurl
 *
 * @return CDiv
 */
function make_latest_issues(array $filter = [], $backurl)
{
    // hide the sort indicator if no sortfield and sortorder are given
    $show_sort_indicator = isset($filter['sortfield']) || isset($filter['sortorder']);
    if (isset($filter['sortfield']) && $filter['sortfield'] !== 'lastchange') {
        $sort_field = [$filter['sortfield'], 'lastchange'];
        $sort_order = [$filter['sortorder'], ZBX_SORT_DOWN];
    } else {
        $sort_field = ['lastchange'];
        $sort_order = [ZBX_SORT_DOWN];
    }
    $options = ['groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'search' => $filter['trigger_name'] !== '' ? ['description' => $filter['trigger_name']] : null, 'filter' => ['priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE]];
    $triggers = API::Trigger()->get(array_merge($options, ['output' => ['triggerid', 'expression', 'description', 'url', 'priority', 'lastchange', 'comments', 'error', 'state'], 'selectHosts' => ['hostid'], 'selectLastEvent' => ['eventid', 'acknowledged', 'objectid', 'clock', 'ns'], 'withLastEventUnacknowledged' => isset($filter['extAck']) && $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'sortfield' => $sort_field, 'sortorder' => $sort_order, 'limit' => isset($filter['limit']) ? $filter['limit'] : DEFAULT_LATEST_ISSUES_CNT, 'preservekeys' => true, 'expandComment' => true]));
    $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers);
    // don't use withLastEventUnacknowledged and skipDependent because of performance issues
    $triggers_total_count = API::Trigger()->get(array_merge($options, ['countOutput' => true]));
    // get acknowledges
    $hostids = [];
    $eventids = [];
    foreach ($triggers as $trigger) {
        foreach ($trigger['hosts'] as $host) {
            $hostids[$host['hostid']] = true;
        }
        if ($trigger['lastEvent']) {
            $eventids[] = $trigger['lastEvent']['eventid'];
        }
    }
    $config = select_config();
    if ($config['event_ack_enable'] && $eventids) {
        $event_acknowledges = API::Event()->get(['output' => ['eventid'], 'eventids' => $eventids, 'select_acknowledges' => API_OUTPUT_EXTEND, 'preservekeys' => true]);
    }
    // actions
    $actions = makeEventsActions($eventids);
    // indicator of sort field
    if ($show_sort_indicator) {
        $sort_div = (new CDiv())->addClass($filter['sortorder'] === ZBX_SORT_DOWN ? ZBX_STYLE_ARROW_DOWN : ZBX_STYLE_ARROW_UP);
    }
    $table = (new CTableInfo())->setHeader([$show_sort_indicator && $filter['sortfield'] === 'hostname' ? [_('Host'), $sort_div] : _('Host'), $show_sort_indicator && $filter['sortfield'] === 'priority' ? [_('Issue'), $sort_div] : _('Issue'), $show_sort_indicator && $filter['sortfield'] === 'lastchange' ? [_('Last change'), $sort_div] : _('Last change'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')]);
    $hostids = array_keys($hostids);
    $scripts = API::Script()->getScriptsByHosts($hostids);
    // get hosts
    $hosts = API::Host()->get(['hostids' => $hostids, 'output' => ['hostid', 'name', 'status', 'maintenance_status', 'maintenance_type', 'maintenanceid'], 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true]);
    $maintenanceids = [];
    foreach ($hosts as $host) {
        if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
            $maintenanceids[$host['maintenanceid']] = true;
        }
    }
    if ($maintenanceids) {
        $maintenances = API::Maintenance()->get(['maintenanceids' => array_keys($maintenanceids), 'output' => ['name', 'description'], 'preservekeys' => true]);
    }
    // triggers
    foreach ($triggers as $trigger) {
        $host_list = [];
        foreach ($trigger['hosts'] as $trigger_host) {
            $host = $hosts[$trigger_host['hostid']];
            $host_name = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
            if ($host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
                $maintenance_icon = (new CSpan())->addClass(ZBX_STYLE_ICON_MAINT)->addClass(ZBX_STYLE_CURSOR_POINTER);
                if (array_key_exists($host['maintenanceid'], $maintenances)) {
                    $maintenance = $maintenances[$host['maintenanceid']];
                    $hint = $maintenance['name'] . ' [' . ($host['maintenance_type'] ? _('Maintenance without data collection') : _('Maintenance with data collection')) . ']';
                    if ($maintenance['description']) {
                        $hint .= "\n" . $maintenance['description'];
                    }
                    $maintenance_icon->setHint($hint);
                }
                $host_name = (new CSpan([$host_name, $maintenance_icon]))->addClass(ZBX_STYLE_REL_CONTAINER);
            }
            $host_list[] = $host_name;
            $host_list[] = ', ';
        }
        array_pop($host_list);
        // unknown triggers
        $unknown = '';
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = makeUnknownIcon($trigger['error']);
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, ['clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns']]));
        } else {
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:blocks.inc.php

示例3: end

      */
     $lastEvent = end($allEventsSlice);
     $eventOptions['eventid_till'] = $lastEvent['eventid'] - 1;
 }
 /*
  * At this point it is possible that more than $config['search_limit'] events are selected,
  * therefore at most only first $config['search_limit'] + 1 events will be used for pagination.
  */
 $events = array_slice($events, 0, $config['search_limit'] + 1);
 // get paging
 $url = (new CUrl('events.php'))->setArgument('fullscreen', getRequest('fullscreen'))->setArgument('groupid', $pageFilter->groupid)->setArgument('hostid', $pageFilter->hostid);
 $paging = getPagingLine($events, ZBX_SORT_DOWN, $url);
 // query event with extend data
 $events = API::Event()->get(['source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'eventids' => zbx_objectValues($events, 'eventid'), 'output' => API_OUTPUT_EXTEND, 'select_acknowledges' => API_OUTPUT_COUNT, 'sortfield' => ['clock', 'eventid'], 'sortorder' => ZBX_SORT_DOWN, 'nopermissions' => true]);
 $triggers = API::Trigger()->get(['output' => ['triggerid', 'description', 'expression', 'priority', 'flags', 'url'], 'selectHosts' => ['hostid', 'name', 'status'], 'selectItems' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'triggerids' => zbx_objectValues($events, 'objectid'), 'preservekeys' => true]);
 $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers);
 // fetch hosts
 $hosts = [];
 foreach ($triggers as &$trigger) {
     $hosts[] = reset($trigger['hosts']);
     // Add already filtered read and read-write 'groupid' and 'hostid' to pass to menu pop-up "Events" link.
     $trigger['groupid'] = $pageFilter->groupid;
     $trigger['hostid'] = $pageFilter->hostid;
 }
 unset($trigger);
 $hostids = zbx_objectValues($hosts, 'hostid');
 $hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'hostids' => $hostids, 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'preservekeys' => true]);
 // fetch scripts for the host JS menu
 if (!$csvExport && $pageFilter->hostid == 0) {
     $scripts = API::Script()->getScriptsByHosts($hostids);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:events.php

示例4: EXISTS

}
if (CWebUser::getType() == USER_TYPE_SUPER_ADMIN && ($data['filter']['groupids'] || $data['filter']['hostids'])) {
    $sql .= ' AND EXISTS (' . 'SELECT NULL' . ' FROM functions f,items i,hosts_groups hgg' . ' WHERE t.triggerid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ($data['filter']['hostids'] ? $inHosts : '') . ($data['filter']['groupids'] ? $inGroups : '') . ')';
} elseif (CWebUser::getType() != USER_TYPE_SUPER_ADMIN) {
    // add permission filter
    $userId = CWebUser::$data['userid'];
    $userGroups = getUserGroupsByUserId($userId);
    $sql .= ' AND EXISTS (' . 'SELECT NULL' . ' FROM functions f,items i,hosts_groups hgg' . ' JOIN rights r' . ' ON r.id=hgg.groupid' . ' AND ' . dbConditionInt('r.groupid', $userGroups) . ' WHERE t.triggerid=f.triggerid' . ' AND f.itemid=i.itemid' . ' AND i.hostid=hgg.hostid' . ($data['filter']['hostids'] ? $inHosts : '') . ($data['filter']['groupids'] ? $inGroups : '') . ' GROUP BY f.triggerid' . ' HAVING MIN(r.permission)>' . PERM_DENY . ')';
}
$sql .= ' AND ' . dbConditionInt('t.flags', [ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED]) . ' GROUP BY e.objectid' . ' ORDER BY cnt_event DESC';
$result = DBselect($sql, 100);
while ($row = DBfetch($result)) {
    $triggersEventCount[$row['objectid']] = $row['cnt_event'];
}
$data['triggers'] = API::Trigger()->get(['output' => ['triggerid', 'description', 'expression', 'priority', 'flags', 'url', 'lastchange'], 'selectItems' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'selectHosts' => ['hostid', 'status', 'name'], 'triggerids' => array_keys($triggersEventCount), 'expandDescription' => true, 'preservekeys' => true]);
$data['triggers'] = CMacrosResolverHelper::resolveTriggerUrls($data['triggers']);
$hostIds = [];
foreach ($data['triggers'] as $triggerId => $trigger) {
    $hostId = $trigger['hosts'][0]['hostid'];
    $hostIds[$hostId] = $hostId;
    $data['triggers'][$triggerId]['cnt_event'] = $triggersEventCount[$triggerId];
}
CArrayHelper::sort($data['triggers'], [['field' => 'cnt_event', 'order' => ZBX_SORT_DOWN], 'host', 'description', 'priority']);
$data['hosts'] = API::Host()->get(['output' => ['hostid', 'status'], 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'hostids' => $hostIds, 'preservekeys' => true]);
$data['scripts'] = API::Script()->getScriptsByHosts($hostIds);
$monitored_hostids = [];
foreach ($data['triggers'] as $trigger) {
    foreach ($trigger['hosts'] as $host) {
        if ($host['status'] == HOST_STATUS_MONITORED) {
            $monitored_hostids[$host['hostid']] = true;
        }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:toptriggers.php


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