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


PHP CMacrosResolverHelper::resolveEventDescription方法代码示例

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


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

示例1: make_latest_issues


//.........这里部分代码省略.........
    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');
        }
        $hostDiv = new CDiv(array($hostName, $maintenanceIcon), 'maintenance-abs-cont');
        // unknown triggers
        $unknown = SPACE;
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = new CDiv(SPACE, 'status_icon iconunknown');
            $unknown->setHint($trigger['error'], '', 'on');
        }
        // trigger has events
        if ($trigger['lastEvent']) {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns'])));
            // ack
            $ack = getEventAckState($trigger['lastEvent'], empty($filter['backUrl']) ? true : $filter['backUrl'], true, $ackParams);
        } else {
            // description
            $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['lastchange'], 'ns' => '999999999')));
            // ack
            $ack = new CSpan(_('No events'), 'unknown');
        }
        // description
        if (!zbx_empty($trigger['url'])) {
            $description = new CLink($description, resolveTriggerUrl($trigger), null, null, true);
        } else {
            $description = new CSpan($description, 'pointer');
        }
        $description = new CCol($description, getSeverityStyle($trigger['priority']));
        if ($trigger['lastEvent']) {
            $description->setHint(make_popup_eventlist($trigger['triggerid'], $trigger['lastEvent']['eventid']), '', '', false);
        }
        // clock
        $clock = new CLink(zbx_date2str(_('d M Y H:i:s'), $trigger['lastchange']), 'events.php?triggerid=' . $trigger['triggerid'] . '&source=0&show_unknown=1&nav_time=' . $trigger['lastchange']);
        // actions
        $actionHint = $trigger['lastEvent'] && isset($actions[$trigger['lastEvent']['eventid']]) ? $actions[$trigger['lastEvent']['eventid']] : SPACE;
        $table->addRow(array(get_node_name_by_elid($trigger['triggerid']), $hostDiv, $description, $clock, zbx_date2age($trigger['lastchange']), $unknown, $ack, $actionHint));
    }
    // initialize blinking
    zbx_add_post_js('jqBlink.blink();');
    $script = new CJSScript(get_js("jQuery('#hat_lastiss_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    $infoDiv = new CDiv(_n('%1$d of %2$d issue is shown', '%1$d of %2$d issues are shown', count($triggers), $triggersTotalCount));
    $infoDiv->addStyle('text-align: right; padding-right: 3px;');
    return new CDiv(array($table, $infoDiv, $script));
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:101,代码来源:blocks.inc.php

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

示例3: unset

 }
 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);
 }
 // actions
 $actions = makeEventsActions(zbx_objectValues($events, 'eventid'));
 // events
 foreach ($events as $event) {
     $trigger = $triggers[$event['objectid']];
     $host = reset($trigger['hosts']);
     $host = $hosts[$host['hostid']];
     $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, ['clock' => $event['clock'], 'ns' => $event['ns']]));
     // duration
     $event['duration'] = ($nextEvent = get_next_event($event, $events)) ? zbx_date2age($event['clock'], $nextEvent['clock']) : zbx_date2age($event['clock']);
     // action
     $action = isset($actions[$event['eventid']]) ? $actions[$event['eventid']] : '';
     if ($csvExport) {
         $csvRows[] = [zbx_date2str(DATE_TIME_FORMAT_SECONDS, $event['clock']), $pageFilter->hostid == 0 ? $host['name'] : null, $description, trigger_value2str($event['value']), getSeverityName($trigger['priority'], $config), $event['duration'], $config['event_ack_enable'] ? $event['acknowledges'] ? _('Yes') : _('No') : null, strip_tags((string) $action)];
     } else {
         $triggerDescription = (new CSpan($description))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getTrigger($trigger, null, $event['clock']));
         // add colors and blinking to span depending on configuration and trigger parameters
         $statusSpan = new CSpan(trigger_value2str($event['value']));
         addTriggerValueStyle($statusSpan, $event['value'], $event['clock'], $event['acknowledged']);
         // host JS menu link
         $hostName = null;
         if ($pageFilter->hostid == 0) {
             $hostName = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$host['hostid']]));
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:events.php

示例4: makeTriggersPopup

/**
 * Generate table for dashboard triggers popup.
 *
 * @see make_system_status
 *
 * @param array $triggers
 * @param string $backurl
 * @param array $actions
 * @param array $config
 *
 * @return CTableInfo
 */
function makeTriggersPopup(array $triggers, $backurl, array $actions, array $config)
{
    $popupTable = (new CTableInfo())->setHeader([_('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')]);
    CArrayHelper::sort($triggers, [['field' => 'lastchange', 'order' => ZBX_SORT_DOWN]]);
    foreach ($triggers as $trigger) {
        $description = CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, array('clock' => $trigger['event']['clock'], 'ns' => $trigger['event']['ns'])));
        // unknown triggers
        $unknown = '';
        if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
            $unknown = makeUnknownIcon($trigger['error']);
        }
        // ack
        if ($config['event_ack_enable']) {
            $ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], $backurl) : (new CSpan(_('No events')))->addClass(ZBX_STYLE_GREY);
        } else {
            $ack = null;
        }
        // action
        $action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : '';
        $popupTable->addRow([$trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $config, $description), zbx_date2age($trigger['lastchange']), $unknown, $ack, (new CCol($action))->addClass(ZBX_STYLE_NOWRAP)]);
    }
    return $popupTable;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:35,代码来源:blocks.inc.php

示例5: foreach

     foreach ($depTriggers as $depTrigger) {
         $dependenciesTable->addRow(SPACE . '-' . SPACE . $depTrigger['description']);
         $dependency = true;
     }
 }
 if ($dependency) {
     $description[] = (new CSpan())->addClass(ZBX_STYLE_ICON_DEPEND_UP)->addClass(ZBX_STYLE_CURSOR_POINTER)->setHint($dependenciesTable);
 }
 unset($img, $dependenciesTable, $dependency);
 // Trigger has events.
 if ($trigger['lastEvent']) {
     $event = ['clock' => $trigger['lastEvent']['clock'], 'ns' => $trigger['lastEvent']['ns']];
 } else {
     $event = ['clock' => $trigger['lastchange'], 'ns' => '999999999'];
 }
 $description[] = (new CSpan(CMacrosResolverHelper::resolveEventDescription(zbx_array_merge($trigger, $event))))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getTrigger($trigger));
 if ($showDetails) {
     $description[] = BR();
     $description[] = $trigger['expression_html'];
 }
 // host js menu
 $hostList = [];
 foreach ($trigger['hosts'] as $host) {
     // fetch scripts for the host js menu
     $scripts = [];
     if (isset($scriptsByHosts[$host['hostid']])) {
         foreach ($scriptsByHosts[$host['hostid']] as $script) {
             $scripts[] = $script;
         }
     }
     $host_name = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($hosts[$host['hostid']], $scripts));
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:tr_status.php


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