[T_ZBX_INT, O_OPT, P_SYS|P_ONLY_ARRAY, DB_ID, null], 'from' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null], 'to' => [T_ZBX_RANGE_TIME, O_OPT, P_SYS, null, null], 'filter_task' => [T_ZBX_STR, O_OPT, null, IN(FILTER_TASK_SHOW.','.FILTER_TASK_HIDE.','.FILTER_TASK_MARK.','.FILTER_TASK_INVERT_MARK), null], 'filter' => [T_ZBX_STR, O_OPT, null, null, null], 'mark_color' => [T_ZBX_STR, O_OPT, null, IN(MARK_COLOR_RED.','.MARK_COLOR_GREEN.','.MARK_COLOR_BLUE), null], 'plaintext' => [T_ZBX_STR, O_OPT, null, null, null], 'action' => [T_ZBX_STR, O_OPT, P_SYS, IN('"'.HISTORY_GRAPH.'","'.HISTORY_VALUES.'","'.HISTORY_LATEST.'","'.HISTORY_BATCH_GRAPH.'"'), null], 'graphtype' => [T_ZBX_INT, O_OPT, null, IN([GRAPH_TYPE_NORMAL, GRAPH_TYPE_STACKED]), null], // filter 'filter_rst' => [T_ZBX_STR, O_OPT, P_SYS, null, null] ]; check_fields($fields); validateTimeSelectorPeriod(getRequest('from'), getRequest('to')); if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__).'/include/page_footer.php'; exit; } /* * Actions */ $_REQUEST['action'] = getRequest('action', HISTORY_GRAPH); /* * Display */ $itemids = getRequest('filter_rst') ? [] : getRequest('itemids', []); $items = []; $value_type = ''; if ($itemids) { $items = API::Item()->get([ 'output' => ['itemid', 'name', 'value_type'], 'selectHosts' => ['name'], 'itemids' => $itemids, 'preservekeys' => true, 'templated' => false, 'webitems' => true ]); if (getRequest('action') == HISTORY_BATCH_GRAPH) { // Remove items that are not numeric. $items = array_filter($items, function ($item) { return ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64); }); // Keep only item IDs that are applicable to graphs. $itemids = array_keys($items); // If there are none left and all of the selected did not exist or were not numeric, display error. if (!$itemids) { access_deny(); } } else { // If other mode is selected, retain original functionality where all given items are checked if they exist. foreach ($itemids as $itemid) { if (!array_key_exists($itemid, $items)) { access_deny(); } } } $item = reset($items); $value_type = $item['value_type']; } $data = [ 'itemids' => $itemids, 'items' => $items, 'value_type' => $value_type, 'action' => getRequest('action'), 'from' => getRequest('from'), 'to' => getRequest('to'), 'page' => getRequest('page', 1), 'plaintext' => hasRequest('plaintext'), 'graphtype' => getRequest('graphtype', GRAPH_TYPE_NORMAL), 'iv_string' => [ITEM_VALUE_TYPE_LOG => true, ITEM_VALUE_TYPE_TEXT => true], 'iv_numeric' => [ITEM_VALUE_TYPE_FLOAT => true, ITEM_VALUE_TYPE_UINT64 => true], 'profileIdx' => 'web.item.graph.filter', 'profileIdx2' => 0, 'filter_task' => getRequest('filter_rst') ? FILTER_TASK_SHOW : getRequest('filter_task', FILTER_TASK_SHOW), 'mark_color' => getRequest('mark_color', MARK_COLOR_RED), 'filter' => getRequest('filter_rst') ? '' : getRequest('filter', ''), 'active_tab' => CProfile::get('web.item.graph.filter.active', 1) ]; if ($data['action'] != HISTORY_BATCH_GRAPH && $itemids) { $data['profileIdx2'] = reset($itemids); } updateTimeSelectorPeriod([ 'profileIdx' => $data['profileIdx'], 'profileIdx2' => $data['profileIdx2'], 'from' => getRequest('from'), 'to' => getRequest('to') ]); // render view echo (new CView('monitoring.history', $data))->getOutput(); require_once dirname(__FILE__).'/include/page_footer.php';