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


PHP CTableInfo::makeVerticalRotation方法代码示例

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


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

示例1: CWidget

** 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.
**/
$discoveryWidget = new CWidget('hat_discovery');
// create header form
$discoveryHeaderForm = new CForm('get');
$discoveryHeaderForm->setName('slideHeaderForm');
$discoveryHeaderForm->addVar('fullscreen', $this->data['fullscreen']);
$discoveryWidget->addPageHeader(_('STATUS OF DISCOVERY'), get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen'])));
$discoveryRulesComboBox = $this->data['pageFilter']->getDiscoveryCB();
$discoveryHeaderForm->addItem(array(_('Discovery rule') . SPACE, $discoveryRulesComboBox));
$discoveryWidget->addHeader(_('Discovery rules'), $discoveryHeaderForm);
// create table
$discoveryTable = new CTableInfo(_('No discovered devices found.'));
$discoveryTable->makeVerticalRotation();
$discoveredDeviceCol = make_sorting_header(_('Discovered device'), 'ip', $this->data['sort'], $this->data['sortorder']);
$discoveredDeviceCol->addClass('left');
$header = array($discoveredDeviceCol, new CCol(_('Monitored host'), 'left'), new CCol(array(_('Uptime') . '/', _('Downtime')), 'left'));
foreach ($this->data['services'] as $name => $foo) {
    $header[] = new CCol($name, 'vertical_rotation');
}
$discoveryTable->setHeader($header, 'vertical_header');
foreach ($this->data['drules'] as $drule) {
    $discovery_info = array();
    $dhosts = $drule['dhosts'];
    foreach ($dhosts as $dhost) {
        if ($dhost['status'] == DHOST_STATUS_DISABLED) {
            $hclass = 'disabled';
            $htime = $dhost['lastdown'];
        } else {
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:31,代码来源:monitoring.discovery.php

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

示例3: date

$_REQUEST['media_type'] = $media_type;
$currentYear = date('Y');
// fetch media types
$media_types = array();
$db_media_types = DBselect('SELECT mt.*' . ' FROM media_type mt' . whereDbNode('mt.mediatypeid') . ' ORDER BY mt.description');
while ($media_type_data = DBfetch($db_media_types)) {
    $media_types[$media_type_data['mediatypeid']] = $media_type_data['description'];
}
// if no media types were defined, we have nothing to show
if (zbx_empty($media_types)) {
    show_table_header(_('Notifications'));
    $table = new CTableInfo(_('No notifications found.'));
    $table->show();
} else {
    $table = new CTableInfo();
    $table->makeVerticalRotation();
    // fetch the year of the first alert
    if (($firstAlert = DBfetch(DBselect('SELECT MIN(a.clock) AS clock FROM alerts a'))) && $firstAlert['clock']) {
        $minYear = date('Y', $firstAlert['clock']);
    } else {
        $minYear = date('Y');
    }
    $form = new CForm();
    $form->setMethod('get');
    $form->addItem(SPACE . _('Media type') . SPACE);
    $cmbMedia = new CComboBox('media_type', $media_type, 'submit();');
    $cmbMedia->addItem(0, _('all'));
    foreach ($media_types as $media_type_id => $media_type_description) {
        $cmbMedia->addItem($media_type_id, $media_type_description);
        // we won't need other media types in the future, if only one was selected
        if ($media_type > 0 && $media_type != $media_type_id) {
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:31,代码来源:report4.php

示例4: getItemsDataOverview

/**
 * Retrieve overview table object for items.
 *
 * @param array  $hostIds
 * @param string $application name of application to filter
 * @param int    $viewMode
 *
 * @return CTableInfo
 */
function getItemsDataOverview($hostIds, $application, $viewMode)
{
    $sqlFrom = '';
    $sqlWhere = '';
    if ($application !== '') {
        $sqlFrom = 'applications a,items_applications ia,';
        $sqlWhere = ' AND i.itemid=ia.itemid AND a.applicationid=ia.applicationid AND a.name=' . zbx_dbstr($application);
    }
    $dbItems = DBfetchArray(DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.units,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,' . $sqlFrom . 'items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostIds) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . $sqlWhere));
    $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
    CArrayHelper::sort($dbItems, array(array('field' => 'name_expanded', 'order' => ZBX_SORT_UP), array('field' => 'itemid', 'order' => ZBX_SORT_UP)));
    // fetch latest values
    $history = Manager::History()->getLast(zbx_toHash($dbItems, 'itemid'), 1, ZBX_HISTORY_PERIOD);
    // fetch data for the host JS menu
    $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'monitored_hosts' => true, 'hostids' => $hostIds, 'with_monitored_items' => true, 'preservekeys' => true, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null));
    $items = array();
    foreach ($dbItems as $dbItem) {
        $name = $dbItem['name_expanded'];
        $dbItem['hostname'] = get_node_name_by_elid($dbItem['hostid'], null, NAME_DELIMITER) . $dbItem['hostname'];
        $hostNames[$dbItem['hostid']] = $dbItem['hostname'];
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($items[$name][$dbItem['hostname']]) || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE && $dbItem['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$name][$dbItem['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE || $dbItem['tr_value'] == TRIGGER_VALUE_TRUE) && $dbItem['priority'] > $items[$name][$dbItem['hostname']]['severity'])) {
            $items[$name][$dbItem['hostname']] = array('itemid' => $dbItem['itemid'], 'value_type' => $dbItem['value_type'], 'value' => isset($history[$dbItem['itemid']]) ? $history[$dbItem['itemid']][0]['value'] : null, 'units' => $dbItem['units'], 'name' => $name, 'valuemapid' => $dbItem['valuemapid'], 'severity' => $dbItem['priority'], 'tr_value' => $dbItem['tr_value'], 'triggerid' => $dbItem['triggerid']);
        }
    }
    $table = new CTableInfo(_('No items found.'));
    if (empty($hostNames)) {
        return $table;
    }
    $table->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        $header = array(new CCol(_('Items'), 'center'));
        foreach ($hostNames as $hostName) {
            $header[] = new CCol($hostName, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($items as $descr => $ithosts) {
            $tableRow = array(nbsp($descr));
            foreach ($hostNames as $hostName) {
                $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
            }
            $table->addRow($tableRow);
        }
    } else {
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        $header = array(new CCol(_('Hosts'), 'center'));
        foreach ($items as $descr => $ithosts) {
            $header[] = new CCol($descr, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($hostNames as $hostId => $hostName) {
            $host = $hosts[$hostId];
            $name = new CSpan($host['name'], 'link_menu');
            $name->setMenuPopup(getMenuPopupHost($host, $scripts[$hostId]));
            $tableRow = array(new CCol($name));
            foreach ($items as $ithosts) {
                $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
            }
            $table->addRow($tableRow);
        }
    }
    return $table;
}
开发者ID:hujingguang,项目名称:work,代码行数:74,代码来源:items.inc.php

示例5: get_items_data_overview

/**
 * Retrieve overview table object for items.
 *
 * @param $hostids
 * @param null $view_style
 *
 * @return CTableInfo
 */
function get_items_data_overview($hostids, $view_style)
{
    global $USER_DETAILS;
    $db_items = DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.lastvalue,i.units,i.lastclock,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostids) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', array(ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED)) . ' ORDER BY i.name,i.itemid');
    $options = array('output' => array('name', 'hostid'), 'monitored_hosts' => true, 'hostids' => $hostids, 'with_monitored_items' => true, 'preservekeys' => true);
    if ($view_style == STYLE_LEFT) {
        $options['selectScreens'] = API_OUTPUT_COUNT;
        $options['selectInventory'] = array('hostid');
    }
    // fetch data for the host JS menu
    $hosts = API::Host()->get($options);
    $items = array();
    while ($row = DBfetch($db_items)) {
        $descr = itemName($row);
        $row['hostname'] = get_node_name_by_elid($row['hostid'], null, ': ') . $row['hostname'];
        $hostnames[$row['hostid']] = $row['hostname'];
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!isset($items[$descr][$row['hostname']]) || ($items[$descr][$row['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE && $row['tr_value'] == TRIGGER_VALUE_TRUE || ($items[$descr][$row['hostname']]['tr_value'] == TRIGGER_VALUE_FALSE || $row['tr_value'] == TRIGGER_VALUE_TRUE) && $row['priority'] > $items[$descr][$row['hostname']]['severity'])) {
            $items[$descr][$row['hostname']] = array('itemid' => $row['itemid'], 'value_type' => $row['value_type'], 'lastvalue' => $row['lastvalue'], 'lastclock' => $row['lastclock'], 'units' => $row['units'], 'name' => $row['name'], 'valuemapid' => $row['valuemapid'], 'severity' => $row['priority'], 'tr_value' => $row['tr_value'], 'triggerid' => $row['triggerid']);
        }
    }
    $table = new CTableInfo(_('No items defined.'));
    if (empty($hostnames)) {
        return $table;
    }
    $table->makeVerticalRotation();
    order_result($hostnames);
    if ($view_style == STYLE_TOP) {
        $header = array(new CCol(_('Items'), 'center'));
        foreach ($hostnames as $hostname) {
            $header[] = new CCol($hostname, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($items as $descr => $ithosts) {
            $tableRow = array(nbsp($descr));
            foreach ($hostnames as $hostname) {
                $tableRow = get_item_data_overview_cells($tableRow, $ithosts, $hostname);
            }
            $table->addRow($tableRow);
        }
    } else {
        $hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        foreach ($hostScripts as $hostid => $scripts) {
            $hosts[$hostid]['scripts'] = $scripts;
        }
        $header = array(new CCol(_('Hosts'), 'center'));
        foreach ($items as $descr => $ithosts) {
            $header[] = new CCol($descr, 'vertical_rotation');
        }
        $table->setHeader($header, 'vertical_header');
        foreach ($hostnames as $hostid => $hostname) {
            $host = $hosts[$hostid];
            // host js menu link
            $hostSpan = new CSpan(nbsp($host['name']), 'link_menu menu-host');
            $hostSpan->setAttribute('data-menu', hostMenuData($host, $hostScripts[$host['hostid']]));
            $tableRow = array(new CCol($hostSpan));
            foreach ($items as $ithosts) {
                $tableRow = get_item_data_overview_cells($tableRow, $ithosts, $hostname);
            }
            $table->addRow($tableRow);
        }
    }
    return $table;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:73,代码来源:items.inc.php

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

示例7: get_triggers_overview

/**
 * Creates and returns the trigger overview table for the given hosts.
 *
 * Possible $view_style values:
 * - STYLE_TOP
 * - STYLE_LEFT
 *
 * @param string|array $hostids
 * @param int $view_style	    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 get_triggers_overview($hostids, $view_style = null, $screenId = null)
{
    if (is_null($view_style)) {
        $view_style = CProfile::get('web.overview.view.style', STYLE_TOP);
    }
    // get triggers
    $dbTriggers = API::Trigger()->get(array('hostids' => $hostids, 'monitored' => true, 'skipDependent' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('hostid', 'name'), 'sortfield' => 'description'));
    // get hosts
    $hostids = array();
    foreach ($dbTriggers as $trigger) {
        $hostids[] = $trigger['hosts'][0]['hostid'];
    }
    $options = array('output' => array('name', 'hostid'), 'hostids' => $hostids, 'preservekeys' => true);
    if ($view_style == STYLE_LEFT) {
        $options['selectScreens'] = API_OUTPUT_COUNT;
        $options['selectInventory'] = array('hostid');
    }
    $hosts = API::Host()->get($options);
    $triggers = array();
    $hostNames = array();
    foreach ($dbTriggers as $trigger) {
        $trigger['host'] = $trigger['hosts'][0]['name'];
        $trigger['hostid'] = $trigger['hosts'][0]['hostid'];
        $trigger['host'] = get_node_name_by_elid($trigger['hostid'], null, ': ') . $trigger['host'];
        $trigger['description'] = CTriggerHelper::expandReferenceMacros($trigger);
        $hostNames[$trigger['hostid']] = $trigger['host'];
        // 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']][$trigger['host']]) || ($triggers[$trigger['description']][$trigger['host']]['value'] == TRIGGER_VALUE_FALSE && $trigger['value'] == TRIGGER_VALUE_TRUE || ($triggers[$trigger['description']][$trigger['host']]['value'] == TRIGGER_VALUE_FALSE || $trigger['value'] == TRIGGER_VALUE_TRUE) && $trigger['priority'] > $triggers[$trigger['description']][$trigger['host']]['priority'])) {
            $triggers[$trigger['description']][$trigger['host']] = array('hostid' => $trigger['hostid'], 'triggerid' => $trigger['triggerid'], 'value' => $trigger['value'], 'lastchange' => $trigger['lastchange'], 'priority' => $trigger['priority']);
        }
    }
    $triggerTable = new CTableInfo(_('No triggers defined.'));
    if (empty($hostNames)) {
        return $triggerTable;
    }
    $triggerTable->makeVerticalRotation();
    order_result($hostNames);
    if ($view_style == 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) {
            $tableColumns = array(nbsp($description));
            foreach ($hostNames as $hostid => $hostName) {
                array_push($tableColumns, get_trigger_overview_cells($triggerHosts, $hostName, $screenId));
            }
            $triggerTable->addRow($tableColumns);
        }
    } else {
        $hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        foreach ($hostScripts as $hostid => $scripts) {
            $hosts[$hostid]['scripts'] = $scripts;
        }
        // header
        $header = array(new CCol(_('Host'), 'center'));
        foreach ($triggers as $description => $triggerHosts) {
            $header[] = new CCol($description, 'vertical_rotation');
        }
        $triggerTable->setHeader($header, 'vertical_header');
        // data
        foreach ($hostNames as $hostid => $hostName) {
            $host = $hosts[$hostid];
            // host js link
            $hostSpan = new CSpan(nbsp($hostName), 'link_menu menu-host');
            $hostSpan->setAttribute('data-menu', hostMenuData($host, $hostScripts[$host['hostid']]));
            $tableColumns = array($hostSpan);
            foreach ($triggers as $triggerHosts) {
                array_push($tableColumns, get_trigger_overview_cells($triggerHosts, $hostName, $screenId));
            }
            $triggerTable->addRow($tableColumns);
        }
    }
    return $triggerTable;
}
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:92,代码来源:triggers.inc.php

示例8: getItemsDataOverview

/**
 * Retrieve overview table object for items.
 *
 * @param array  		$hostIds
 * @param array|null	$applicationIds		IDs of applications to filter items by
 * @param int    		$viewMode
 *
 * @return CTableInfo
 */
function getItemsDataOverview($hostIds, array $applicationIds = null, $viewMode)
{
    $sqlFrom = '';
    $sqlWhere = '';
    if ($applicationIds !== null) {
        $sqlFrom = 'items_applications ia,';
        $sqlWhere = ' AND i.itemid=ia.itemid AND ' . dbConditionInt('ia.applicationid', $applicationIds);
    }
    $dbItems = DBfetchArray(DBselect('SELECT DISTINCT h.hostid,h.name AS hostname,i.itemid,i.key_,i.value_type,i.units,' . 'i.name,t.priority,i.valuemapid,t.value AS tr_value,t.triggerid' . ' FROM hosts h,' . $sqlFrom . 'items i' . ' LEFT JOIN functions f ON f.itemid=i.itemid' . ' LEFT JOIN triggers t ON t.triggerid=f.triggerid AND t.status=' . TRIGGER_STATUS_ENABLED . ' WHERE ' . dbConditionInt('h.hostid', $hostIds) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . dbConditionInt('i.flags', [ZBX_FLAG_DISCOVERY_NORMAL, ZBX_FLAG_DISCOVERY_CREATED]) . $sqlWhere));
    $dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
    CArrayHelper::sort($dbItems, [['field' => 'name_expanded', 'order' => ZBX_SORT_UP], ['field' => 'itemid', 'order' => ZBX_SORT_UP]]);
    // fetch latest values
    $history = Manager::History()->getLast(zbx_toHash($dbItems, 'itemid'), 1, ZBX_HISTORY_PERIOD);
    // fetch data for the host JS menu
    $hosts = API::Host()->get(['output' => ['name', 'hostid', 'status'], 'monitored_hosts' => true, 'hostids' => $hostIds, 'with_monitored_items' => true, 'preservekeys' => true, 'selectGraphs' => API_OUTPUT_COUNT, 'selectScreens' => $viewMode == STYLE_LEFT ? API_OUTPUT_COUNT : null]);
    $items = [];
    $item_counter = [];
    $host_items = [];
    foreach ($dbItems as $dbItem) {
        $item_name = $dbItem['name_expanded'];
        $host_name = $dbItem['hostname'];
        $hostNames[$dbItem['hostid']] = $host_name;
        if (!array_key_exists($host_name, $item_counter)) {
            $item_counter[$host_name] = [];
        }
        if (!array_key_exists($item_name, $item_counter[$host_name])) {
            $item_counter[$host_name][$item_name] = 0;
        }
        if (!array_key_exists($item_name, $host_items) || !array_key_exists($host_name, $host_items[$item_name])) {
            $host_items[$item_name][$host_name] = [];
        }
        // a little tricky check for attempt to overwrite active trigger (value=1) with
        // inactive or active trigger with lower priority.
        if (!array_key_exists($dbItem['itemid'], $host_items[$item_name][$host_name]) || ($host_items[$item_name][$host_name][$dbItem['itemid']]['tr_value'] == TRIGGER_VALUE_FALSE && $dbItem['tr_value'] == TRIGGER_VALUE_TRUE || ($host_items[$item_name][$host_name][$dbItem['itemid']]['tr_value'] == TRIGGER_VALUE_FALSE || $dbItem['tr_value'] == TRIGGER_VALUE_TRUE) && $dbItem['priority'] > $host_items[$item_name][$host_name][$dbItem['itemid']]['severity'])) {
            if (array_key_exists($dbItem['itemid'], $host_items[$item_name][$host_name])) {
                $item_place = $host_items[$item_name][$host_name][$dbItem['itemid']]['item_place'];
            } else {
                $item_place = $item_counter[$host_name][$item_name];
                $item_counter[$host_name][$item_name]++;
            }
            $items[$item_name][$item_place][$host_name] = ['itemid' => $dbItem['itemid'], 'value_type' => $dbItem['value_type'], 'value' => isset($history[$dbItem['itemid']]) ? $history[$dbItem['itemid']][0]['value'] : null, 'units' => $dbItem['units'], 'valuemapid' => $dbItem['valuemapid'], 'severity' => $dbItem['priority'], 'tr_value' => $dbItem['tr_value'], 'triggerid' => $dbItem['triggerid'], 'item_place' => $item_place];
            $host_items[$item_name][$host_name][$dbItem['itemid']] = $items[$item_name][$item_place][$host_name];
        }
    }
    $table = new CTableInfo();
    if (empty($hostNames)) {
        return $table;
    }
    $table->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        $header = [_('Items')];
        foreach ($hostNames as $hostName) {
            $header[] = (new CColHeader($hostName))->addClass('vertical_rotation');
        }
        $table->setHeader($header);
        foreach ($items as $item_name => $item_data) {
            foreach ($item_data as $ithosts) {
                $tableRow = [nbsp($item_name)];
                foreach ($hostNames as $hostName) {
                    $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
                }
                $table->addRow($tableRow);
            }
        }
    } else {
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        $header = [_('Hosts')];
        foreach ($items as $item_name => $item_data) {
            foreach ($item_data as $ithosts) {
                $header[] = (new CColHeader($item_name))->addClass('vertical_rotation');
            }
        }
        $table->setHeader($header);
        foreach ($hostNames as $hostId => $hostName) {
            $host = $hosts[$hostId];
            $name = (new CSpan($host['name']))->addClass(ZBX_STYLE_LINK_ACTION)->setMenuPopup(CMenuPopupHelper::getHost($host, $scripts[$hostId]));
            $tableRow = [(new CCol($name))->addClass(ZBX_STYLE_NOWRAP)];
            foreach ($items as $item_data) {
                foreach ($item_data as $ithosts) {
                    $tableRow = getItemDataOverviewCells($tableRow, $ithosts, $hostName);
                }
            }
            $table->addRow($tableRow);
        }
    }
    return $table;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:97,代码来源:items.inc.php

示例9: 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 = [];
    $hostNames = [];
    $trcounter = [];
    $triggers = CMacrosResolverHelper::resolveTriggerNames($triggers, true);
    foreach ($triggers as $trigger) {
        $trigger_name = $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'];
            if (!array_key_exists($host['name'], $trcounter)) {
                $trcounter[$host['name']] = [];
            }
            if (!array_key_exists($trigger_name, $trcounter[$host['name']])) {
                $trcounter[$host['name']][$trigger_name] = 0;
            }
            $data[$trigger_name][$trcounter[$host['name']][$trigger_name]][$host['name']] = ['groupid' => $trigger['groupid'], 'hostid' => $host['hostid'], 'triggerid' => $trigger['triggerid'], 'value' => $trigger['value'], 'lastchange' => $trigger['lastchange'], 'priority' => $trigger['priority'], 'flags' => $trigger['flags'], 'url' => $trigger['url'], 'hosts' => $trigger['hosts'], 'items' => $trigger['items']];
            $trcounter[$host['name']][$trigger_name]++;
        }
    }
    $triggerTable = new CTableInfo();
    if (empty($hostNames)) {
        return $triggerTable;
    }
    $triggerTable->makeVerticalRotation();
    order_result($hostNames);
    if ($viewMode == STYLE_TOP) {
        // header
        $header = [_('Triggers')];
        foreach ($hostNames as $hostName) {
            $header[] = (new CColHeader($hostName))->addClass('vertical_rotation');
        }
        $triggerTable->setHeader($header);
        // data
        foreach ($data as $trigger_name => $trigger_data) {
            foreach ($trigger_data as $trigger_hosts) {
                $columns = [nbsp($trigger_name)];
                foreach ($hostNames as $hostName) {
                    $columns[] = getTriggerOverviewCells(isset($trigger_hosts[$hostName]) ? $trigger_hosts[$hostName] : null, $pageFile, $screenId);
                }
                $triggerTable->addRow($columns);
            }
        }
    } else {
        // header
        $header = [_('Host')];
        foreach ($data as $trigger_name => $trigger_data) {
            foreach ($trigger_data as $trigger_hosts) {
                $header[] = (new CColHeader($trigger_name))->addClass('vertical_rotation');
            }
        }
        $triggerTable->setHeader($header);
        // data
        $scripts = API::Script()->getScriptsByHosts(zbx_objectValues($hosts, 'hostid'));
        foreach ($hostNames as $hostId => $hostName) {
            $name = (new CSpan($hostName))->addClass(ZBX_STYLE_LINK_ACTION);
            $name->setMenuPopup(CMenuPopupHelper::getHost($hosts[$hostId], $scripts[$hostId]));
            $columns = [(new CCol($name))->addClass(ZBX_STYLE_NOWRAP)];
            foreach ($data as $trigger_data) {
                foreach ($trigger_data as $trigger_hosts) {
                    $columns[] = getTriggerOverviewCells(isset($trigger_hosts[$hostName]) ? $trigger_hosts[$hostName] : null, $pageFile, $screenId);
                }
            }
            $triggerTable->addRow($columns);
        }
    }
    return $triggerTable;
}
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:96,代码来源:triggers.inc.php


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