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


PHP CMacrosResolverHelper::resolveTriggerReference方法代码示例

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


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

示例1: getTriggersOverview

/**
 * Creates and returns the trigger overview table for the given hosts.
 *
 * @param array  $hostIds
 * @param string $application	name of application to filter
 * @param string $pageFile		the page where the element is displayed
 * @param int    $viewMode		table display style: either hosts on top, or host on the left side
 * @param string $screenId		the ID of the screen, that contains the trigger overview table
 *
 * @return CTableInfo
 */
function getTriggersOverview($hostIds, $application, $pageFile, $viewMode = null, $screenId = null)
{
    if (is_null($viewMode)) {
        $viewMode = CProfile::get('web.overview.view.style', STYLE_TOP);
    }
    // get application ids
    $applicationIds = null;
    if ($application !== '') {
        $dbApplications = API::Application()->get(array('hostids' => $hostIds, 'filter' => array('name' => $application), 'output' => array('applicationid')));
        $applicationIds = zbx_objectValues($dbApplications, 'applicationid');
        $hostIds = null;
    }
    // get triggers
    $dbTriggers = API::Trigger()->get(array('hostids' => $hostIds, 'applicationids' => $applicationIds, 'monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('hostid', 'name'), 'sortfield' => 'description'));
    // get hosts
    $hostIds = array();
    foreach ($dbTriggers as $trigger) {
        $host = reset($trigger['hosts']);
        $hostIds[$host['hostid']] = $host['hostid'];
    }
    $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $hostIds, 'preservekeys' => true, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null));
    $triggers = array();
    $hostNames = array();
    foreach ($dbTriggers as $trigger) {
        $host = reset($trigger['hosts']);
        $host['name'] = get_node_name_by_elid($host['hostid'], null, NAME_DELIMITER) . $host['name'];
        $trigger['description'] = CMacrosResolverHelper::resolveTriggerReference($trigger['expression'], $trigger['description']);
        $hostNames[$host['hostid']] = $host['name'];
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($triggers[$trigger['description']][$host['name']]) || ($triggers[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE && $trigger['value'] == TRIGGER_VALUE_TRUE || ($triggers[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE || $trigger['value'] == TRIGGER_VALUE_TRUE) && $trigger['priority'] > $triggers[$trigger['description']][$host['name']]['priority'])) {
            $triggers[$trigger['description']][$host['name']] = array('hostid' => $host['hostid'], 'triggerid' => $trigger['triggerid'], 'value' => $trigger['value'], 'lastchange' => $trigger['lastchange'], 'priority' => $trigger['priority'], 'flags' => $trigger['flags'], 'url' => $trigger['url'], 'hosts' => array($host));
        }
    }
    $triggerTable = new CTableInfo(_('No triggers found.'));
    if (empty($hostNames)) {
        return $triggerTable;
    }
    $triggerTable->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        // header
        $header = array(new CCol(_('Triggers'), 'center'));
        foreach ($hostNames as $hostName) {
            $header[] = new CCol($hostName, 'vertical_rotation');
        }
        $triggerTable->setHeader($header, 'vertical_header');
        // data
        foreach ($triggers as $description => $triggerHosts) {
            $columns = array(nbsp($description));
            foreach ($hostNames as $hostName) {
                $columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
            }
            $triggerTable->addRow($columns);
        }
    } else {
        // header
        $header = array(new CCol(_('Host'), 'center'));
        foreach ($triggers as $description => $triggerHosts) {
            $header[] = new CCol($description, 'vertical_rotation');
        }
        $triggerTable->setHeader($header, 'vertical_header');
        // data
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        foreach ($hostNames as $hostId => $hostName) {
            $name = new CSpan($hostName, 'link_menu');
            $name->setMenuPopup(getMenuPopupHost($hosts[$hostId], $scripts[$hostId]));
            $columns = array($name);
            foreach ($triggers as $triggerHosts) {
                $columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
            }
            $triggerTable->addRow($columns);
        }
    }
    return $triggerTable;
}
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:87,代码来源:triggers.inc.php

示例2: getTriggersOverview

/**
 * Creates and returns the trigger overview table for the given hosts.
 *
 * @param array  	$hosts							an array of hosts with host IDs as keys
 * @param string 	$hosts[hostid][name]
 * @param string 	$hosts[hostid][hostid]
 * @param array		$triggers
 * @param string	$triggers[][triggerid]
 * @param string	$triggers[][description]
 * @param string	$triggers[][expression]
 * @param int		$triggers[][value]
 * @param int		$triggers[][lastchange]
 * @param int		$triggers[][flags]
 * @param array		$triggers[][url]
 * @param int		$triggers[][priority]
 * @param array		$triggers[][hosts]
 * @param string	$triggers[][hosts][][hostid]
 * @param string	$triggers[][hosts][][name]
 * @param string 	$pageFile						the page where the element is displayed
 * @param int    	$viewMode						table display style: either hosts on top, or host on the left side
 * @param string 	$screenId						the ID of the screen, that contains the trigger overview table
 *
 * @return CTableInfo
 */
function getTriggersOverview(array $hosts, array $triggers, $pageFile, $viewMode = null, $screenId = null)
{
    $data = array();
    $hostNames = array();
    foreach ($triggers as $trigger) {
        $trigger['description'] = CMacrosResolverHelper::resolveTriggerReference($trigger['expression'], $trigger['description']);
        foreach ($trigger['hosts'] as $host) {
            // triggers may belong to hosts that are filtered out and shouldn't be displayed, skip them
            if (!isset($hosts[$host['hostid']])) {
                continue;
            }
            $hostNames[$host['hostid']] = $host['name'];
            // a little tricky check for attempt to overwrite active trigger (value=1) with
            // inactive or active trigger with lower priority.
            if (!isset($data[$trigger['description']][$host['name']]) || ($data[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE && $trigger['value'] == TRIGGER_VALUE_TRUE || ($data[$trigger['description']][$host['name']]['value'] == TRIGGER_VALUE_FALSE || $trigger['value'] == TRIGGER_VALUE_TRUE) && $trigger['priority'] > $data[$trigger['description']][$host['name']]['priority'])) {
                $data[$trigger['description']][$host['name']] = array('hostid' => $host['hostid'], 'triggerid' => $trigger['triggerid'], 'value' => $trigger['value'], 'lastchange' => $trigger['lastchange'], 'priority' => $trigger['priority'], 'flags' => $trigger['flags'], 'url' => $trigger['url'], 'hosts' => array($host));
            }
        }
    }
    $triggerTable = new CTableInfo(_('No triggers found.'));
    if (empty($hostNames)) {
        return $triggerTable;
    }
    $triggerTable->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        // header
        $header = array(new CCol(_('Triggers'), 'center'));
        foreach ($hostNames as $hostName) {
            $header[] = new CCol($hostName, 'vertical_rotation');
        }
        $triggerTable->setHeader($header, 'vertical_header');
        // data
        foreach ($data as $description => $triggerHosts) {
            $columns = array(nbsp($description));
            foreach ($hostNames as $hostName) {
                $columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
            }
            $triggerTable->addRow($columns);
        }
    } else {
        // header
        $header = array(new CCol(_('Host'), 'center'));
        foreach ($data as $description => $triggerHosts) {
            $header[] = new CCol($description, 'vertical_rotation');
        }
        $triggerTable->setHeader($header, 'vertical_header');
        // data
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        foreach ($hostNames as $hostId => $hostName) {
            $name = new CSpan($hostName, 'link_menu');
            $name->setMenuPopup(CMenuPopupHelper::getHost($hosts[$hostId], $scripts[$hostId]));
            $columns = array($name);
            foreach ($data as $triggerHosts) {
                $columns[] = getTriggerOverviewCells(isset($triggerHosts[$hostName]) ? $triggerHosts[$hostName] : null, $pageFile, $screenId);
            }
            $triggerTable->addRow($columns);
        }
    }
    return $triggerTable;
}
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:85,代码来源:triggers.inc.php


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