protected function doAction() { $sortField = $this->getInput('sort', CProfile::get('web.proxies.php.sort', 'host')); $sortOrder = $this->getInput('sortorder', CProfile::get('web.proxies.php.sortorder', ZBX_SORT_UP)); CProfile::update('web.proxies.php.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.proxies.php.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder, 'config' => ['max_in_table' => $config['max_in_table']]]; $data['proxies'] = API::Proxy()->get(['output' => ['proxyid', 'host', 'status', 'lastaccess', 'tls_connect', 'tls_accept'], 'selectHosts' => ['hostid', 'name', 'status'], 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]); // sorting & paging order_result($data['proxies'], $sortField, $sortOrder); $url = (new CUrl('zabbix.php'))->setArgument('action', 'proxy.list'); $data['paging'] = getPagingLine($data['proxies'], $sortOrder, $url); foreach ($data['proxies'] as &$proxy) { order_result($proxy['hosts'], 'name'); } unset($proxy); // get proxy IDs for a *selected* page $proxyIds = array_keys($data['proxies']); if ($proxyIds) { // calculate performance $dbPerformance = DBselect('SELECT h.proxy_hostid,SUM(1.0/i.delay) AS qps' . ' FROM hosts h,items i' . ' WHERE h.hostid=i.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE . ' AND ' . dbConditionInt('h.proxy_hostid', $proxyIds) . ' GROUP BY h.proxy_hostid'); while ($performance = DBfetch($dbPerformance)) { $data['proxies'][$performance['proxy_hostid']]['perf'] = round($performance['qps'], 2); } // get items $items = API::Item()->get(['proxyids' => $proxyIds, 'groupCount' => true, 'countOutput' => true, 'webitems' => true, 'monitored' => true]); foreach ($items as $item) { $data['proxies'][$item['proxy_hostid']]['item_count'] = $item['rowscount']; } } $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of proxies')); $this->setResponse($response); }
/** * Tries to login a user and populates self::$data on success. * * @param string $login user login * @param string $password user password * * @throws Exception if user cannot be logged in * * @return bool */ public static function login($login, $password) { try { self::setDefault(); self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true)); if (!self::$data) { throw new Exception(); } if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) { error(_('GUI access disabled.')); throw new Exception(); } if (empty(self::$data['url'])) { self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php'); } $result = (bool) self::$data; if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) { CProfile::init(); CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT); CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR); CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT); $result &= CProfile::flush(); } // remove guest session after successful login $result &= DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid'))); if ($result) { self::setSessionCookie(self::$data['sessionid']); add_audit_ext(AUDIT_ACTION_LOGIN, AUDIT_RESOURCE_USER, self::$data['userid'], '', null, null, null); } return $result; } catch (Exception $e) { self::setDefault(); return false; } }
protected function doAction() { $sortField = $this->getInput('sort', CProfile::get('web.media_types.php.sort', 'description')); $sortOrder = $this->getInput('sortorder', CProfile::get('web.media_types.php.sortorder', ZBX_SORT_UP)); CProfile::update('web.media_type.php.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.media_types.php.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder]; // get media types $data['mediatypes'] = API::Mediatype()->get(['output' => ['mediatypeid', 'description', 'type', 'smtp_server', 'smtp_helo', 'smtp_email', 'exec_path', 'gsm_modem', 'username', 'status'], 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]); if ($data['mediatypes']) { // get media types used in actions $actions = API::Action()->get(['output' => ['actionid', 'name'], 'selectOperations' => ['operationtype', 'opmessage'], 'mediatypeids' => array_keys($data['mediatypes'])]); foreach ($data['mediatypes'] as &$mediaType) { $mediaType['typeid'] = $mediaType['type']; $mediaType['type'] = media_type2str($mediaType['type']); $mediaType['listOfActions'] = []; foreach ($actions as $action) { foreach ($action['operations'] as $operation) { if ($operation['operationtype'] == OPERATION_TYPE_MESSAGE && $operation['opmessage']['mediatypeid'] == $mediaType['mediatypeid']) { $mediaType['listOfActions'][$action['actionid']] = ['actionid' => $action['actionid'], 'name' => $action['name']]; } } } order_result($mediaType['listOfActions'], 'name'); } unset($mediaType); order_result($data['mediatypes'], $sortField, $sortOrder); } $url = (new CUrl('zabbix.php'))->setArgument('action', 'mediatype.list'); $data['paging'] = getPagingLine($data['mediatypes'], $sortOrder, $url); $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of media types')); $this->setResponse($response); }
function local_generateHeader($data) { // only needed for zbx_construct_menu global $page; header('Content-Type: text/html; charset=UTF-8'); // construct menu $main_menu = []; $sub_menus = []; zbx_construct_menu($main_menu, $sub_menus, $page, $data['controller']['action']); $pageHeader = new CView('layout.htmlpage.header', ['javascript' => ['files' => $data['javascript']['files']], 'page' => ['title' => $data['page']['title']], 'user' => ['lang' => CWebUser::$data['lang'], 'theme' => CWebUser::$data['theme']]]); echo $pageHeader->getOutput(); if ($data['fullscreen'] == 0) { global $ZBX_SERVER_NAME; $pageMenu = new CView('layout.htmlpage.menu', ['server_name' => isset($ZBX_SERVER_NAME) ? $ZBX_SERVER_NAME : '', 'menu' => ['main_menu' => $main_menu, 'sub_menus' => $sub_menus, 'selected' => $page['menu']], 'user' => ['is_guest' => CWebUser::isGuest(), 'alias' => CWebUser::$data['alias'], 'name' => CWebUser::$data['name'], 'surname' => CWebUser::$data['surname']]]); echo $pageMenu->getOutput(); } echo '<div class="' . ZBX_STYLE_ARTICLE . '">'; // should be replaced with addPostJS() at some point zbx_add_post_js('initMessages({});'); // if a user logs in after several unsuccessful attempts, display a warning if ($failedAttempts = CProfile::get('web.login.attempt.failed', 0)) { $attempt_ip = CProfile::get('web.login.attempt.ip', ''); $attempt_date = CProfile::get('web.login.attempt.clock', 0); $error_msg = _n('%4$s failed login attempt logged. Last failed attempt was from %1$s on %2$s at %3$s.', '%4$s failed login attempts logged. Last failed attempt was from %1$s on %2$s at %3$s.', $attempt_ip, zbx_date2str(DATE_FORMAT, $attempt_date), zbx_date2str(TIME_FORMAT, $attempt_date), $failedAttempts); error($error_msg); CProfile::update('web.login.attempt.failed', 0, PROFILE_TYPE_INT); } show_messages(); }
public static function login($login, $password) { try { self::setDefault(); self::$data = API::User()->login(array('user' => $login, 'password' => $password, 'userData' => true)); if (!self::$data) { throw new Exception(); } if (self::$data['gui_access'] == GROUP_GUI_ACCESS_DISABLED) { error(_('GUI access disabled.')); throw new Exception(); } if (empty(self::$data['url'])) { self::$data['url'] = CProfile::get('web.menu.view.last', 'index.php'); } if (isset(self::$data['attempt_failed']) && self::$data['attempt_failed']) { CProfile::init(); CProfile::update('web.login.attempt.failed', self::$data['attempt_failed'], PROFILE_TYPE_INT); CProfile::update('web.login.attempt.ip', self::$data['attempt_ip'], PROFILE_TYPE_STR); CProfile::update('web.login.attempt.clock', self::$data['attempt_clock'], PROFILE_TYPE_INT); CProfile::flush(); } // remove guest session after successful login DBexecute('DELETE FROM sessions WHERE sessionid=' . zbx_dbstr(get_cookie('zbx_sessionid'))); zbx_setcookie('zbx_sessionid', self::$data['sessionid'], self::$data['autologin'] ? time() + SEC_PER_DAY * 31 : 0); return true; } catch (Exception $e) { self::setDefault(); return false; } }
protected function doAction() { $sortField = $this->getInput('sort', CProfile::get('web.scripts.php.sort', 'name')); $sortOrder = $this->getInput('sortorder', CProfile::get('web.scripts.php.sortorder', ZBX_SORT_UP)); CProfile::update('web.scripts.php.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.scripts.php.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder]; // list of scripts $data['scripts'] = API::Script()->get(['output' => ['scriptid', 'name', 'command', 'host_access', 'usrgrpid', 'groupid', 'type', 'execute_on'], 'editable' => true, 'limit' => $config['search_limit'] + 1]); // sorting & paging order_result($data['scripts'], $sortField, $sortOrder); $url = (new CUrl('zabbix.php'))->setArgument('action', 'script.list'); $data['paging'] = getPagingLine($data['scripts'], $sortOrder, $url); // find script host group name and user group name. set to '' if all host/user groups used. $usrgrpids = []; $groupids = []; foreach ($data['scripts'] as &$script) { $script['userGroupName'] = null; // all user groups $script['hostGroupName'] = null; // all host groups if ($script['usrgrpid'] != 0) { $usrgrpids[] = $script['usrgrpid']; } if ($script['groupid'] != 0) { $groupids[] = $script['groupid']; } } unset($script); if ($usrgrpids) { $userGroups = API::UserGroup()->get(['output' => ['name'], 'usrgrpids' => $usrgrpids, 'preservekeys' => true]); foreach ($data['scripts'] as &$script) { if ($script['usrgrpid'] != 0 && array_key_exists($script['usrgrpid'], $userGroups)) { $script['userGroupName'] = $userGroups[$script['usrgrpid']]['name']; } unset($script['usrgrpid']); } unset($script); } if ($groupids) { $hostGroups = API::HostGroup()->get(['output' => ['name'], 'groupids' => $groupids, 'preservekeys' => true]); foreach ($data['scripts'] as &$script) { if ($script['groupid'] != 0 && array_key_exists($script['groupid'], $hostGroups)) { $script['hostGroupName'] = $hostGroups[$script['groupid']]['name']; } unset($script['groupid']); } unset($script); } $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of scripts')); $this->setResponse($response); }
protected function doAction() { $sortField = $this->getInput('sort', CProfile::get('web.httpmon.php.sort', 'name')); $sortOrder = $this->getInput('sortorder', CProfile::get('web.httpmon.php.sortorder', ZBX_SORT_UP)); CProfile::update('web.httpmon.php.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.httpmon.php.sortorder', $sortOrder, PROFILE_TYPE_STR); $data = ['fullscreen' => $this->getInput('fullscreen', 0), 'sort' => $sortField, 'sortorder' => $sortOrder, 'page' => $this->getInput('page', 1)]; $data['pageFilter'] = new CPageFilter(['groups' => ['real_hosts' => true, 'with_httptests' => true], 'hosts' => ['with_monitored_items' => true, 'with_httptests' => true], 'hostid' => $this->hasInput('hostid') ? $this->getInput('hostid') : null, 'groupid' => $this->hasInput('groupid') ? $this->getInput('groupid') : null]); $response = new CControllerResponseData($data); $response->setTitle(_('Web monitoring')); $this->setResponse($response); }
function init_nodes() { /* Init CURRENT NODE ID */ if (defined('ZBX_NODES_INITIALIZED')) { return; } global $USER_DETAILS; global $ZBX_LOCALNODEID, $ZBX_LOCMASTERID, $ZBX_CURRENT_NODEID, $ZBX_CURMASTERID, $ZBX_NODES, $ZBX_NODES_IDS, $ZBX_AVAILABLE_NODES, $ZBX_VIEWED_NODES, $ZBX_WITH_ALL_NODES; $ZBX_AVAILABLE_NODES = array(); $ZBX_NODES_IDS = array(); $ZBX_NODES = array(); $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID; $ZBX_WITH_ALL_NODES = !defined('ZBX_NOT_ALLOW_ALL_NODES'); if (!defined('ZBX_PAGE_NO_AUTHORIZATION') && ZBX_DISTRIBUTED) { if ($USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN) { $sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid FROM nodes n '; } else { $sql = 'SELECT DISTINCT n.nodeid,n.name,n.masterid ' . ' FROM nodes n, groups hg,rights r, users_groups g ' . ' WHERE r.id=hg.groupid ' . ' AND r.groupid=g.usrgrpid ' . ' AND g.userid=' . $USER_DETAILS['userid'] . ' AND n.nodeid=' . DBid2nodeid('hg.groupid'); } $db_nodes = DBselect($sql); while ($node = DBfetch($db_nodes)) { $ZBX_NODES[$node['nodeid']] = $node; $ZBX_NODES_IDS[$node['nodeid']] = $node['nodeid']; } $ZBX_AVAILABLE_NODES = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_LIST, PERM_RES_IDS_ARRAY, $ZBX_NODES_IDS); $ZBX_VIEWED_NODES = get_viewed_nodes(); $ZBX_CURRENT_NODEID = $ZBX_VIEWED_NODES['selected']; if ($node_data = DBfetch(DBselect('SELECT masterid FROM nodes WHERE nodeid=' . $ZBX_CURRENT_NODEID))) { $ZBX_CURMASTERID = $node_data['masterid']; } if (!isset($ZBX_NODES[$ZBX_CURRENT_NODEID])) { $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID; $ZBX_CURMASTERID = $ZBX_LOCMASTERID; } if (isset($_REQUEST['select_nodes'])) { // CProfile::update('web.nodes.selected', $ZBX_VIEWED_NODES['nodeids'], PROFILE_TYPE_ARRAY_ID); update_node_profile($ZBX_VIEWED_NODES['nodeids']); } if (isset($_REQUEST['switch_node'])) { CProfile::update('web.nodes.switch_node', $ZBX_VIEWED_NODES['selected'], PROFILE_TYPE_ID); } } else { $ZBX_CURRENT_NODEID = $ZBX_LOCALNODEID; $ZBX_CURMASTERID = $ZBX_LOCMASTERID; } // zbx_set_post_cookie('zbx_current_nodeid', $ZBX_CURRENT_NODEID); define('ZBX_NODES_INITIALIZED', 1); // reset profiles if node is different than local if ($ZBX_CURRENT_NODEID != $ZBX_LOCALNODEID) { CProfile::init(); } }
protected function doAction() { foreach (CJs::decodeJson($this->getInput('grid')) as $col => $column) { foreach ($column as $row => $widgetName) { $widgetName = str_replace('_widget', '', $widgetName); CProfile::update('web.dashboard.widget.' . $widgetName . '.col', $col, PROFILE_TYPE_INT); CProfile::update('web.dashboard.widget.' . $widgetName . '.row', $row, PROFILE_TYPE_INT); } } $data = ['main_block' => '']; $response = new CControllerResponseData($data); $this->setResponse($response); }
protected function doAction() { CProfile::update('web.maps.sysmapid', $this->sysmapid, PROFILE_TYPE_ID); $data = ['fullscreen' => $this->getInput('fullscreen', 0)]; $maps = API::Map()->get(['output' => ['name', 'severity_min'], 'sysmapids' => [$this->sysmapid]]); $data['map'] = reset($maps); $data['map']['editable'] = API::Map()->isWritable([$this->sysmapid]); $data['pageFilter'] = new CPageFilter(['severitiesMin' => ['default' => $data['map']['severity_min'], 'mapId' => $this->sysmapid], 'severityMin' => $this->hasInput('severity_min') ? $this->getInput('severity_min') : null]); $data['severity_min'] = $data['pageFilter']->severityMin; $response = new CControllerResponseData($data); $response->setTitle(_('Network maps')); $this->setResponse($response); }
protected function doAction() { $sortField = $this->getInput('sort', CProfile::get('web.discovery.php.sort', 'ip')); $sortOrder = $this->getInput('sortorder', CProfile::get('web.discovery.php.sortorder', ZBX_SORT_UP)); CProfile::update('web.discovery.php.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.discovery.php.sortorder', $sortOrder, PROFILE_TYPE_STR); /* * Display */ $data = ['fullscreen' => $this->getInput('fullscreen', 0), 'druleid' => $this->getInput('druleid', 0), 'sort' => $sortField, 'sortorder' => $sortOrder]; $data['pageFilter'] = new CPageFilter(['drules' => ['filter' => ['status' => DRULE_STATUS_ACTIVE]], 'druleid' => $data['druleid']]); $response = new CControllerResponseData($data); $response->setTitle(_('Status of discovery')); $this->setResponse($response); }
protected function doAction() { $widget = $this->getInput('widget'); $data = ['main_block' => '']; // refresh rate if ($this->hasInput('refreshrate')) { $refreshrate = $this->getInput('refreshrate'); CProfile::update('web.dashboard.widget.' . $widget . '.rf_rate', $refreshrate, PROFILE_TYPE_INT); $data['main_block'] = 'PMasters["dashboard"].dolls["' . $widget . '"].frequency(' . CJs::encodeJson($refreshrate) . ');' . "\n" . 'PMasters["dashboard"].dolls["' . $widget . '"].restartDoll();'; } // widget state if ($this->hasInput('state')) { CProfile::update('web.dashboard.widget.' . $widget . '.state', $this->getInput('state'), PROFILE_TYPE_INT); } $this->setResponse(new CControllerResponseData($data)); }
if (isset($_REQUEST['favid'])) { CProfile::update('web.auditlogs.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT); } } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Filter */ if (hasRequest('filter_set')) { CProfile::update('web.auditlogs.filter.alias', getRequest('alias', ''), PROFILE_TYPE_STR); CProfile::update('web.auditlogs.filter.action', getRequest('action', -1), PROFILE_TYPE_INT); CProfile::update('web.auditlogs.filter.resourcetype', getRequest('resourcetype', -1), PROFILE_TYPE_INT); } elseif (hasRequest('filter_rst')) { DBStart(); CProfile::delete('web.auditlogs.filter.alias'); CProfile::delete('web.auditlogs.filter.action'); CProfile::delete('web.auditlogs.filter.resourcetype'); DBend(); } /* * Display */ $effectivePeriod = navigation_bar_calc('web.auditlogs.timeline', 0, true); $data = ['stime' => getRequest('stime'), 'actions' => [], 'action' => CProfile::get('web.auditlogs.filter.action', -1), 'resourcetype' => CProfile::get('web.auditlogs.filter.resourcetype', -1), 'alias' => CProfile::get('web.auditlogs.filter.alias', '')]; $from = zbxDateToTime($data['stime']); $till = $from + $effectivePeriod; // get audit
} $_REQUEST['hostid'] = $item['hostid']; $host = reset($item['hosts']); } else { $hosts = API::Host()->get(array('hostids' => $_REQUEST['hostid'], 'output' => array('status', 'flags'), 'templated_hosts' => true, 'editable' => true)); $host = reset($hosts); if (!$host) { access_deny(); } } /* * Ajax */ if (isset($_REQUEST['favobj'])) { if ($_REQUEST['favobj'] == 'filter') { CProfile::update('web.host_discovery.filter.state', $_REQUEST['favstate'], PROFILE_TYPE_INT); } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Actions */ if (isset($_REQUEST['add_delay_flex']) && isset($_REQUEST['new_delay_flex'])) { $timePeriodValidator = new CTimePeriodValidator(array('allowMultiple' => false)); $_REQUEST['delay_flex'] = get_request('delay_flex', array()); if ($timePeriodValidator->validate($_REQUEST['new_delay_flex']['period'])) { array_push($_REQUEST['delay_flex'], $_REQUEST['new_delay_flex']); unset($_REQUEST['new_delay_flex']);
function validate_group(&$PAGE_GROUPS, &$PAGE_HOSTS, $reset_host = true) { global $page; $config = select_config(); $dd_first_entry = $config['dropdown_first_entry']; $group_var = 'web.latest.groupid'; $host_var = 'web.latest.hostid'; $_REQUEST['groupid'] = get_request('groupid', CProfile::get($group_var, -1)); if ($_REQUEST['groupid'] < 0) { $PAGE_GROUPS['selected'] = $_REQUEST['groupid'] = 0; $PAGE_HOSTS['selected'] = $_REQUEST['hostid'] = 0; } if (!isset($_REQUEST['hostid']) || $reset_host) { $PAGE_HOSTS['selected'] = $_REQUEST['hostid'] = 0; } if ($PAGE_GROUPS['selected'] == 0 && $dd_first_entry == ZBX_DROPDOWN_FIRST_NONE) { $PAGE_GROUPS['groupids'] = array(); } $PAGE_GROUPS['selected'] = $_REQUEST['groupid']; if ($PAGE_GROUPS['original'] > -1) { CProfile::update('web.' . $page['menu'] . '.groupid', $_REQUEST['groupid'], PROFILE_TYPE_ID); } if ($PAGE_HOSTS['original'] > -1) { CProfile::update('web.' . $page['menu'] . '.hostid', $_REQUEST['hostid'], PROFILE_TYPE_ID); } CProfile::update($group_var, $_REQUEST['groupid'], PROFILE_TYPE_ID); CProfile::update($host_var, $_REQUEST['hostid'], PROFILE_TYPE_ID); }
* Permissions */ $dbGraph = API::Graph()->get(array('graphids' => $_REQUEST['graphid'], 'output' => API_OUTPUT_EXTEND, 'expandName' => 1)); // _ex($dbGraph,0); if (!$dbGraph) { access_deny(); } 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_Zabbix($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'];
$itemPrototype = []; if (hasRequest('itemid')) { $itemPrototype = API::ItemPrototype()->get(['itemids' => getRequest('itemid'), 'output' => ['itemid', 'type', 'snmp_community', 'snmp_oid', 'hostid', 'name', 'key_', 'delay', 'history', 'trends', 'status', 'value_type', 'trapper_hosts', 'units', 'multiplier', 'delta', 'snmpv3_securityname', 'snmpv3_securitylevel', 'snmpv3_authpassphrase', 'snmpv3_privpassphrase', 'formula', 'logtimefmt', 'templateid', 'valuemapid', 'delay_flex', 'params', 'ipmi_sensor', 'data_type', 'authtype', 'username', 'password', 'publickey', 'privatekey', 'interfaceid', 'port', 'description', 'snmpv3_authprotocol', 'snmpv3_privprotocol', 'snmpv3_contextname']]); $itemPrototype = reset($itemPrototype); } $data = getItemFormData($itemPrototype); $data['config'] = select_config(); // render view $itemView = new CView('configuration.item.prototype.edit', $data); $itemView->render(); $itemView->show(); } else { $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name')); $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP)); CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR); CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR); $config = select_config(); $data = ['form' => getRequest('form'), 'parent_discoveryid' => getRequest('parent_discoveryid'), 'hostid' => $discoveryRule['hostid'], 'sort' => $sortField, 'sortorder' => $sortOrder]; $data['items'] = API::ItemPrototype()->get(['discoveryids' => $data['parent_discoveryid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectApplications' => API_OUTPUT_EXTEND, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1]); foreach ($data['items'] as &$item) { if ($item['value_type'] == ITEM_VALUE_TYPE_STR || $item['value_type'] == ITEM_VALUE_TYPE_LOG || $item['value_type'] == ITEM_VALUE_TYPE_TEXT) { $item['trends'] = ''; } if ($item['type'] == ITEM_TYPE_TRAPPER || $item['type'] == ITEM_TYPE_SNMPTRAP) { $item['delay'] = ''; } } unset($item); $data['items'] = CMacrosResolverHelper::resolveItemNames($data['items']); order_result($data['items'], $sortField, $sortOrder); $url = (new CUrl('disc_prototypes.php'))->setArgument('parent_discoveryid', $data['parent_discoveryid']);
$isExportData = true; $page['type'] = detect_page_type(PAGE_TYPE_XML); $page['file'] = 'zbx_export_screens.xml'; } else { $isExportData = false; $page['type'] = detect_page_type(PAGE_TYPE_HTML); $page['title'] = _('Configuration of screens'); $page['file'] = 'screenconf.php'; $page['hist_arg'] = array('templateid'); } require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('screens' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'screenid' => array(T_ZBX_INT, O_NO, P_SYS, DB_ID, 'isset({form})&&{form}=="update"'), 'templateid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'name' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})', _('Name')), 'hsize' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 100), 'isset({save})', _('Columns')), 'vsize' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, 100), 'isset({save})', _('Rows')), 'go' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'clone' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null), 'rules' => array(T_ZBX_STR, O_OPT, null, DB_ID, null), 'import' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null)); check_fields($fields); validate_sort_and_sortorder('name', ZBX_SORT_UP); CProfile::update('web.screenconf.config', get_request('config', 0), PROFILE_TYPE_INT); $_REQUEST['go'] = get_request('go', 'none'); /* * Permissions */ if (isset($_REQUEST['screenid'])) { $options = array('screenids' => $_REQUEST['screenid'], 'editable' => true, 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND); if (isset($_REQUEST['templateid'])) { $screens = API::TemplateScreen()->get($options); } else { $screens = API::Screen()->get($options); } if (empty($screens)) { access_deny(); } }
echo '$("addrm_fav").title = "' . _('Remove from favourites') . '";' . "\n" . '$("addrm_fav").onclick = function() { rm4favorites("' . $_REQUEST['favobj'] . '", "' . $_REQUEST['favid'] . '", 0); }' . "\n"; } } elseif ($_REQUEST['favaction'] == 'remove') { $result = CFavorite::remove('web.favorite.screenids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Add to favourites') . '";' . "\n" . '$("addrm_fav").onclick = function() { add2favorites("' . $_REQUEST['favobj'] . '", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } if ($page['type'] == PAGE_TYPE_JS && $result) { echo 'switchElementsClass("addrm_fav", "iconminus", "iconplus");'; } } // saving fixed/dynamic setting to profile if ($_REQUEST['favobj'] == 'timelinefixedperiod') { if (isset($_REQUEST['favid'])) { CProfile::update('web.screens.timelinefixed', $_REQUEST['favid'], PROFILE_TYPE_INT); } } } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Display */ $data = array('fullscreen' => $_REQUEST['fullscreen'], 'period' => get_request('period'), 'stime' => get_request('stime'), 'elementid' => get_request('elementid', false), 'use_screen_name' => isset($_REQUEST['screenname'])); // if none is provided if (empty($data['elementid']) && !$data['use_screen_name']) { // get element id saved in profile from the last visit $data['elementid'] = CProfile::get('web.screens.elementid', null);
$hostinvent_wdgt->addPageHeader(_('HOST INVENTORIES')); // host details if ($_REQUEST['hostid'] > 0) { $hostinvent_wdgt->addItem(insert_host_inventory_form()); } else { $r_form = new CForm('get'); $r_form->addItem(array(_('Group'), SPACE, $pageFilter->getGroupsCB(true))); $hostinvent_wdgt->addHeader(_('Hosts'), $r_form); // HOST INVENTORY FILTER {{{ if (isset($_REQUEST['filter_set'])) { $_REQUEST['filter_field'] = get_request('filter_field'); $_REQUEST['filter_field_value'] = get_request('filter_field_value'); $_REQUEST['filter_exact'] = get_request('filter_exact'); CProfile::update('web.hostinventories.filter_field', $_REQUEST['filter_field'], PROFILE_TYPE_STR); CProfile::update('web.hostinventories.filter_field_value', $_REQUEST['filter_field_value'], PROFILE_TYPE_STR); CProfile::update('web.hostinventories.filter_exact', $_REQUEST['filter_exact'], PROFILE_TYPE_INT); } else { $_REQUEST['filter_field'] = CProfile::get('web.hostinventories.filter_field'); $_REQUEST['filter_field_value'] = CProfile::get('web.hostinventories.filter_field_value'); $_REQUEST['filter_exact'] = CProfile::get('web.hostinventories.filter_exact'); } $filter_table = new CTable('', 'filter'); // getting inventory fields to make a drop down $inventoryFields = getHostInventories(true); // 'true' means list should be ordered by title $inventoryFieldsComboBox = new CComboBox('filter_field', $_REQUEST['filter_field']); foreach ($inventoryFields as $inventoryField) { $inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title']); } $exactComboBox = new CComboBox('filter_exact', $_REQUEST['filter_exact']); $exactComboBox->addItem('0', _('like'));
} } if (get_request('show_events') != CProfile::get('web.tr_status.filter.show_events')) { $url = new CUrl(); $path = $url->getPath(); insert_js('cookie.eraseArray("' . $path . '")'); } //-- if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { CProfile::update('web.tr_status.filter.show_details', $_REQUEST['show_details'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.show_events', $_REQUEST['show_events'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.ack_status', $_REQUEST['ack_status'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.show_severity', $_REQUEST['show_severity'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.txt_select', $_REQUEST['txt_select'], PROFILE_TYPE_STR); CProfile::update('web.tr_status.filter.status_change', $_REQUEST['status_change'], PROFILE_TYPE_INT); CProfile::update('web.tr_status.filter.status_change_days', $_REQUEST['status_change_days'], PROFILE_TYPE_INT); } $show_triggers = $_REQUEST['show_triggers']; $show_events = $_REQUEST['show_events']; $show_severity = $_REQUEST['show_severity']; $ack_status = $_REQUEST['ack_status']; // -------------- validate_sort_and_sortorder('lastchange', ZBX_SORT_DOWN); $mute = CProfile::get('web.tr_status.mute', 0); if (isset($audio) && !$mute) { play_sound($audio); } $trigg_wdgt = new CWidget(); $r_form = new CForm(null, 'get'); $r_form->addItem(array(S_GROUP . SPACE, $pageFilter->getGroupsCB(true))); $r_form->addItem(array(SPACE . S_HOST . SPACE, $pageFilter->getHostsCB(true)));
$newExpression = triggerExpression($newTrigger, false); if (strcmp($oldExpression, $newExpression) == 0) { $_REQUEST['triggerid'] = $newTrigger['triggerid']; $_REQUEST['filter_set'] = 1; break; } } } } // -------- if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { CProfile::update('web.events.filter.triggerid', $_REQUEST['triggerid'], PROFILE_TYPE_ID); CProfile::update('web.events.filter.hide_unknown', $_REQUEST['hide_unknown'], PROFILE_TYPE_INT); } // -------------- CProfile::update('web.events.source', $source, PROFILE_TYPE_INT); $events_wdgt = new CWidget(); // PAGE HEADER {{{ $fs_icon = get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen'])); $events_wdgt->addPageHeader(array(S_HISTORY_OF_EVENTS_BIG . SPACE . S_ON_BIG . SPACE, zbx_date2str(S_EVENTS_DATE_FORMAT, time())), $fs_icon); // }}}PAGE HEADER // HEADER {{{ $r_form = new CForm(null, 'get'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $r_form->addVar('triggerid', get_request('triggerid')); $r_form->addVar('stime', get_request('stime')); $r_form->addVar('period', get_request('period')); if (EVENT_SOURCE_TRIGGERS == $source) { $options = array('groups' => array('monitored_hosts' => 1, 'with_items' => 1), 'hosts' => array('monitored_hosts' => 1, 'with_items' => 1), 'triggers' => array(), 'hostid' => get_request('hostid', null), 'groupid' => get_request('groupid', null), 'triggerid' => get_request('triggerid', null)); $pageFilter = new CPageFilter($options); $_REQUEST['groupid'] = $pageFilter->groupid;
CProfile::update('web.dashconf.groups.grpswitch', $_REQUEST['grpswitch'], PROFILE_TYPE_INT); if ($_REQUEST['grpswitch'] == 1) { $result = rm4favorites('web.dashconf.groups.groupids'); foreach ($groupids as $gnum => $groupid) { $result &= add2favorites('web.dashconf.groups.groupids', $groupid); } } // HOSTS $_REQUEST['maintenance'] = get_request('maintenance', 0); CProfile::update('web.dashconf.hosts.maintenance', $_REQUEST['maintenance'], PROFILE_TYPE_INT); // TRIGGERS $_REQUEST['trgSeverity'] = get_request('trgSeverity', array()); $trgSeverity = implode(';', array_keys($_REQUEST['trgSeverity'])); CProfile::update('web.dashconf.triggers.severity', $trgSeverity, PROFILE_TYPE_STR); $_REQUEST['extAck'] = get_request('extAck', 0); CProfile::update('web.dashconf.events.extAck', $_REQUEST['extAck'], PROFILE_TYPE_INT); } jsRedirect('dashboard.php'); } else { if (isset($_REQUEST['new_right'])) { $_REQUEST['groupids'] = get_request('groupids', array()); foreach ($_REQUEST['new_right'] as $id => $group) { $_REQUEST['groupids'][$id] = $id; } } else { if (isset($_REQUEST['delete'])) { $del_groups = get_request('del_groups', array()); foreach ($del_groups as $gnum => $groupid) { if (!isset($_REQUEST['groupids'][$groupid])) { continue; }
require_once dirname(__FILE__) . '/include/config.inc.php'; require_once dirname(__FILE__) . '/include/hosts.inc.php'; require_once dirname(__FILE__) . '/include/httptest.inc.php'; require_once dirname(__FILE__) . '/include/forms.inc.php'; $page['title'] = _('Configuration of web monitoring'); $page['file'] = 'httpconf.php'; $page['hist_arg'] = array('groupid', 'hostid'); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('applications' => array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'applicationid' => array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'close' => array(T_ZBX_INT, O_OPT, null, IN('1'), null), 'open' => array(T_ZBX_INT, O_OPT, null, IN('1'), null), 'groupid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'hostid' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, 'isset({form})||isset({save})'), 'httptestid' => array(T_ZBX_INT, O_NO, P_SYS, DB_ID, '(isset({form})&&({form}=="update"))'), 'application' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})', _('Application')), 'name' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})', _('Name')), 'delay' => array(T_ZBX_INT, O_OPT, null, BETWEEN(1, SEC_PER_DAY), 'isset({save})', _('Update interval (in sec)')), 'status' => array(T_ZBX_INT, O_OPT, null, IN('0,1'), 'isset({save})'), 'agent' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'macros' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})'), 'steps' => array(T_ZBX_STR, O_OPT, null, null, 'isset({save})', _('Steps')), 'authentication' => array(T_ZBX_INT, O_OPT, null, IN('0,1,2'), 'isset({save})'), 'http_user' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})&&isset({authentication})&&({authentication}==' . HTTPTEST_AUTH_BASIC . '||{authentication}==' . HTTPTEST_AUTH_NTLM . ')', _('User')), 'http_password' => array(T_ZBX_STR, O_OPT, null, NOT_EMPTY, 'isset({save})&&isset({authentication})&&({authentication}==' . HTTPTEST_AUTH_BASIC . '||{authentication}==' . HTTPTEST_AUTH_NTLM . ')', _('Password')), 'new_httpstep' => array(T_ZBX_STR, O_OPT, null, null, null), 'move_up' => array(T_ZBX_INT, O_OPT, P_ACT, BETWEEN(0, 65534), null), 'move_down' => array(T_ZBX_INT, O_OPT, P_ACT, BETWEEN(0, 65534), null), 'sel_step' => array(T_ZBX_INT, O_OPT, null, BETWEEN(0, 65534), null), 'group_httptestid' => array(T_ZBX_INT, O_OPT, null, DB_ID, null), 'showdisabled' => array(T_ZBX_INT, O_OPT, P_SYS, IN('0,1'), null), 'go' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'clone' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'save' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'delete' => array(T_ZBX_STR, O_OPT, P_SYS | P_ACT, null, null), 'cancel' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form' => array(T_ZBX_STR, O_OPT, P_SYS, null, null), 'form_refresh' => array(T_ZBX_INT, O_OPT, null, null, null)); $_REQUEST['showdisabled'] = get_request('showdisabled', CProfile::get('web.httpconf.showdisabled', 1)); $_REQUEST['status'] = isset($_REQUEST['status']) ? 0 : 1; check_fields($fields); validate_sort_and_sortorder('name', ZBX_SORT_UP); $showDisabled = get_request('showdisabled', 1); CProfile::update('web.httpconf.showdisabled', $showDisabled, PROFILE_TYPE_STR); if (!empty($_REQUEST['steps'])) { order_result($_REQUEST['steps'], 'no'); } /* * Permissions */ if (isset($_REQUEST['httptestid'])) { $dbHttpTest = DBfetch(DBselect('SELECT wt.*,a.name AS application' . ' FROM httptest wt,applications a' . ' WHERE a.applicationid=wt.applicationid' . ' AND wt.httptestid=' . get_request('httptestid'))); if (empty($dbHttpTest)) { access_deny(); } } if (isset($_REQUEST['go'])) { if (!isset($_REQUEST['group_httptestid']) || !is_array($_REQUEST['group_httptestid'])) { access_deny();
} /* * Filter */ if (isset($_REQUEST['filter_rst'])) { $_REQUEST['alias'] = ''; $_REQUEST['action'] = -1; $_REQUEST['resourcetype'] = -1; } $_REQUEST['alias'] = get_request('alias', CProfile::get('web.auditlogs.filter.alias', '')); $_REQUEST['action'] = get_request('action', CProfile::get('web.auditlogs.filter.action', -1)); $_REQUEST['resourcetype'] = get_request('resourcetype', CProfile::get('web.auditlogs.filter.resourcetype', -1)); if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { CProfile::update('web.auditlogs.filter.alias', $_REQUEST['alias'], PROFILE_TYPE_STR); CProfile::update('web.auditlogs.filter.action', $_REQUEST['action'], PROFILE_TYPE_INT); CProfile::update('web.auditlogs.filter.resourcetype', $_REQUEST['resourcetype'], PROFILE_TYPE_INT); } /* * Display */ $effectivePeriod = navigation_bar_calc('web.auditlogs.timeline', 0, true); $data = array('stime' => get_request('stime'), 'actions' => array(), 'action' => get_request('action'), 'resourcetype' => get_request('resourcetype'), 'alias' => get_request('alias')); $from = zbxDateToTime($data['stime']); $till = $from + $effectivePeriod; // get audit $sqlWhere = array(); if (!empty($data['alias'])) { $sqlWhere['alias'] = ' AND u.alias=' . zbx_dbstr($data['alias']); } if ($data['action'] > -1) { $sqlWhere['action'] = ' AND a.action=' . $data['action'] . ' ';
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)); $graph->setYMaxItemId(getRequest('ymax_itemid', 0));
*/ if (hasRequest('filterState')) { CProfile::update('web.hostscreen.filter.state', getRequest('filterState'), PROFILE_TYPE_INT); } if (getRequest('favobj') === 'timeline' && hasRequest('elementid') && hasRequest('period')) { navigation_bar_calc('web.hostscreen', getRequest('elementid'), true); } if ($page['type'] == PAGE_TYPE_JS || $page['type'] == PAGE_TYPE_HTML_BLOCK) { require_once dirname(__FILE__) . '/include/page_footer.php'; exit; } /* * Display */ $data = array('hostid' => getRequest('hostid', 0), 'fullscreen' => $_REQUEST['fullscreen'], 'screenid' => getRequest('screenid', CProfile::get('web.hostscreen.screenid', null)), 'period' => getRequest('period'), 'stime' => getRequest('stime')); CProfile::update('web.hostscreen.screenid', $data['screenid'], PROFILE_TYPE_ID); // get screen list $data['screens'] = API::TemplateScreen()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND)); $data['screens'] = zbx_toHash($data['screens'], 'screenid'); order_result($data['screens'], 'name'); // get screen $screenid = null; if (!empty($data['screens'])) { $screen = !isset($data['screens'][$data['screenid']]) ? reset($data['screens']) : $data['screens'][$data['screenid']]; if (!empty($screen['screenid'])) { $screenid = $screen['screenid']; } } $data['screen'] = API::TemplateScreen()->get(array('screenids' => $screenid, 'hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND, 'selectScreenItems' => API_OUTPUT_EXTEND)); $data['screen'] = reset($data['screen']); // get host
** You should have received a copy of the GNU General Public License ** along with this program; if not, write to the Free Software ** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. **/ require_once dirname(__FILE__) . '/include/config.inc.php'; require_once dirname(__FILE__) . '/include/items.inc.php'; $page['title'] = _('Queue'); $page['file'] = 'queue.php'; define('ZBX_PAGE_DO_REFRESH', 1); require_once dirname(__FILE__) . '/include/page_header.php'; $queueModes = [QUEUE_OVERVIEW, QUEUE_OVERVIEW_BY_PROXY, QUEUE_DETAILS]; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = ['config' => [T_ZBX_INT, O_OPT, P_SYS, IN($queueModes), null]]; check_fields($fields); $config = getRequest('config', CProfile::get('web.queue.config', 0)); CProfile::update('web.queue.config', $config, PROFILE_TYPE_INT); // fetch data $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, ZBX_SOCKET_BYTES_LIMIT); $queueRequests = [QUEUE_OVERVIEW => CZabbixServer::QUEUE_OVERVIEW, QUEUE_OVERVIEW_BY_PROXY => CZabbixServer::QUEUE_OVERVIEW_BY_PROXY, QUEUE_DETAILS => CZabbixServer::QUEUE_DETAILS]; $queueData = $zabbixServer->getQueue($queueRequests[$config], get_cookie('zbx_sessionid')); // check for errors error if ($zabbixServer->getError()) { error($zabbixServer->getError()); show_error_message(_('Cannot display item queue.')); require_once dirname(__FILE__) . '/include/page_footer.php'; } $widget = (new CWidget())->setTitle(_('Queue of items to be updated'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem((new CComboBox('config', $config, 'submit();'))->addItem(QUEUE_OVERVIEW, _('Overview'))->addItem(QUEUE_OVERVIEW_BY_PROXY, _('Overview by proxy'))->addItem(QUEUE_DETAILS, _('Details'))))); $table = new CTableInfo(); $severityConfig = select_config(); // overview if ($config == QUEUE_OVERVIEW) {
if (getRequest('graphid')) { $graphs = API::Graph()->get(array('graphids' => array($_REQUEST['graphid']), 'output' => array('graphid'))); if (!$graphs) { access_deny(); } } $pageFilter = new CPageFilter(array('groups' => array('real_hosts' => true, 'with_graphs' => true), 'hosts' => array('with_graphs' => true), 'groupid' => getRequest('groupid'), 'hostid' => getRequest('hostid'), 'graphs' => array('templated' => 0), 'graphid' => getRequest('graphid'))); /* * Ajax */ if (hasRequest('filterState')) { CProfile::update('web.charts.filter.state', getRequest('filterState'), PROFILE_TYPE_INT); } if (isset($_REQUEST['favobj'])) { if (getRequest('favobj') === 'timelinefixedperiod' && hasRequest('favid')) { CProfile::update('web.screens.timelinefixed', getRequest('favid'), PROFILE_TYPE_INT); } if (str_in_array($_REQUEST['favobj'], array('itemid', 'graphid'))) { $result = false; DBstart(); if ($_REQUEST['favaction'] == 'add') { $result = CFavorite::add('web.favorite.graphids', $_REQUEST['favid'], $_REQUEST['favobj']); if ($result) { echo '$("addrm_fav").title = "' . _('Remove from favourites') . '";' . "\n"; echo '$("addrm_fav").onclick = function() { rm4favorites("graphid", "' . $_REQUEST['favid'] . '"); }' . "\n"; } } 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";
} // view generation $hostinventoriesView = new CView('inventory.host.view', $data); $hostinventoriesView->render(); $hostinventoriesView->show(); } else { $data = ['config' => select_config(), 'hosts' => [], 'sort' => $sortField, 'sortorder' => $sortOrder]; // filter $data['pageFilter'] = new CPageFilter(['groups' => ['real_hosts' => true], 'groupid' => getRequest('groupid')]); /* * Filter */ if (hasRequest('filter_set')) { CProfile::update('web.hostinventories.filter_field', getRequest('filter_field', ''), PROFILE_TYPE_STR); CProfile::update('web.hostinventories.filter_field_value', getRequest('filter_field_value', ''), PROFILE_TYPE_STR); CProfile::update('web.hostinventories.filter_exact', getRequest('filter_exact', 0), PROFILE_TYPE_INT); } elseif (hasRequest('filter_rst')) { DBStart(); CProfile::delete('web.hostinventories.filter_field'); CProfile::delete('web.hostinventories.filter_field_value'); CProfile::delete('web.hostinventories.filter_exact'); DBend(); } $data['filterField'] = CProfile::get('web.hostinventories.filter_field', ''); $data['filterFieldValue'] = CProfile::get('web.hostinventories.filter_field_value', ''); $data['filterExact'] = CProfile::get('web.hostinventories.filter_exact', 0); if ($data['pageFilter']->groupsSelected) { // which inventory fields we will need for displaying $requiredInventoryFields = ['name', 'type', 'os', 'serialno_a', 'tag', 'macaddress_a']; // checking if correct inventory field is specified for filter $possibleInventoryFields = getHostInventories();