access_deny(); } } $name = getRequest('name', ''); } else { show_error_message(_('No items defined.')); exit; } /* * Display */ $profileIdx = getRequest('profileIdx', 'web.httptest'); $profileIdx2 = getRequest('httptestid', getRequest('profileIdx2')); $timeline = CScreenBase::calculateTime(array('profileIdx' => $profileIdx, 'profileIdx2' => $profileIdx2, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); CProfile::update($profileIdx . '.httptestid', $profileIdx2, PROFILE_TYPE_ID); $graph = new CLineGraphDraw(getRequest('graphtype', GRAPH_TYPE_NORMAL)); $graph->setHeader($name); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); $graph->setWidth(getRequest('width', 900)); $graph->setHeight(getRequest('height', 200)); $graph->showLegend(getRequest('legend', 1)); $graph->showWorkPeriod(getRequest('showworkperiod', 1)); $graph->showTriggers(getRequest('showtriggers', 1)); $graph->setYMinAxisType(getRequest('ymin_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYMaxAxisType(getRequest('ymax_type', GRAPH_YAXIS_TYPE_CALCULATED)); $graph->setYAxisMin(getRequest('yaxismin', 0.0)); $graph->setYAxisMax(getRequest('yaxismax', 100.0)); $graph->setYMinItemId(getRequest('ymin_itemid', 0)); $graph->setYMaxItemId(getRequest('ymax_itemid', 0)); $graph->setLeftPercentage(getRequest('percent_left', 0));
} $hostNames = array(); foreach ($items as &$item) { $item['hostname'] = $item['hosts'][0]['name']; if (!in_array($item['hostname'], $hostNames)) { $hostNames[] = $item['hostname']; } } unset($item); // sort items CArrayHelper::sort($items, array('name', 'hostname', 'itemid')); /* * Display */ $timeline = CScreenBase::calculateTime(array('profileIdx' => getRequest('profileIdx', 'web.screens'), 'profileIdx2' => getRequest('profileIdx2'), 'updateProfile' => getRequest('updateProfile', true), 'period' => getRequest('period'), 'stime' => getRequest('stime'))); $graph = new CLineGraphDraw(getRequest('type')); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); // change how the graph will be displayed if more than one item is selected if (getRequest('batch')) { // set a default header if (count($hostNames) == 1) { $graph->setHeader($hostNames[0] . NAME_DELIMITER . _('Item values')); } else { $graph->setHeader(_('Item values')); } // hide triggers $graph->showTriggers(false); } if (isset($_REQUEST['from'])) { $graph->setFrom($_REQUEST['from']);
} else { $dbGraph = reset($dbGraph); } $host = API::Host()->get(array('nodeids' => get_current_nodeid(true), 'graphids' => $_REQUEST['graphid'], 'output' => API_OUTPUT_EXTEND, 'templated_hosts' => true)); $host = reset($host); /* * Display */ $timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime'))); CProfile::update('web.screens.graphid', $_REQUEST['graphid'], PROFILE_TYPE_ID); $chartHeader = ''; if (id2nodeid($dbGraph['graphid']) != get_current_nodeid()) { $chartHeader = get_node_name_by_elid($dbGraph['graphid'], true, NAME_DELIMITER); } $chartHeader .= $host['name'] . NAME_DELIMITER . $dbGraph['name']; $graph = new CLineGraphDraw($dbGraph['graphtype']); $graph->setHeader($chartHeader); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); if (isset($_REQUEST['border'])) { $graph->setBorder(0); } $width = get_request('width', 0); if ($width <= 0) { $width = $dbGraph['width']; } $height = get_request('height', 0); if ($height <= 0) { $height = $dbGraph['height']; } $graph->showLegend($dbGraph['show_legend']);
$fields = array('itemid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'period' => array(T_ZBX_INT, O_OPT, P_NZERO, BETWEEN(ZBX_MIN_PERIOD, ZBX_MAX_PERIOD), null), 'stime' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'profileIdx' => array(T_ZBX_STR, O_OPT, null, null, null), 'profileIdx2' => array(T_ZBX_STR, O_OPT, null, null, null), 'updateProfile' => array(T_ZBX_STR, O_OPT, null, null, null), 'from' => array(T_ZBX_INT, O_OPT, null, '{}>=0', null), 'width' => array(T_ZBX_INT, O_OPT, null, BETWEEN(20, 65535), null), 'height' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'border' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), null)); if (!check_fields($fields)) { exit; } /* * Permissions */ $dbItems = API::Item()->get(array('output' => array('itemid'), 'itemids' => $_REQUEST['itemid'], 'webitems' => true)); if (!$dbItems) { access_deny(); } /* * Display */ $timeline = CScreenBase::calculateTime(array('profileIdx' => get_request('profileIdx', 'web.screens'), 'profileIdx2' => get_request('profileIdx2'), 'updateProfile' => get_request('updateProfile', true), 'period' => get_request('period'), 'stime' => get_request('stime'))); $graph = new CLineGraphDraw(); $graph->setPeriod($timeline['period']); $graph->setSTime($timeline['stime']); if (isset($_REQUEST['from'])) { $graph->setFrom($_REQUEST['from']); } if (isset($_REQUEST['width'])) { $graph->setWidth($_REQUEST['width']); } if (isset($_REQUEST['height'])) { $graph->setHeight($_REQUEST['height']); } if (isset($_REQUEST['border'])) { $graph->setBorder(0); } $graph->addItem($_REQUEST['itemid'], GRAPH_YAXIS_SIDE_DEFAULT, CALC_FNC_ALL);