protected function doAction() { $data = ['sid' => $this->getUserSID(), 'eventids' => $this->getInput('eventids'), 'message' => $this->getInput('message', ''), 'acknowledge_type' => $this->getInput('acknowledge_type', ZBX_ACKNOWLEDGE_SELECTED), 'backurl' => $this->getInput('backurl', 'tr_status.php'), 'unack_problem_events_count' => 0, 'unack_events_count' => 0]; if (count($this->getInput('eventids')) == 1) { $events = API::Event()->get(['output' => [], 'eventids' => $this->getInput('eventids'), 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'select_acknowledges' => ['clock', 'message', 'alias', 'name', 'surname']]); if ($events) { $data['event'] = ['acknowledges' => $events[0]['acknowledges']]; order_result($data['acknowledges'], 'clock', ZBX_SORT_DOWN); } } $events = API::Event()->get(['output' => ['objectid', 'acknowledged', 'value'], 'eventids' => $this->getInput('eventids'), 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER]); $triggerids = []; foreach ($events as $event) { if ($event['acknowledged'] == EVENT_ACKNOWLEDGED) { $data['unack_problem_events_count']++; $data['unack_events_count']++; } elseif ($event['value'] == TRIGGER_VALUE_FALSE) { $data['unack_problem_events_count']++; } $triggerids[$event['objectid']] = true; } $triggerids = array_keys($triggerids); $data['unack_problem_events_count'] += API::Event()->get(['countOutput' => true, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $triggerids, 'filter' => ['acknowledged' => EVENT_NOT_ACKNOWLEDGED, 'value' => TRIGGER_VALUE_TRUE]]); $data['unack_events_count'] += API::Event()->get(['countOutput' => true, 'source' => EVENT_SOURCE_TRIGGERS, 'object' => EVENT_OBJECT_TRIGGER, 'objectids' => $triggerids, 'filter' => ['acknowledged' => EVENT_NOT_ACKNOWLEDGED]]); $response = new CControllerResponseData($data); $response->setTitle(_('Alarm acknowledgements')); $this->setResponse($response); }
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); }
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); }
protected function doAction() { // no data is passed to the view $response = new CControllerResponseData([]); $response->setTitle(_('Status of Zabbix')); $this->setResponse($response); }
protected function doAction() { $show_discovery_widget = $this->getUserType() >= USER_TYPE_ZABBIX_ADMIN && (bool) API::DRule()->get(['output' => [], 'filter' => ['status' => DRULE_STATUS_ACTIVE], 'limit' => 1]); $data = ['fullscreen' => $this->getInput('fullscreen', 0), 'filter_enabled' => CProfile::get('web.dashconf.filter.enable', 0), 'favourite_graphs' => getFavouriteGraphs(), 'favourite_maps' => getFavouriteMaps(), 'favourite_screens' => getFavouriteScreens(), 'show_status_widget' => $this->getUserType() == USER_TYPE_SUPER_ADMIN, 'show_discovery_widget' => $show_discovery_widget]; $response = new CControllerResponseData($data); $response->setTitle(_('Dashboard')); $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); }
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() { // default values $data = ['sid' => $this->getUserSID(), 'scriptid' => 0, 'name' => '', 'type' => ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT, 'execute_on' => ZBX_SCRIPT_EXECUTE_ON_AGENT, 'command' => '', 'commandipmi' => '', 'description' => '', 'usrgrpid' => 0, 'groupid' => 0, 'host_access' => 0, 'confirmation' => '', 'enable_confirmation' => 0, 'hgstype' => 0]; // get values from the dabatase if ($this->hasInput('scriptid')) { $scripts = API::Script()->get(['output' => ['scriptid', 'name', 'type', 'execute_on', 'command', 'description', 'usrgrpid', 'groupid', 'host_access', 'confirmation'], 'scriptids' => $this->getInput('scriptid')]); $script = $scripts[0]; $data['scriptid'] = $script['scriptid']; $data['name'] = $script['name']; $data['type'] = $script['type']; $data['execute_on'] = $script['execute_on']; $data['command'] = $script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT ? $script['command'] : ''; $data['commandipmi'] = $script['type'] == ZBX_SCRIPT_TYPE_IPMI ? $script['command'] : ''; $data['description'] = $script['description']; $data['usrgrpid'] = $script['usrgrpid']; $data['groupid'] = $script['groupid']; $data['host_access'] = $script['host_access']; $data['confirmation'] = $script['confirmation']; $data['enable_confirmation'] = $script['confirmation'] !== ''; $data['hgstype'] = $script['groupid'] != 0 ? 1 : 0; } // overwrite with input variables $this->getInputs($data, ['name', 'type', 'execute_on', 'command', 'commandipmi', 'description', 'usrgrpid', 'groupid', 'host_access', 'confirmation', 'enable_confirmation', 'hgstype']); // get host group if ($data['groupid'] == 0) { $data['hostgroup'] = null; } else { $hostgroups = API::HostGroup()->get(['groupids' => [$data['groupid']], 'output' => ['groupid', 'name']]); $hostgroup = $hostgroups[0]; $data['hostgroup'][] = ['id' => $hostgroup['groupid'], 'name' => $hostgroup['name']]; } // get list of user groups $usergroups = API::UserGroup()->get(['output' => ['usrgrpid', 'name']]); order_result($usergroups, 'name'); $data['usergroups'] = $usergroups; $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of scripts')); $this->setResponse($response); }
protected function doAction() { // default values $data = ['fullscreen' => $this->getInput('fullscreen', 0), 'period' => $this->getInput('period', 'yearly'), 'service' => $this->service, 'year' => $this->getInput('year', date('Y')), 'YEAR_LEFT_SHIFT' => self::YEAR_LEFT_SHIFT]; switch ($data['period']) { case 'yearly': $from = date('Y') - self::YEAR_LEFT_SHIFT; $to = date('Y'); function get_time($year, $y) { return mktime(0, 0, 0, 1, 1, $y); } break; case 'monthly': $from = 1; $to = 12; function get_time($year, $m) { return mktime(0, 0, 0, $m, 1, $year); } break; case 'weekly': $from = 0; $to = 52; function get_time($year, $w) { $time = mktime(0, 0, 0, 1, 1, $year); $wd = date('w', $time); $wd = $wd == 0 ? 6 : $wd - 1; $beg = $time - $wd * SEC_PER_DAY; return strtotime("+{$w} week", $beg); } break; case 'daily': $from = 1; $to = DAY_IN_YEAR; function get_time($year, $d) { return mktime(0, 0, 0, 1, $d, $year); } break; } $now = time(); $intervals = []; for ($t = $from; $t <= $to; $t++) { if (($start = get_time($data['year'], $t)) > $now) { break; } if (($end = get_time($data['year'], $t + 1)) > $now) { $end = $now; } $intervals[] = ['from' => $start, 'to' => $end]; } $sla = API::Service()->getSla(['serviceids' => [$this->service['serviceid']], 'intervals' => $intervals]); $data['sla'] = reset($sla); $response = new CControllerResponseData($data); $response->setTitle(_('IT services availability report')); $this->setResponse($response); }
protected function doAction() { // default values $data = ['sid' => $this->getUserSID(), 'proxyid' => 0, 'host' => '', 'status' => HOST_STATUS_PROXY_ACTIVE, 'dns' => 'localhost', 'ip' => '127.0.0.1', 'useip' => '1', 'port' => '10051', 'proxy_hostids' => [], 'description' => '', 'tls_accept' => HOST_ENCRYPTION_NONE, 'tls_connect' => HOST_ENCRYPTION_NONE, 'tls_issuer' => '', 'tls_psk' => '', 'tls_psk_identity' => '', 'tls_subject' => '', 'form_refresh' => 0]; // get values from the dabatase if ($this->hasInput('proxyid')) { $data['proxyid'] = $this->getInput('proxyid'); $proxies = API::Proxy()->get(['output' => ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk'], 'selectHosts' => ['hostid'], 'selectInterface' => ['interfaceid', 'dns', 'ip', 'useip', 'port'], 'proxyids' => $data['proxyid']]); $proxy = $proxies[0]; $data['host'] = $proxy['host']; $data['status'] = $proxy['status']; $data['tls_accept'] = $proxy['tls_accept']; $data['tls_connect'] = $proxy['tls_connect']; $data['tls_issuer'] = $proxy['tls_issuer']; $data['tls_psk'] = $proxy['tls_psk']; $data['tls_psk_identity'] = $proxy['tls_psk_identity']; $data['tls_subject'] = $proxy['tls_subject']; if ($data['status'] == HOST_STATUS_PROXY_PASSIVE) { $data['interfaceid'] = $proxy['interface']['interfaceid']; $data['dns'] = $proxy['interface']['dns']; $data['ip'] = $proxy['interface']['ip']; $data['useip'] = $proxy['interface']['useip']; $data['port'] = $proxy['interface']['port']; } $data['proxy_hostids'] = zbx_objectValues($proxy['hosts'], 'hostid'); $data['description'] = $proxy['description']; } // overwrite with input variables $data['host'] = $this->getInput('host', $data['host']); $data['status'] = $this->getInput('status', $data['status']); $data['dns'] = $this->getInput('dns', $data['dns']); $data['ip'] = $this->getInput('ip', $data['ip']); $data['useip'] = $this->getInput('useip', $data['useip']); $data['port'] = $this->getInput('port', $data['port']); $data['proxy_hostids'] = $this->getInput('proxy_hostids', $data['proxy_hostids']); $data['description'] = $this->getInput('description', $data['description']); $data['tls_accept'] = $this->getInput('tls_accept', $data['tls_accept']); $data['tls_connect'] = $this->getInput('tls_connect', $data['tls_connect']); $data['tls_issuer'] = $this->getInput('tls_issuer', $data['tls_issuer']); $data['tls_psk'] = $this->getInput('tls_psk', $data['tls_psk']); $data['tls_psk_identity'] = $this->getInput('tls_psk_identity', $data['tls_psk_identity']); $data['tls_subject'] = $this->getInput('tls_subject', $data['tls_subject']); $data['form_refresh'] = $this->getInput('form_refresh', $data['form_refresh']); if ($data['status'] == HOST_STATUS_PROXY_PASSIVE && $this->hasInput('interfaceid')) { $data['interfaceid'] = $this->getInput('interfaceid'); } // fetch available hosts, skip host prototypes $data['all_hosts'] = DBfetchArray(DBselect('SELECT h.hostid,h.proxy_hostid,h.name,h.flags' . ' FROM hosts h' . ' WHERE h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND h.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE)); order_result($data['all_hosts'], 'name'); $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of proxies')); $this->setResponse($response); }
protected function doAction() { // default values $data = ['sid' => $this->getUserSID(), 'mediatypeid' => 0, 'type' => MEDIA_TYPE_EMAIL, 'description' => '', 'smtp_server' => 'localhost', 'smtp_port' => '25', 'smtp_helo' => 'localhost', 'smtp_email' => 'zabbix@localhost', 'smtp_security' => '0', 'smtp_verify_peer' => '0', 'smtp_verify_host' => '0', 'smtp_authentication' => '0', 'exec_params' => [], 'exec_params_count' => '0', 'exec_path' => '', 'gsm_modem' => '/dev/ttyS0', 'jabber_username' => 'user@server', 'eztext_username' => '', 'eztext_limit' => EZ_TEXTING_LIMIT_USA, 'smtp_username' => '', 'passwd' => '', 'status' => MEDIA_TYPE_STATUS_ACTIVE]; // get values from the dabatase if ($this->hasInput('mediatypeid')) { $data['mediatypeid'] = $this->mediatype['mediatypeid']; $data['type'] = $this->mediatype['type']; $data['description'] = $this->mediatype['description']; $data['smtp_server'] = $this->mediatype['smtp_server']; $data['smtp_port'] = $this->mediatype['smtp_port']; $data['smtp_helo'] = $this->mediatype['smtp_helo']; $data['smtp_email'] = $this->mediatype['smtp_email']; $data['smtp_security'] = $this->mediatype['smtp_security']; $data['smtp_verify_peer'] = $this->mediatype['smtp_verify_peer']; $data['smtp_verify_host'] = $this->mediatype['smtp_verify_host']; $data['smtp_authentication'] = $this->mediatype['smtp_authentication']; $data['exec_path'] = $this->mediatype['exec_path']; $this->mediatype['exec_params'] = explode("\n", $this->mediatype['exec_params']); foreach ($this->mediatype['exec_params'] as $exec_param) { $data['exec_params'][] = ['exec_param' => $exec_param]; } // Remove last empty new line param. array_pop($data['exec_params']); $data['exec_params_count'] = count($data['exec_params']); $data['gsm_modem'] = $this->mediatype['gsm_modem']; $data['passwd'] = $this->mediatype['passwd']; $data['status'] = $this->mediatype['status']; switch ($data['type']) { case MEDIA_TYPE_EMAIL: $data['smtp_username'] = $this->mediatype['username']; break; case MEDIA_TYPE_JABBER: $data['jabber_username'] = $this->mediatype['username']; break; case MEDIA_TYPE_EZ_TEXTING: $data['eztext_username'] = $this->mediatype['username']; $data['eztext_limit'] = $this->mediatype['exec_path']; break; } } // overwrite with input variables $this->getInputs($data, ['type', 'description', 'smtp_server', 'smtp_port', 'smtp_helo', 'smtp_email', 'smtp_security', 'smtp_verify_peer', 'smtp_verify_host', 'smtp_authentication', 'exec_params', 'exec_params_count', 'exec_path', 'eztext_limit', 'gsm_modem', 'jabber_username', 'eztext_username', 'smtp_username', 'passwd', 'status']); $response = new CControllerResponseData($data); $response->setTitle(_('Configuration of media types')); $this->setResponse($response); }
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); }