/** * Init screen data. * * @param array $options * @param string $options['filter'] * @param int $options['filterTask'] * @param int $options['markColor'] * @param boolean $options['plaintext'] * @param array $options['itemids'] */ public function __construct(array $options = []) { parent::__construct($options); $this->resourcetype = SCREEN_RESOURCE_HISTORY; // mandatory $this->filter = isset($options['filter']) ? $options['filter'] : ''; $this->filterTask = isset($options['filter_task']) ? $options['filter_task'] : null; $this->markColor = isset($options['mark_color']) ? $options['mark_color'] : MARK_COLOR_RED; $this->graphType = isset($options['graphtype']) ? $options['graphtype'] : GRAPH_TYPE_NORMAL; // optional $this->itemids = array_key_exists('itemids', $options) ? $options['itemids'] : []; $this->plaintext = isset($options['plaintext']) ? $options['plaintext'] : false; }
/** * Init screen data. * * @param array $options * @param int $options['itemid'] * @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->itemid = isset($options['itemid']) ? $options['itemid'] : 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->itemid, 'webitems' => true, 'selectHosts' => array('hostid', 'name'), 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true)); $this->item = reset($this->items); } }
} } elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { add2favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } $result = DBend($result); if ($page['type'] == PAGE_TYPE_JS && $result) { echo 'switchElementClass("addrm_fav", "iconminus", "iconplus");'; } } } if (!empty($_REQUEST['period']) || !empty($_REQUEST['stime'])) { CScreenBase::calculateTime(array('profileIdx' => 'web.screens', 'profileIdx2' => $pageFilter->graphid, 'updateProfile' => true, 'period' => getRequest('period'), 'stime' => getRequest('stime'))); $curl = new CUrl(); $curl->removeArgument('period'); $curl->removeArgument('stime'); ob_end_clean(); DBstart(); CProfile::flush(); DBend(); redirect($curl->getUrl()); } ob_end_flush(); if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /*
/** * Init screen data. * * @param array $options * @param array $options['data'] */ public function __construct(array $options = []) { parent::__construct($options); $this->data = $options['data']; }
$fields = array('itemid' => array(T_ZBX_INT, O_MAND, P_SYS, DB_ID, null), 'screenid' => array(T_ZBX_STR, O_OPT, null, null, 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, '{}>0', null), 'height' => array(T_ZBX_INT, O_OPT, null, '{}>0', null), 'border' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), null)); check_fields($fields); /* * Permissions */ if (!DBfetch(DBselect('SELECT i.itemid FROM items i WHERE i.itemid=' . $_REQUEST['itemid']))) { show_error_message(_('No items defined.')); } $dbItems = API::Item()->get(array('itemids' => $_REQUEST['itemid'], 'webitems' => true, 'nodeids' => get_current_nodeid(true), 'filter' => array('flags' => null))); if (empty($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 CChart(); $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); }
foreach ($items as $item) { if (!isset($dbItems[$item['itemid']])) { 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));
/** * Init screen data. * * @param array $options * @param int $options['graphid'] */ public function __construct(array $options = array()) { parent::__construct($options); $this->graphid = isset($options['graphid']) ? $options['graphid'] : null; }
/** * Init screen data. * * @param array $options * @param boolean $options['isFlickerfree'] * @param string $options['pageFile'] * @param int $options['mode'] * @param int $options['timestamp'] * @param int $options['hostid'] * @param int $options['period'] * @param int $options['stime'] * @param string $options['profileIdx'] * @param int $options['profileIdx2'] * @param boolean $options['updateProfile'] * @param array $options['screen'] */ public function __construct(array $options = array()) { $this->isFlickerfree = isset($options['isFlickerfree']) ? $options['isFlickerfree'] : true; $this->mode = isset($options['mode']) ? $options['mode'] : SCREEN_MODE_SLIDESHOW; $this->timestamp = !empty($options['timestamp']) ? $options['timestamp'] : time(); $this->hostid = !empty($options['hostid']) ? $options['hostid'] : null; // get page file if (!empty($options['pageFile'])) { $this->pageFile = $options['pageFile']; } else { global $page; $this->pageFile = $page['file']; } // get screen if (!empty($options['screen'])) { $this->screen = $options['screen']; } elseif (!empty($options['screenid'])) { $this->screen = API::Screen()->get(array('screenids' => $options['screenid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND, 'editable' => $this->mode == SCREEN_MODE_EDIT)); if (!empty($this->screen)) { $this->screen = reset($this->screen); } else { access_deny(); } } // calculate time $this->profileIdx = !empty($options['profileIdx']) ? $options['profileIdx'] : ''; $this->profileIdx2 = !empty($options['profileIdx2']) ? $options['profileIdx2'] : null; $this->updateProfile = isset($options['updateProfile']) ? $options['updateProfile'] : true; $this->timeline = CScreenBase::calculateTime(array('profileIdx' => $this->profileIdx, 'profileIdx2' => $this->profileIdx2, 'updateProfile' => $this->updateProfile, 'period' => !empty($options['period']) ? $options['period'] : null, 'stime' => !empty($options['stime']) ? $options['stime'] : null)); }
* Graph in */ $graphInScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_in', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $graphInScreen->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($itemIds)); $src = 'chart3.php?height=150' . '&name=' . $httpTest['name'] . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_IN . '&httptestid=' . $httpTest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graphInScreen->timeline['period'] . '&stime=' . $graphInScreen->timeline['stime'] . '&profileIdx=' . $graphInScreen->profileIdx . '&profileIdx2=' . $graphInScreen->profileIdx2; $graphInContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_in'); $graphInContainer->setAttribute('style', 'position: relative'); $graphInContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Speed')), $graphInContainer)); $timeControlData = array('id' => 'graph_in', 'containerid' => 'flickerfreescreen_graph_in', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_in", ' . zbx_jsvalue($graphInScreen->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); $graphInScreen->insertFlickerfreeJs(); /* * Graph time */ $graphTimeScreen = new CScreenBase(array('resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_time', 'profileIdx' => 'web.httptest', 'profileIdx2' => get_request('httptestid'), 'period' => get_request('period'), 'stime' => get_request('stime'))); $src = 'chart3.php?height=150' . '&name=' . $httpTest['name'] . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_TIME . '&httptestid=' . $httpTest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graphTimeScreen->timeline['period'] . '&stime=' . $graphTimeScreen->timeline['stime'] . '&profileIdx=' . $graphTimeScreen->profileIdx . '&profileIdx2=' . $graphTimeScreen->profileIdx2; $graphTimeContainer = new CDiv(new CLink(null, $src), 'flickerfreescreen', 'flickerfreescreen_graph_time'); $graphTimeContainer->setAttribute('style', 'position: relative'); $graphTimeContainer->setAttribute('data-timestamp', time()); $graphTable->addRow(array(bold(_('Response time')), $graphTimeContainer)); $timeControlData = array('id' => 'graph_time', 'containerid' => 'flickerfreescreen_graph_time', 'src' => $src, 'objDims' => $graphDims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD); zbx_add_post_js('timeControl.addObject("graph_time", ' . zbx_jsvalue($graphInScreen->timeline) . ', ' . zbx_jsvalue($timeControlData) . ');'); $graphTimeScreen->insertFlickerfreeJs(); // scroll CScreenBuilder::insertScreenScrollJs(array('timeline' => $graphInScreen->timeline)); CScreenBuilder::insertScreenRefreshTimeJs(); CScreenBuilder::insertProcessObjectsJs(); $graphsWidget->addItem($graphTable); $graphsWidget->show(); require_once dirname(__FILE__) . '/include/page_footer.php';
/** * Init screen data. * * @param array $options * @param int $options['graphid'] */ public function __construct(array $options = []) { parent::__construct($options); $this->graphid = isset($options['graphid']) ? $options['graphid'] : null; $this->profileIdx2 = $this->graphid; }
// dims $graph_dims = getGraphDims(); $graph_dims['width'] = -50; $graph_dims['graphHeight'] = 150; /* * Graph in */ $graph_in = new CScreenBase(['resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_in', 'profileIdx' => 'web.httptest', 'profileIdx2' => getRequest('httptestid'), 'period' => getRequest('period'), 'stime' => getRequest('stime')]); $httptest_manager = new CHttpTestManager(); $itemids = $httptest_manager->getHttpStepItems($httptest['httptestid']); $itemids = zbx_objectValues($itemids, 'itemid'); $graph_in->timeline['starttime'] = date(TIMESTAMP_FORMAT, get_min_itemclock_by_itemid($itemids)); $src = 'chart3.php?height=150' . '&name=' . $http_test_name . ': ' . _('Speed') . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_IN . '&httptestid=' . $httptest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graph_in->timeline['period'] . '&stime=' . $graph_in->timeline['stime'] . '&profileIdx=' . $graph_in->profileIdx . '&profileIdx2=' . $graph_in->profileIdx2; $graphs[] = (new CDiv(new CLink(null, $src)))->addClass('flickerfreescreen')->setId('flickerfreescreen_graph_in')->setAttribute('data-timestamp', time()); $time_control_data = ['id' => 'graph_in', 'containerid' => 'flickerfreescreen_graph_in', 'src' => $src, 'objDims' => $graph_dims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD]; zbx_add_post_js('timeControl.addObject("graph_in", ' . zbx_jsvalue($graph_in->timeline) . ', ' . zbx_jsvalue($time_control_data) . ');'); $graph_in->insertFlickerfreeJs(); /* * Graph time */ $graph_time = new CScreenBase(['resourcetype' => SCREEN_RESOURCE_GRAPH, 'mode' => SCREEN_MODE_PREVIEW, 'dataId' => 'graph_time', 'profileIdx' => 'web.httptest', 'profileIdx2' => getRequest('httptestid'), 'period' => getRequest('period'), 'stime' => getRequest('stime')]); $src = 'chart3.php?height=150' . '&name=' . $http_test_name . ': ' . _('Response time') . '&http_item_type=' . HTTPSTEP_ITEM_TYPE_TIME . '&httptestid=' . $httptest['httptestid'] . '&graphtype=' . GRAPH_TYPE_STACKED . '&period=' . $graph_time->timeline['period'] . '&stime=' . $graph_time->timeline['stime'] . '&profileIdx=' . $graph_time->profileIdx . '&profileIdx2=' . $graph_time->profileIdx2; $graphs[] = (new CDiv(new CLink(null, $src)))->addClass('flickerfreescreen')->setId('flickerfreescreen_graph_time')->setAttribute('data-timestamp', time()); $time_control_data = ['id' => 'graph_time', 'containerid' => 'flickerfreescreen_graph_time', 'src' => $src, 'objDims' => $graph_dims, 'loadSBox' => 1, 'loadImage' => 1, 'periodFixed' => CProfile::get('web.httptest.timelinefixed', 1), 'sliderMaximumTimePeriod' => ZBX_MAX_PERIOD]; zbx_add_post_js('timeControl.addObject("graph_time", ' . zbx_jsvalue($graph_in->timeline) . ', ' . zbx_jsvalue($time_control_data) . ');'); $graph_time->insertFlickerfreeJs(); // scroll CScreenBuilder::insertScreenStandardJs(['timeline' => $graph_in->timeline]); // Create graphs widget. (new CWidget())->addItem((new CFilter('web.httpdetails.filter.state'))->addNavigator())->addItem((new CDiv($graphs))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER))->show(); require_once dirname(__FILE__) . '/include/page_footer.php';