1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22require_once dirname(__FILE__).'/include/config.inc.php'; 23require_once dirname(__FILE__).'/include/hosts.inc.php'; 24require_once dirname(__FILE__).'/include/httptest.inc.php'; 25require_once dirname(__FILE__).'/include/forms.inc.php'; 26 27$page['title'] = _('Details of web scenario'); 28$page['file'] = 'httpdetails.php'; 29$page['scripts'] = ['class.calendar.js', 'gtlc.js', 'flickerfreescreen.js', 'layout.mode.js']; 30$page['type'] = detect_page_type(PAGE_TYPE_HTML); 31$page['web_layout_mode'] = CViewHelper::loadLayoutMode(); 32 33require_once dirname(__FILE__).'/include/page_header.php'; 34 35// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION 36$fields = [ 37 'from' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null], 38 'to' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null], 39 'reset' => [T_ZBX_STR, O_OPT, P_SYS|P_ACT, null, null], 40 'httptestid' => [T_ZBX_INT, O_MAND, P_SYS, DB_ID, null] 41]; 42check_fields($fields); 43validateTimeSelectorPeriod(getRequest('from'), getRequest('to')); 44 45if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { 46 require_once dirname(__FILE__).'/include/page_footer.php'; 47 exit; 48} 49 50/* 51 * Collect data 52 */ 53$httptest = API::HttpTest()->get([ 54 'output' => ['httptestid', 'name', 'hostid'], 55 'httptestids' => getRequest('httptestid'), 56 'preservekeys' => true 57]); 58$httptest = reset($httptest); 59if (!$httptest) { 60 access_deny(); 61} 62 63$timeselector_options = [ 64 'profileIdx' => 'web.httpdetails.filter', 65 'profileIdx2' => $httptest['httptestid'], 66 'from' => getRequest('from'), 67 'to' => getRequest('to') 68]; 69updateTimeSelectorPeriod($timeselector_options); 70 71$timeline = getTimeSelectorPeriod($timeselector_options); 72 73$http_test_name = CMacrosResolverHelper::resolveHttpTestName($httptest['hostid'], $httptest['name']); 74 75$details_screen = CScreenBuilder::getScreen([ 76 'resourcetype' => SCREEN_RESOURCE_HTTPTEST_DETAILS, 77 'mode' => SCREEN_MODE_JS, 78 'dataId' => 'httptest_details' 79] + $timeline); 80 81$graphs = []; 82 83// dims 84$graph_dims = getGraphDims(); 85$graph_dims['width'] = -50; 86$graph_dims['graphHeight'] = 151; 87 88/* 89 * Graph in 90 */ 91$graph_in = new CScreenBase([ 92 'resourcetype' => SCREEN_RESOURCE_GRAPH, 93 'mode' => SCREEN_MODE_PREVIEW, 94 'dataId' => 'graph_in' 95] + $timeline); 96 97$items = DBfetchArray(DBselect( 98 'SELECT i.itemid,i.value_type,i.history,i.trends,i.hostid'. 99 ' FROM items i,httpstepitem hi,httpstep hs'. 100 ' WHERE i.itemid=hi.itemid'. 101 ' AND hi.httpstepid=hs.httpstepid'. 102 ' AND hs.httptestid='.zbx_dbstr($httptest['httptestid']) 103)); 104 105$url = (new CUrl('chart3.php')) 106 ->setArgument('height', 150) 107 ->setArgument('name', $http_test_name.': '._('Speed')) 108 ->setArgument('http_item_type', HTTPSTEP_ITEM_TYPE_IN) 109 ->setArgument('httptestid', $httptest['httptestid']) 110 ->setArgument('graphtype', GRAPH_TYPE_STACKED) 111 ->setArgument('from', $graph_in->timeline['from']) 112 ->setArgument('to', $graph_in->timeline['to']) 113 ->setArgument('profileIdx', $graph_in->profileIdx) 114 ->setArgument('profileIdx2', $graph_in->profileIdx2) 115 ->getUrl(); 116 117$graphs[] = (new CDiv((new CDiv()) 118 ->setId('graph_in_container') 119 ->addClass(ZBX_STYLE_CENTER) 120 )) 121 ->addClass('flickerfreescreen') 122 ->setId('flickerfreescreen_graph_in') 123 ->setAttribute('data-timestamp', time()); 124 125$time_control_data = [ 126 'id' => 'graph_in', 127 'containerid' => 'graph_in_container', 128 'src' => $url, 129 'objDims' => $graph_dims, 130 'loadSBox' => 1, 131 'loadImage' => 1 132]; 133zbx_add_post_js('timeControl.addObject("graph_in", '.zbx_jsvalue($graph_in->timeline).', '. 134 zbx_jsvalue($time_control_data).');' 135); 136$graph_in->insertFlickerfreeJs(); 137 138/* 139 * Graph time 140 */ 141$graph_time = new CScreenBase([ 142 'resourcetype' => SCREEN_RESOURCE_GRAPH, 143 'mode' => SCREEN_MODE_PREVIEW, 144 'dataId' => 'graph_time' 145] + $timeline); 146 147$url = (new CUrl('chart3.php')) 148 ->setArgument('height', 150) 149 ->setArgument('name', $http_test_name.': '._('Response time')) 150 ->setArgument('http_item_type', HTTPSTEP_ITEM_TYPE_TIME) 151 ->setArgument('httptestid', $httptest['httptestid']) 152 ->setArgument('graphtype', GRAPH_TYPE_STACKED) 153 ->setArgument('from', $graph_time->timeline['from']) 154 ->setArgument('to', $graph_time->timeline['to']) 155 ->setArgument('profileIdx', $graph_time->profileIdx) 156 ->setArgument('profileIdx2', $graph_time->profileIdx2) 157 ->getUrl(); 158 159$graphs[] = (new CDiv(((new CDiv()) 160 ->setId('graph_time_container') 161 ->addClass(ZBX_STYLE_CENTER) 162 ))) 163 ->addClass('flickerfreescreen') 164 ->setId('flickerfreescreen_graph_time') 165 ->setAttribute('data-timestamp', time()); 166 167$time_control_data = [ 168 'id' => 'graph_time', 169 'containerid' => 'graph_time_container', 170 'src' => $url, 171 'objDims' => $graph_dims, 172 'loadSBox' => 1, 173 'loadImage' => 1 174]; 175zbx_add_post_js('timeControl.addObject("graph_time", '.zbx_jsvalue($graph_in->timeline).', '. 176 zbx_jsvalue($time_control_data).');' 177); 178$graph_time->insertFlickerfreeJs(); 179 180// scroll 181CScreenBuilder::insertScreenStandardJs($graph_in->timeline); 182 183// Create graphs widget. 184$widget = (new CWidget()) 185 ->setTitle(_('Details of web scenario').': '.$http_test_name) 186 ->setWebLayoutMode($page['web_layout_mode']) 187 ->setControls((new CTag('nav', true, 188 (new CForm()) 189 ->cleanItems() 190 ->addItem((new CList())->addItem(get_icon('kioskmode', ['mode' => $page['web_layout_mode']]))) 191 )) 192 ->setAttribute('aria-label', _('Content controls')) 193 ) 194 ->addItem($details_screen->get()) 195 ->addItem(new CTag('br')) 196 ->addItem( 197 (new CFilter(new CUrl())) 198 ->setProfile($timeline['profileIdx'], $timeline['profileIdx2']) 199 ->setActiveTab(CProfile::get($timeline['profileIdx'].'.active', 1)) 200 ->addTimeSelector($timeline['from'], $timeline['to'], $page['web_layout_mode'] != ZBX_LAYOUT_KIOSKMODE) 201 ) 202 ->addItem((new CDiv($graphs))->addClass(ZBX_STYLE_TABLE_FORMS_CONTAINER)) 203 ->show(); 204 205require_once dirname(__FILE__).'/include/page_footer.php'; 206