$db_host['item_cnt']++; if (isset($showAll) && !empty($apps) && !isset($apps[0])) { continue; } else { if (isset($hideAll) && (empty($apps) || isset($apps[0]))) { continue; } } // column "lastclock" if (isset($db_item['lastclock'])) { $lastclock = zbx_date2str(_('d M Y H:i:s'), $db_item['lastclock']); } else { $lastclock = ' - '; } // column "lastvalue" $lastvalue = formatItemValue($db_item); // column "change" $digits = $db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT ? 2 : 0; if (isset($db_item['lastvalue']) && isset($db_item['prevvalue']) && ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) && bcsub($db_item['lastvalue'], $db_item['prevvalue'], $digits) != 0) { $change = ''; if ($db_item['lastvalue'] - $db_item['prevvalue'] > 0) { $change = '+'; } // for 'unixtime' change should be calculated as uptime $change .= convert_units(bcsub($db_item['lastvalue'], $db_item['prevvalue'], $digits), $db_item['units'] == 'unixtime' ? 'uptime' : $db_item['units'], 0); $change = nbsp($change); } else { $change = ' - '; } // column "action" if ($db_item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $db_item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
$resp = formatItemValue($httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_RSPCODE]); $respTime = $httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_TIME]['lastvalue']; $respItemTime = formatItemValue($httpstep_data['item_data'][HTTPSTEP_ITEM_TYPE_TIME]); $httpdetailsTable->addRow(array($httpstep_data['name'], $speed, $respTime == 0 ? '-' : $respItemTime, $resp, new CSpan($status['msg'], $status['style']))); } if (!isset($db_httptest['lastcheck'])) { $status['msg'] = _('Never executed'); $status['style'] = 'unknown'; } elseif ($db_httptest['lastfailedstep'] != 0) { $status['msg'] = _s('Error: %1$s', $db_httptest['error']); $status['style'] = 'disabled'; } else { $status['msg'] = _('OK'); $status['style'] = 'enabled'; } $httpdetailsTable->addRow(array(bold(_('TOTAL')), SPACE, bold(formatItemValue($totalTime)), SPACE, new CSpan($status['msg'], $status['style'] . ' bold'))); $httpdetailsWidget->addItem($httpdetailsTable); $httpdetailsWidget->show(); echo SBR; // create graphs widget $graphsWidget = new CWidget(); $graphsWidget->addFlicker(new CDiv(null, null, 'scrollbar_cntr'), CProfile::get('web.httpdetails.filter.state', 0)); $graphsWidget->addItem(SPACE); $graphTable = new CTableInfo(); $graphTable->setAttribute('id', 'graph'); // dims $graphDims = getGraphDims(); $graphDims['shiftYtop'] += 1; $graphDims['width'] = -120; $graphDims['graphHeight'] = 150; /*
/** * Resolve {ITEM.LASTVALUE} macro. * * @param array $item * * @return string */ protected function resolveItemLastvalueMacro(array $item) { if (is_null($item['mappingid'])) { $value = formatItemValue($item, UNRESOLVED_MACRO_STRING); } else { $value = $item['newvalue'] . ' (' . $item['lastvalue'] . ')'; } return $value; }
function get_item_data_overview_cells(&$table_row, &$ithosts, $hostname) { $css_class = ''; unset($it_ov_menu); $value = '-'; $ack = null; if (isset($ithosts[$hostname])) { if ($ithosts[$hostname]['tr_value'] == TRIGGER_VALUE_TRUE) { $css_class = getSeverityStyle($ithosts[$hostname]['severity']); $ack = get_last_event_by_triggerid($ithosts[$hostname]['triggerid']); $ack = $ack['acknowledged'] == 1 ? array(SPACE, new CImg('images/general/tick.png', 'ack')) : null; } $value = formatItemValue($ithosts[$hostname]); $it_ov_menu = array(array(_('Values'), null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(_('500 latest values'), 'history.php?action=showlatest&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank'))); switch ($ithosts[$hostname]['value_type']) { case ITEM_VALUE_TYPE_UINT64: case ITEM_VALUE_TYPE_FLOAT: $it_ov_menu = array_merge(array(array(_('Graphs'), null, null, array('outer' => array('pum_oheader'), 'inner' => array('pum_iheader'))), array(_('Last hour graph'), 'history.php?period=3600&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank')), array(_('Last week graph'), 'history.php?period=604800&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank')), array(_('Last month graph'), 'history.php?period=2678400&action=showgraph&itemid=' . $ithosts[$hostname]['itemid'], array('tw' => '_blank'))), $it_ov_menu); break; default: break; } } if ($value != '-') { $value = new CSpan($value, 'link'); } $value_col = new CCol(array($value, $ack), $css_class); if (isset($it_ov_menu)) { $it_ov_menu = new CPUMenu($it_ov_menu, 170); $value_col->onClick($it_ov_menu->getOnActionJS()); unset($it_ov_menu); } array_push($table_row, $value_col); return $table_row; }
protected function resolveItemValueMacro(array $item, array $trigger) { $item['lastvalue'] = item_get_history($item, 0, $trigger['clock'], $trigger['ns']); return formatItemValue($item, UNRESOLVED_MACRO_STRING); }