本文整理汇总了PHP中CMacrosResolverHelper类 的典型用法代码示例。如果您正苦于以下问题:PHP CMacrosResolverHelper类的具体用法?PHP CMacrosResolverHelper怎么用?PHP CMacrosResolverHelper使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了CMacrosResolverHelper类 的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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()
{
// if screen is defined in template, then 'real_resourceid' is defined and should be used
if (!empty($this->screenitem['real_resourceid'])) {
$this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
}
if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
$newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
$this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
}
if ($this->screenitem['resourceid'] == 0) {
$table = (new CTableInfo())->setHeader([_('Timestamp'), _('Item')]);
return $this->getOutput($table);
}
$items = CMacrosResolverHelper::resolveItemNames([get_item_by_itemid($this->screenitem['resourceid'])]);
$item = reset($items);
switch ($item['value_type']) {
case ITEM_VALUE_TYPE_TEXT:
case ITEM_VALUE_TYPE_LOG:
$orderField = 'id';
break;
case ITEM_VALUE_TYPE_FLOAT:
case ITEM_VALUE_TYPE_UINT64:
default:
$orderField = ['itemid', 'clock'];
}
$host = get_host_by_itemid($this->screenitem['resourceid']);
$table = (new CTableInfo())->setHeader([_('Timestamp'), _('Value')]);
$stime = zbxDateToTime($this->timeline['stime']);
$histories = API::History()->get(['history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']]);
foreach ($histories as $history) {
switch ($item['value_type']) {
case ITEM_VALUE_TYPE_FLOAT:
sscanf($history['value'], '%f', $value);
break;
case ITEM_VALUE_TYPE_TEXT:
case ITEM_VALUE_TYPE_STR:
case ITEM_VALUE_TYPE_LOG:
$value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
break;
default:
$value = $history['value'];
break;
}
if ($item['valuemapid'] > 0) {
$value = applyValueMap($value, $item['valuemapid']);
}
if ($this->screenitem['style'] == 0) {
$value = new CPre($value);
}
$table->addRow([zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), $value]);
}
$footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT);
return $this->getOutput((new CUiWidget(uniqid(), [$table, $footer]))->setHeader($host['name'] . NAME_DELIMITER . $item['name_expanded']));
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:60, 代码来源:CScreenPlainText.php
示例3: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
// if screen is defined in template, then 'real_resourceid' is defined and should be used
if (!empty($this->screenitem['real_resourceid'])) {
$this->screenitem['resourceid'] = $this->screenitem['real_resourceid'];
}
if ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && !empty($this->hostid)) {
$newitemid = get_same_item_for_host($this->screenitem['resourceid'], $this->hostid);
$this->screenitem['resourceid'] = !empty($newitemid) ? $newitemid : 0;
}
if ($this->screenitem['resourceid'] == 0) {
$table = new CTableInfo(_('No values found.'));
$table->setHeader(array(_('Timestamp'), _('Item')));
return $this->getOutput($table);
}
$items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($this->screenitem['resourceid'])));
$item = reset($items);
switch ($item['value_type']) {
case ITEM_VALUE_TYPE_TEXT:
case ITEM_VALUE_TYPE_LOG:
$orderField = 'id';
break;
case ITEM_VALUE_TYPE_FLOAT:
case ITEM_VALUE_TYPE_UINT64:
default:
$orderField = array('itemid', 'clock');
}
$host = get_host_by_itemid($this->screenitem['resourceid']);
$table = new CTableInfo(_('No values found.'));
$table->setHeader(array(_('Timestamp'), $host['name'] . NAME_DELIMITER . $item['name_expanded']));
$stime = zbxDateToTime($this->timeline['stime']);
$histories = API::History()->get(array('history' => $item['value_type'], 'itemids' => $this->screenitem['resourceid'], 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN, 'sortfield' => $orderField, 'limit' => $this->screenitem['elements'], 'time_from' => $stime, 'time_till' => $stime + $this->timeline['period']));
foreach ($histories as $history) {
switch ($item['value_type']) {
case ITEM_VALUE_TYPE_FLOAT:
sscanf($history['value'], '%f', $value);
break;
case ITEM_VALUE_TYPE_TEXT:
case ITEM_VALUE_TYPE_STR:
case ITEM_VALUE_TYPE_LOG:
$value = $this->screenitem['style'] ? new CJsScript($history['value']) : $history['value'];
break;
default:
$value = $history['value'];
break;
}
if ($item['valuemapid'] > 0) {
$value = applyValueMap($value, $item['valuemapid']);
}
$class = $this->screenitem['style'] ? null : 'pre';
$table->addRow(array(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $history['clock']), new CCol($value, $class)));
}
return $this->getOutput($table);
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:59, 代码来源:CScreenPlainText.php
示例4: addItem
public function addItem($itemid, $calc_fnc = CALC_FNC_AVG, $color = null, $type = null)
{
$items = CMacrosResolverHelper::resolveItemNames(array(get_item_by_itemid($itemid)));
$this->items[$this->num] = reset($items);
$host = get_host_by_hostid($this->items[$this->num]['hostid']);
$this->items[$this->num]['host'] = $host['host'];
$this->items[$this->num]['hostname'] = $host['name'];
$this->items[$this->num]['color'] = is_null($color) ? 'Dark Green' : $color;
$this->items[$this->num]['calc_fnc'] = is_null($calc_fnc) ? CALC_FNC_AVG : $calc_fnc;
$this->items[$this->num]['calc_type'] = is_null($type) ? GRAPH_ITEM_SIMPLE : $type;
$this->num++;
}
开发者ID:itnihao, 项目名称:zatree-2.2, 代码行数:12, 代码来源:CPieGraphDraw.php
示例5: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
// prevent from resolving macros in configuration page
if ($this->mode != SCREEN_MODE_PREVIEW && $this->mode != SCREEN_MODE_SLIDESHOW) {
return $this->getOutput(new CIFrame($this->screenitem['url'], $this->screenitem['width'], $this->screenitem['height'], 'auto'));
} elseif ($this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM && $this->hostid == 0) {
return $this->getOutput((new CTableInfo())->setNoDataMessage(_('No host selected.')));
}
$resolveHostMacros = $this->screenitem['dynamic'] == SCREEN_DYNAMIC_ITEM || $this->isTemplatedScreen;
$url = CMacrosResolverHelper::resolveScreenElementURL(['config' => $resolveHostMacros ? 'screenElementURL' : 'screenElementURLUser', 'url' => $this->screenitem['url'], 'hostid' => $resolveHostMacros ? $this->hostid : 0]);
$this->screenitem['url'] = $url ? $url : $this->screenitem['url'];
return $this->getOutput(new CIFrame($this->screenitem['url'], $this->screenitem['width'], $this->screenitem['height'], 'auto'));
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:18, 代码来源:CScreenUrl.php
示例6: getFavouriteGraphs
/**
* Prepare data for favourite graphs menu popup.
*
* @return array
*/
public static function getFavouriteGraphs()
{
$graphs = $simpeGraphs = array();
$favourites = CFavorite::get('web.favorite.graphids');
if ($favourites) {
$graphIds = $itemIds = $dbGraphs = $dbItems = array();
foreach ($favourites as $favourite) {
if ($favourite['source'] === 'itemid') {
$itemIds[$favourite['value']] = $favourite['value'];
} else {
$graphIds[$favourite['value']] = $favourite['value'];
}
}
if ($graphIds) {
$dbGraphs = API::Graph()->get(array('output' => array('graphid', 'name'), 'selectHosts' => array('hostid', 'host'), 'expandName' => true, 'graphids' => $graphIds, 'preservekeys' => true));
}
if ($itemIds) {
$dbItems = API::Item()->get(array('output' => array('itemid', 'hostid', 'name', 'key_'), 'selectHosts' => array('hostid', 'host'), 'itemids' => $itemIds, 'webitems' => true, 'preservekeys' => true));
$dbItems = CMacrosResolverHelper::resolveItemNames($dbItems);
}
foreach ($favourites as $favourite) {
$sourceId = $favourite['value'];
if ($favourite['source'] === 'itemid') {
if (isset($dbItems[$sourceId])) {
$dbItem = $dbItems[$sourceId];
$dbHost = reset($dbItem['hosts']);
$simpeGraphs[] = array('id' => $sourceId, 'label' => $dbHost['host'] . NAME_DELIMITER . $dbItem['name_expanded']);
}
} else {
if (isset($dbGraphs[$sourceId])) {
$dbGraph = $dbGraphs[$sourceId];
$dbHost = reset($dbGraph['hosts']);
$graphs[] = array('id' => $sourceId, 'label' => $dbHost['host'] . NAME_DELIMITER . $dbGraph['name']);
}
}
}
}
return array('type' => 'favouriteGraphs', 'graphs' => $graphs, 'simpleGraphs' => $simpeGraphs);
}
开发者ID:TonywalkerCN, 项目名称:Zabbix, 代码行数:44, 代码来源:CMenuPopupHelper.php
示例7: getCreatedItemIds
/**
* Retrieves items created for item prototype given as resource for this screen item
* and returns array of the item IDs, ordered by item name.
*
* @return array
*/
protected function getCreatedItemIds()
{
if (!$this->createdItemIds) {
$itemPrototype = $this->getItemPrototype();
if ($itemPrototype) {
// get all created (discovered) items for current host
$allCreatedItems = API::Item()->get(array('output' => array('itemid', 'name', 'key_', 'hostid'), 'hostids' => array($itemPrototype['discoveryRule']['hostid']), 'selectItemDiscovery' => array('itemid', 'parent_itemid'), 'filter' => array('flags' => ZBX_FLAG_DISCOVERY_CREATED)));
// collect those items where parent item is item prototype selected for this screen item as resource
$createdItems = array();
foreach ($allCreatedItems as $item) {
if ($item['itemDiscovery']['parent_itemid'] == $itemPrototype['itemid']) {
$createdItems[] = $item;
}
}
$createdItems = CMacrosResolverHelper::resolveItemNames($createdItems);
foreach ($createdItems as $item) {
$this->createdItemIds[$item['itemid']] = $item['name_expanded'];
}
natsort($this->createdItemIds);
$this->createdItemIds = array_keys($this->createdItemIds);
}
}
return $this->createdItemIds;
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:30, 代码来源:CScreenLldSimpleGraph.php
示例8: 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
示例9: drawMapLabels
function drawMapLabels(&$im, $map, $mapInfo, $resolveMacros = true)
{
global $colors;
if ($map['label_type'] == MAP_LABEL_TYPE_NOTHING && $map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
return;
}
$selements = $map['selements'];
$allStrings = '';
$labelLines = array();
$statusLines = array();
foreach ($selements as $sid => $selement) {
if (isset($selement['elementsubtype']) && $selement['elementsubtype'] == SYSMAP_ELEMENT_SUBTYPE_HOST_GROUP_ELEMENTS) {
unset($selements[$sid]);
}
}
// set label type and custom label text for all selements
foreach ($selements as $selementId => $selement) {
$selements[$selementId]['label_type'] = $map['label_type'];
if ($map['label_format'] == SYSMAP_LABEL_ADVANCED_OFF) {
continue;
}
switch ($selement['elementtype']) {
case SYSMAP_ELEMENT_TYPE_HOST_GROUP:
$selements[$selementId]['label_type'] = $map['label_type_hostgroup'];
if ($map['label_type_hostgroup'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_hostgroup'];
}
break;
case SYSMAP_ELEMENT_TYPE_HOST:
$selements[$selementId]['label_type'] = $map['label_type_host'];
if ($map['label_type_host'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_host'];
}
break;
case SYSMAP_ELEMENT_TYPE_TRIGGER:
$selements[$selementId]['label_type'] = $map['label_type_trigger'];
if ($map['label_type_trigger'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_trigger'];
}
break;
case SYSMAP_ELEMENT_TYPE_MAP:
$selements[$selementId]['label_type'] = $map['label_type_map'];
if ($map['label_type_map'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_map'];
}
break;
case SYSMAP_ELEMENT_TYPE_IMAGE:
$selements[$selementId]['label_type'] = $map['label_type_image'];
if ($map['label_type_image'] == MAP_LABEL_TYPE_CUSTOM) {
$selements[$selementId]['label'] = $map['label_string_image'];
}
break;
}
}
foreach ($selements as $selementId => $selement) {
if (!isset($labelLines[$selementId])) {
$labelLines[$selementId] = array();
}
if (!isset($statusLines[$selementId])) {
$statusLines[$selementId] = array();
}
$msg = $resolveMacros ? CMacrosResolverHelper::resolveMapLabelMacrosAll($selement) : $selement['label'];
$allStrings .= $msg;
$msgs = explode("\n", $msg);
foreach ($msgs as $msg) {
$labelLines[$selementId][] = array('msg' => $msg);
}
$elementInfo = $mapInfo[$selementId];
foreach (array('problem', 'unack', 'maintenance', 'ok', 'status') as $caption) {
if (!isset($elementInfo['info'][$caption]) || zbx_empty($elementInfo['info'][$caption]['msg'])) {
continue;
}
$statusLines[$selementId][] = array('msg' => $elementInfo['info'][$caption]['msg'], 'color' => $elementInfo['info'][$caption]['color']);
$allStrings .= $elementInfo['info'][$caption]['msg'];
}
}
$allLabelsSize = imageTextSize(8, 0, str_replace("\r", '', str_replace("\n", '', $allStrings)));
$labelFontHeight = $allLabelsSize['height'];
$labelFontBaseline = $allLabelsSize['baseline'];
$elementsHostIds = array();
foreach ($selements as $selement) {
if ($selement['label_type'] != MAP_LABEL_TYPE_IP) {
continue;
}
if ($selement['elementtype'] == SYSMAP_ELEMENT_TYPE_HOST) {
$elementsHostIds[] = $selement['elementid'];
}
}
if (!empty($elementsHostIds)) {
$mapHosts = API::Host()->get(array('hostids' => $elementsHostIds, 'output' => array('hostid'), 'selectInterfaces' => API_OUTPUT_EXTEND));
$mapHosts = zbx_toHash($mapHosts, 'hostid');
}
// draw
foreach ($selements as $selementId => $selement) {
if (empty($selement) || $selement['label_type'] == MAP_LABEL_TYPE_NOTHING) {
continue;
}
$elementInfo = $mapInfo[$selementId];
$hl_color = null;
$st_color = null;
//.........这里部分代码省略.........
开发者ID:TonywalkerCN, 项目名称:Zabbix, 代码行数:101, 代码来源:maps.inc.php
示例10: unset
}
}
} else {
if (preg_match('/^([a-z]+)\\[([=><]{1,2})\\]$/i', $exprType, $matches)) {
$function = $matches[1];
$operator = $matches[2];
if (!isset($functions[$exprType])) {
unset($function);
}
}
// fetch item
$item = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'selectHosts' => ['host', 'name'], 'itemids' => $itemId, 'webitems' => true, 'filter' => ['flags' => null]]);
$item = reset($item);
}
if ($itemId) {
$items = CMacrosResolverHelper::resolveItemNames([$item]);
$item = $items[0];
$itemValueType = $item['value_type'];
$itemKey = $item['key_'];
$itemHostData = reset($item['hosts']);
$description = $itemHostData['name'] . NAME_DELIMITER . $item['name_expanded'];
} else {
$itemKey = '';
$description = '';
$itemValueType = null;
}
if (is_null($paramType) && isset($functions[$exprType]['params']['M'])) {
$paramType = is_array($functions[$exprType]['params']['M']) ? reset($functions[$exprType]['params']['M']) : $functions[$exprType]['params']['M'];
} elseif (is_null($paramType)) {
$paramType = PARAM_TYPE_TIME;
}
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:31, 代码来源:popup_trexpr.php
示例11: CView
// render view
$itemView = new CView('configuration.item.prototype.edit', $data);
$itemView->render();
$itemView->show();
} else {
$sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name'));
$sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
$config = select_config();
$data = ['form' => getRequest('form'), 'parent_discoveryid' => getRequest('parent_discoveryid'), 'hostid' => $discoveryRule['hostid'], 'sort' => $sortField, 'sortorder' => $sortOrder];
$data['items'] = API::ItemPrototype()->get(['discoveryids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectApplications' => API_OUTPUT_EXTEND, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1]);
foreach ($data['items'] as &$item) {
if ($item['value_type'] == ITEM_VALUE_TYPE_STR || $item['value_type'] == ITEM_VALUE_TYPE_LOG || $item['value_type'] == ITEM_VALUE_TYPE_TEXT) {
$item['trends'] = '';
}
if ($item['type'] == ITEM_TYPE_TRAPPER || $item['type'] == ITEM_TYPE_SNMPTRAP) {
$item['delay'] = '';
}
}
unset($item);
$data['items'] = CMacrosResolverHelper::resolveItemNames($data['items']);
order_result($data['items'], $sortField, $sortOrder);
$url = (new CUrl('disc_prototypes.php'))->setArgument('parent_discoveryid', $data['parent_discoveryid']);
$data['paging'] = getPagingLine($data['items'], $sortOrder, $url);
// render view
$itemView = new CView('configuration.item.prototype.list', $data);
$itemView->render();
$itemView->show();
}
require_once dirname(__FILE__) . '/include/page_footer.php';
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:31, 代码来源:disc_prototypes.php
示例12: getHostInventories
* Display
*/
if ($hostId > 0) {
$data = [];
// host scripts
$data['hostScripts'] = API::Script()->getScriptsByHosts([$hostId]);
// inventory info
$data['tableTitles'] = getHostInventories();
$data['tableTitles'] = zbx_toHash($data['tableTitles'], 'db_field');
$inventoryFields = array_keys($data['tableTitles']);
// overview tab
$data['host'] = API::Host()->get(['output' => ['hostid', 'host', 'name', 'status', 'maintenance_status', 'maintenanceid', 'maintenance_type', 'description'], 'selectInterfaces' => API_OUTPUT_EXTEND, 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectScreens' => API_OUTPUT_COUNT, 'selectInventory' => $inventoryFields, 'selectGraphs' => API_OUTPUT_COUNT, 'selectApplications' => API_OUTPUT_COUNT, 'selectDiscoveries' => API_OUTPUT_COUNT, 'selectHttpTests' => API_OUTPUT_COUNT, 'hostids' => $hostId, 'preservekeys' => true]);
$data['host'] = reset($data['host']);
unset($data['host']['inventory']['hostid']);
// resolve macros
$data['host']['interfaces'] = CMacrosResolverHelper::resolveHostInterfaces($data['host']['interfaces']);
if ($data['host']['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
$data['maintenances'] = API::Maintenance()->get(['maintenanceids' => [$data['host']['maintenanceid']], 'output' => ['name', 'description'], 'preservekeys' => true]);
}
// get permissions
$userType = CWebUser::getType();
if ($userType == USER_TYPE_SUPER_ADMIN) {
$data['rwHost'] = true;
} elseif ($userType == USER_TYPE_ZABBIX_ADMIN) {
$rwHost = API::Host()->get(['output' => ['hostid'], 'hostids' => $hostId, 'editable' => true]);
$data['rwHost'] = (bool) $rwHost;
} else {
$data['rwHost'] = false;
}
// view generation
$hostinventoriesView = new CView('inventory.host.view', $data);
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:31, 代码来源:hostinventories.php
示例13: __construct
/**
* Init screen data.
*
* @param array $options
* @param array $options['itemids']
* @param string $options['filter']
* @param int $options['filterTask']
* @param int $options['markColor']
* @param boolean $options['plaintext']
* @param array $options['items']
* @param array $options['item']
*/
public function __construct(array $options = array())
{
parent::__construct($options);
$this->resourcetype = SCREEN_RESOURCE_HISTORY;
// mandatory
$this->itemids = isset($options['itemids']) ? $options['itemids'] : null;
$this->filter = isset($options['filter']) ? $options['filter'] : null;
$this->filterTask = isset($options['filter_task']) ? $options['filter_task'] : null;
$this->markColor = isset($options['mark_color']) ? $options['mark_color'] : MARK_COLOR_RED;
// optional
$this->items = isset($options['items']) ? $options['items'] : null;
$this->item = isset($options['item']) ? $options['item'] : null;
$this->plaintext = isset($options['plaintext']) ? $options['plaintext'] : false;
if (empty($this->items)) {
$this->items = API::Item()->get(array('nodeids' => get_current_nodeid(), 'itemids' => $this->itemids, 'webitems' => true, 'selectHosts' => array('name'), 'output' => array('itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'), 'preservekeys' => true));
$this->items = CMacrosResolverHelper::resolveItemNames($this->items);
$this->item = reset($this->items);
}
}
开发者ID:itnihao, 项目名称:zatree-2.2, 代码行数:31, 代码来源:CScreenHistory.php
示例14: 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
示例15: get
/**
* Process screen.
*
* @return CDiv (screen inside container)
*/
public function get()
{
$output = [];
$items = API::Item()->get(['output' => ['itemid', 'hostid', 'name', 'key_', 'value_type', 'valuemapid'], 'selectHosts' => ['name'], 'itemids' => $this->itemids, 'webitems' => true, 'preservekeys' => true]);
$items = CMacrosResolverHelper::resolveItemNames($items);
$stime = zbxDateToTime($this->timeline['stime']);
$firstItem = reset($items);
$iv_string = [ITEM_VALUE_TYPE_LOG => 1, ITEM_VALUE_TYPE_TEXT => 1];
$iv_numeric = [ITEM_VALUE_TYPE_FLOAT => 1, ITEM_VALUE_TYPE_UINT64 => 1];
if ($this->action == HISTORY_VALUES || $this->action == HISTORY_LATEST) {
$options = ['history' => $firstItem['value_type'], 'itemids' => $this->itemids, 'output' => API_OUTPUT_EXTEND, 'sortorder' => ZBX_SORT_DOWN];
if ($this->action == HISTORY_LATEST) {
$options['limit'] = 500;
} elseif ($this->action == HISTORY_VALUES) {
$config = select_config();
// interval start value is non-inclusive, hence the + 1 second
$options['time_from'] = $stime + 1;
$options['time_till'] = $stime + $this->timeline['period'];
$options['limit'] = $config['search_limit'];
}
// text log
if (isset($iv_string[$firstItem['value_type']])) {
$isManyItems = count($items) > 1;
$useLogItem = $firstItem['value_type'] == ITEM_VALUE_TYPE_LOG;
$useEventLogItem = strpos($firstItem['key_'], 'eventlog[') === 0;
if (empty($this->plaintext)) {
$historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), $isManyItems ? _('Item') : null, $useLogItem ? (new CColHeader(_('Local time')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Source')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Severity')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, $useEventLogItem && $useLogItem ? (new CColHeader(_('Event ID')))->addClass(ZBX_STYLE_CELL_WIDTH) : null, _('Value')]);
}
if ($this->filter !== '' && in_array($this->filterTask, [FILTER_TASK_SHOW, FILTER_TASK_HIDE])) {
$options['search'] = ['value' => $this->filter];
if ($this->filterTask == FILTER_TASK_HIDE) {
$options['excludeSearch'] = 1;
}
}
$options['sortfield'] = 'id';
$historyData = API::History()->get($options);
foreach ($historyData as $data) {
$data['value'] = rtrim($data['value'], " \t\r\n");
if (empty($this->plaintext)) {
$item = $items[$data['itemid']];
$host = reset($item['hosts']);
$color = null;
if ($this->filter !== '') {
$haystack = mb_strtolower($data['value']);
$needle = mb_strtolower($this->filter);
$pos = mb_strpos($haystack, $needle);
if ($pos !== false && $this->filterTask == FILTER_TASK_MARK) {
$color = $this->markColor;
} elseif ($pos === false && $this->filterTask == FILTER_TASK_INVERT_MARK) {
$color = $this->markColor;
}
switch ($color) {
case MARK_COLOR_RED:
$color = ZBX_STYLE_RED;
break;
case MARK_COLOR_GREEN:
$color = ZBX_STYLE_GREEN;
break;
case MARK_COLOR_BLUE:
$color = ZBX_STYLE_BLUE;
break;
}
}
$row = [];
$row[] = (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
if ($isManyItems) {
$row[] = (new CCol($host['name'] . NAME_DELIMITER . $item['name_expanded']))->addClass($color);
}
if ($useLogItem) {
$row[] = $data['timestamp'] != 0 ? (new CCol(zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['timestamp'])))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
// if this is a eventLog item, showing additional info
if ($useEventLogItem) {
$row[] = (new CCol($data['source']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color);
$row[] = $data['severity'] != 0 ? (new CCol(get_item_logtype_description($data['severity'])))->addClass(ZBX_STYLE_NOWRAP)->addClass(get_item_logtype_style($data['severity'])) : '';
$row[] = $data['logeventid'] != 0 ? (new CCol($data['logeventid']))->addClass(ZBX_STYLE_NOWRAP)->addClass($color) : '';
}
}
$row[] = (new CCol(new CPre(zbx_nl2br($data['value']))))->addClass($color);
$historyTable->addRow($row);
} else {
$output[] = zbx_date2str(DATE_TIME_FORMAT_SECONDS, $data['clock']) . ' ' . $data['clock'] . ' ' . htmlspecialchars($data['value']);
}
}
if (empty($this->plaintext)) {
$output[] = $historyTable;
}
} else {
if (empty($this->plaintext)) {
$historyTable = (new CTableInfo())->setHeader([(new CColHeader(_('Timestamp')))->addClass(ZBX_STYLE_CELL_WIDTH), _('Value')]);
}
$options['sortfield'] = ['itemid', 'clock'];
$historyData = API::History()->get($options);
foreach ($historyData as $data) {
$item = $items[$data['itemid']];
$value = rtrim($data['value'], " \t\r\n");
//.........这里部分代码省略.........
开发者ID:jbfavre, 项目名称:debian-zabbix, 代码行数:101, 代码来源:CScreenHistory.php
示例16: makeTriggersPopup
/**
* Generate table for dashboard triggers popup.
*
* @see make_system_status
*
* @param array $triggers
* @param array $ackParams
* @param array $actions
* @param array $config
*
* @return CTableInfo
*/
function makeTriggersPopup(array $triggers, array $ackParams, array $actions, array $config)
{
$popupTable = new CTableInfo();
$popupTable->setAttribute('style', 'width: 400px;');
$popupTable->setHeader(array(_('Host'), _('Issue'), _('Age'), _('Info'), $config['event_ack_enable'] ? _('Ack') : null, _('Actions')));
CArrayHelper::sort($triggers, array(array('field' => 'lastchange', 'order' => ZBX_SORT_DOWN)));
$triggers = CMacrosResolverHelper::resolveTriggerNames($triggers);
foreach ($triggers as $trigger) {
// unknown triggers
$unknown = SPACE;
if ($trigger['state'] == TRIGGER_STATE_UNKNOWN) {
$unknown = new CDiv(SPACE, 'status_icon iconunknown');
$unknown->setHint($trigger['error'], 'on');
}
// ack
if ($config['event_ack_enable']) {
$ack = isset($trigger['event']['eventid']) ? getEventAckState($trigger['event'], true, true, $ackParams) : _('No events');
} else {
$ack = null;
}
// action
$action = isset($trigger['event']['eventid']) && isset($actions[$trigger['event']['eventid']]) ? $actions[$trigger['event']['eventid']] : _('-');
$popupTable->addRow(array($trigger['hosts'][0]['name'], getSeverityCell($trigger['priority'], $trigger['description']), zbx_date2age($trigger['lastchange']), $unknown, $ack, $action));
}
return $popupTable;
}
开发者ID:omidmt, 项目名称:zabbix-greenplum, 代码行数:38, 代码来源:blocks.inc.php
The BolunHan/Krypton repository through 2021-06-03 on GitHub allows absolute pat
阅读:686| 2022-07-29
librespeed/speedtest: Self-hosted Speedtest for HTML5 and more. Easy setup, exam
阅读:1223| 2022-08-30
ozzieperez/packtpub-library-downloader: Script to download all your PacktPub ebo
阅读:535| 2022-08-15
avehtari/BDA_m_demos: Bayesian Data Analysis demos for Matlab/Octave
阅读:1136| 2022-08-17
女人怀孕后,为了有一个健康聪明的宝宝,经历各种体检、筛查。其实这些体检和筛查中的
阅读:947| 2022-11-06
medfreeman/markdown-it-toc-and-anchor: markdown-it plugin to add a toc and ancho
阅读:1344| 2022-08-18
sydney0zq/covid-19-detection: The implementation of A Weakly-supervised Framewor
阅读:491| 2022-08-16
PacktPublishing/Mastering-Embedded-Linux-Programming-Third-Edition: Mastering Em
阅读:747| 2022-08-15
离中国最远的国家是阿根廷。从太平洋直线计算,即往东线走,北京到阿根廷的布宜诺斯艾
阅读:644| 2022-11-06
shem8/MaterialLogin: Login view with material design
阅读:726| 2022-08-17
请发表评论