} else { $data['pageFilter'] = $pageFilter; $data['showDisabled'] = $showDisabled; $data['showAllApps'] = $showAllApps; $data['db_apps'] = array(); $db_app_result = DBselect('SELECT DISTINCT h.name AS hostname,a.*' . ' FROM applications a,hosts h' . ' WHERE a.hostid=h.hostid' . ($data['hostid'] > 0 ? ' AND h.hostid=' . $data['hostid'] : '') . ' AND ' . dbConditionInt('h.hostid', $pageFilter->hostsSelected ? array_keys($pageFilter->hosts) : array())); while ($db_app = DBfetch($db_app_result)) { $db_app['scenarios_cnt'] = 0; $data['db_apps'][$db_app['applicationid']] = $db_app; } // get http tests $data['db_httptests'] = array(); $dbHttpTests_result = DBselect('SELECT wt.*,a.name AS application,h.name AS hostname,h.hostid' . ' FROM httptest wt,applications a,hosts h' . ' WHERE wt.applicationid=a.applicationid' . ' AND a.hostid=h.hostid' . ' AND ' . dbConditionInt('a.applicationid', array_keys($data['db_apps'])) . ($showDisabled == 0 ? ' AND wt.status=' . HTTPTEST_STATUS_ACTIVE : '')); while ($httptest_data = DBfetch($dbHttpTests_result)) { $data['db_apps'][$httptest_data['applicationid']]['scenarios_cnt']++; $httptest_data['step_count'] = null; $data['db_httptests'][$httptest_data['httptestid']] = $httptest_data; } // get http steps $httpstep_res = DBselect('SELECT hs.httptestid,COUNT(hs.httpstepid) AS cnt' . ' FROM httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', array_keys($data['db_httptests'])) . ' GROUP BY hs.httptestid'); while ($step_count = DBfetch($httpstep_res)) { $data['db_httptests'][$step_count['httptestid']]['step_count'] = $step_count['cnt']; } order_result($data['db_httptests'], getPageSortField('host'), getPageSortOrder()); $data['paging'] = getPagingLine($data['db_httptests']); // render view $httpView = new CView('configuration.httpconf.list', $data); $httpView->render(); $httpView->show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
if ($data['copy_type'] == 0) { if (empty($data['copy_groupid'])) { foreach ($data['groups'] as $group) { $data['copy_groupid'] = $group['groupid']; } } $data['hosts'] = API::Host()->get(array('output' => API_OUTPUT_EXTEND, 'groupids' => $data['copy_groupid'], 'templated_hosts' => true)); order_result($data['hosts'], 'name'); } } // render view $itemView = new CView('configuration.item.copy', $data); $itemView->render(); $itemView->show(); } else { $data = array('form' => get_request('form', null), 'sortfield' => getPageSortField('name')); if (isset($hostid)) { $data['form_hostid'] = get_request('form_hostid', $hostid); $data['hostid'] = $hostid; } // items $options = array('search' => array(), 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'selectTriggers' => API_OUTPUT_REFER, 'selectApplications' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectItemDiscovery' => array('ts_delete'), 'sortfield' => $data['sortfield'], 'limit' => $config['search_limit'] + 1); $preFilter = count($options, COUNT_RECURSIVE); if (!empty($data['hostid'])) { $options['hostids'] = $hostid; } if (isset($_REQUEST['filter_group']) && !zbx_empty($_REQUEST['filter_group'])) { $options['group'] = $_REQUEST['filter_group']; } if (isset($_REQUEST['filter_hostname']) && !zbx_empty($_REQUEST['filter_hostname'])) { $options['name'] = $_REQUEST['filter_hostname'];
/** * Get the sort and sort order parameters for the current page and save it into profiles. * * @param string $sort * @param string $sortorder * * @retur void */ function validate_sort_and_sortorder($sort = null, $sortorder = ZBX_SORT_UP) { global $page; $_REQUEST['sort'] = getPageSortField($sort); $_REQUEST['sortorder'] = getPageSortOrder($sortorder); if (!is_null($_REQUEST['sort'])) { $_REQUEST['sort'] = preg_replace('/[^a-z\\.\\_]/i', '', $_REQUEST['sort']); CProfile::update('web.' . $page['file'] . '.sort', $_REQUEST['sort'], PROFILE_TYPE_STR); } if (!str_in_array($_REQUEST['sortorder'], array(ZBX_SORT_DOWN, ZBX_SORT_UP))) { $_REQUEST['sortorder'] = ZBX_SORT_UP; } CProfile::update('web.' . $page['file'] . '.sortorder', $_REQUEST['sortorder'], PROFILE_TYPE_STR); }
$db_slides = DBselect('SELECT s.* FROM slides s WHERE s.slideshowid=' . zbx_dbstr($data['slideshowid']) . ' ORDER BY s.step'); while ($slide = DBfetch($db_slides)) { $data['slides'][$slide['step']] = array('slideid' => $slide['slideid'], 'screenid' => $slide['screenid'], 'delay' => $slide['delay']); } } // get slides without delay $data['slides_without_delay'] = $data['slides']; for ($i = 0, $size = count($data['slides_without_delay']); $i < $size; $i++) { unset($data['slides_without_delay'][$i]['delay']); } // render view $slideshowView = new CView('configuration.slideconf.edit', $data); $slideshowView->render(); $slideshowView->show(); } else { $data['slides'] = DBfetchArray(DBselect('SELECT s.slideshowid,s.name,s.delay,COUNT(sl.slideshowid) AS cnt' . ' FROM slideshows s' . ' LEFT JOIN slides sl ON sl.slideshowid=s.slideshowid' . whereDbNode('s.slideshowid') . ' GROUP BY s.slideshowid,s.name,s.delay')); order_result($data['slides'], getPageSortField('name'), getPageSortOrder()); $data['paging'] = getPagingLine($data['slides'], array('slideshowid')); // nodes if ($data['displayNodes'] = is_array(get_current_nodeid())) { foreach ($data['slides'] as &$slide) { $slide['nodename'] = get_node_name_by_elid($slide['slideshowid'], true); } unset($slide); } // render view $slideshowView = new CView('configuration.slideconf.list', $data); $slideshowView->render(); $slideshowView->show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
foreach ($data['drule']['dchecks'] as $id => $dcheck) { $data['drule']['dchecks'][$id]['name'] = discovery_check2str($dcheck['type'], isset($dcheck['key_']) ? $dcheck['key_'] : '', isset($dcheck['ports']) ? $dcheck['ports'] : ''); } order_result($data['drule']['dchecks'], 'name'); } // get proxies $data['proxies'] = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND)); order_result($data['proxies'], 'host'); // render view $discoveryView = new CView('configuration.discovery.edit', $data); $discoveryView->render(); $discoveryView->show(); } else { $data = array(); // get drules $data['drules'] = API::DRule()->get(array('output' => API_OUTPUT_EXTEND, 'sortfield' => getPageSortField('name'), 'selectDChecks' => API_OUTPUT_EXTEND, 'editable' => true)); if (!empty($data['drules'])) { foreach ($data['drules'] as $druleid => $drule) { // checks $checks = array(); foreach ($drule['dchecks'] as $check) { $checks[$check['type']] = discovery_check_type2str($check['type']); } order_result($checks); $data['drules'][$druleid]['checks'] = $checks; // description $data['drules'][$druleid]['description'] = array(); if (!empty($drule['proxy_hostid'])) { $proxy = get_host_by_hostid($drule['proxy_hostid']); array_push($data['drules'][$druleid]['description'], $proxy['host'] . NAME_DELIMITER); }
show_messages($goResult, _('Discovery rules deleted'), _('Cannot delete discovery rules')); clearCookies($goResult, $_REQUEST['hostid']); } /* * Display */ if (isset($_REQUEST['form'])) { $data = getItemFormData(array('is_discovery_rule' => true)); $data['page_header'] = _('CONFIGURATION OF DISCOVERY RULES'); // render view $itemView = new CView('configuration.item.edit', $data); $itemView->render(); $itemView->show(); } else { $data = array('hostid' => get_request('hostid', 0), 'host' => $host, 'showErrorColumn' => $host['status'] != HOST_STATUS_TEMPLATE); $sortfield = getPageSortField('name'); // discoveries $data['discoveries'] = API::DiscoveryRule()->get(array('hostids' => $data['hostid'], 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectItems' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectHostPrototypes' => API_OUTPUT_COUNT, 'sortfield' => $sortfield, 'limit' => $config['search_limit'] + 1)); $data['discoveries'] = CMacrosResolverHelper::resolveItemNames($data['discoveries']); if ($sortfield === 'status') { orderItemsByStatus($data['discoveries'], getPageSortOrder()); } else { order_result($data['discoveries'], $sortfield, getPageSortOrder()); } // paging $data['paging'] = getPagingLine($data['discoveries'], array('itemid'), array('hostid' => get_request('hostid'))); // render view $discoveryView = new CView('configuration.host.discovery.list', $data); $discoveryView->render(); $discoveryView->show(); }
function get_history_of_actions($limit, &$last_clock = null, $sql_cond = '') { validate_sort_and_sortorder('clock', ZBX_SORT_DOWN); $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array()); $alerts = array(); $clock = array(); $table = new CTableInfo(S_NO_ACTIONS_FOUND); $table->setHeader(array(is_show_all_nodes() ? make_sorting_header(S_NODES, 'a.alertid') : null, make_sorting_header(S_TIME, 'clock'), make_sorting_header(S_TYPE, 'description'), make_sorting_header(S_STATUS, 'status'), make_sorting_header(S_RETRIES_LEFT, 'retries'), make_sorting_header(S_RECIPIENTS, 'sendto'), S_MESSAGE, S_ERROR)); $sql = 'SELECT a.alertid,a.clock,mt.description,a.sendto,a.subject,a.message,a.status,a.retries,a.error ' . ' FROM events e, alerts a ' . ' LEFT JOIN media_type mt ON mt.mediatypeid=a.mediatypeid ' . ' WHERE e.eventid = a.eventid ' . ' AND alerttype IN (' . ALERT_TYPE_MESSAGE . ') ' . $sql_cond . ' AND ' . DBcondition('e.objectid', $available_triggers) . ' AND ' . DBin_node('a.alertid') . ' ORDER BY a.clock DESC'; $result = DBselect($sql, $limit); while ($row = DBfetch($result)) { $alerts[] = $row; $clock[] = $row['clock']; } $last_clock = !empty($clock) ? min($clock) : null; $sortfield = getPageSortField('clock'); $sortorder = getPageSortOrder(); order_result($alerts, $sortfield, $sortorder); foreach ($alerts as $num => $row) { $time = zbx_date2str(S_HISTORY_OF_ACTIONS_DATE_FORMAT, $row['clock']); if ($row['status'] == ALERT_STATUS_SENT) { $status = new CSpan(S_SENT, 'green'); $retries = new CSpan(SPACE, 'green'); } else { if ($row['status'] == ALERT_STATUS_NOT_SENT) { $status = new CSpan(S_IN_PROGRESS, 'orange'); $retries = new CSpan(ALERT_MAX_RETRIES - $row['retries'], 'orange'); } else { $status = new CSpan(S_NOT_SENT, 'red'); $retries = new CSpan(0, 'red'); } } $sendto = $row['sendto']; $message = array(bold(S_SUBJECT . ': '), br(), $row['subject'], br(), br(), bold(S_MESSAGE . ': '), br(), $row['message']); if (empty($row['error'])) { $error = new CSpan(SPACE, 'off'); } else { $error = new CSpan($row['error'], 'on'); } $table->addRow(array(get_node_name_by_elid($row['alertid']), new CCol($time, 'top'), new CCol($row['description'], 'top'), new CCol($status, 'top'), new CCol($retries, 'top'), new CCol($sendto, 'top'), new CCol($message, 'top'), new CCol($error, 'wraptext top'))); } return $table; }
$cmbDRules->addItem(0, S_ALL_SMALL); $options = array('filter' => array('status' => DRULE_STATUS_ACTIVE), 'output' => API_OUTPUT_EXTEND); $drules = CDRule::get($options); order_result($drules, 'name'); foreach ($drules as $dnum => $drule) { $cmbDRules->addItem($drule['druleid'], get_node_name_by_elid($drule['druleid'], null, ': ') . $drule['name']); } $r_form->addVar('fullscreen', $fullscreen); $r_form->addItem(array(S_DISCOVERY_RULE . SPACE, $cmbDRules)); // $dscvry_wdgt->addHeader(array(S_FOUND.': ',$numrows), $r_form); $numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $dscvry_wdgt->addHeader(S_DISCOVERY_RULES_BIG, $r_form); // $dscvry_wdgt->addHeader($numrows); //------------- $sortfield = getPageSortField('ip'); $sortorder = getPageSortOrder(); $options = array('selectHosts' => array('hostid', 'host', 'status'), 'output' => API_OUTPUT_EXTEND, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limitSelects' => 1); if ($druleid > 0) { $options['druleids'] = $druleid; } else { $options['druleids'] = zbx_objectValues($drules, 'druleid'); } $dservices = CDService::get($options); $gMacros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => 1)); $gMacros = zbx_toHash($gMacros, 'macro'); $services = array(); foreach ($dservices as $dsnum => $dservice) { $key_ = $dservice['key_']; if (!zbx_empty($key_)) { if (isset($gMacros[$key_])) {
if (empty($data['copy_groupid'])) { foreach ($data['groups'] as $group) { $data['copy_groupid'] = $group['groupid']; } } $data['hosts'] = API::Host()->get(array('output' => API_OUTPUT_EXTEND, 'groupids' => $data['copy_groupid'], 'templated_hosts' => true)); order_result($data['hosts'], 'name'); } } // render view $itemView = new CView('configuration.item.copy', $data); $itemView->render(); $itemView->show(); } else { $_REQUEST['hostid'] = empty($_REQUEST['filter_hostid']) ? null : $_REQUEST['filter_hostid']; $data = array('form' => get_request('form'), 'hostid' => get_request('hostid'), 'sortfield' => getPageSortField('name'), 'displayNodes' => is_array(get_current_nodeid()) && empty($_REQUEST['filter_groupid']) && empty($_REQUEST['filter_hostid'])); // items $options = array('hostids' => $data['hostid'], 'search' => array(), 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'selectTriggers' => API_OUTPUT_REFER, 'selectApplications' => API_OUTPUT_EXTEND, 'selectDiscoveryRule' => API_OUTPUT_EXTEND, 'selectItemDiscovery' => array('ts_delete'), 'sortfield' => $data['sortfield'], 'limit' => $config['search_limit'] + 1); $preFilter = count($options, COUNT_RECURSIVE); if (isset($_REQUEST['filter_groupid']) && !empty($_REQUEST['filter_groupid'])) { $options['groupids'] = $_REQUEST['filter_groupid']; } if (isset($_REQUEST['filter_hostid']) && !empty($_REQUEST['filter_hostid'])) { $data['filter_hostid'] = $_REQUEST['filter_hostid']; } if (isset($_REQUEST['filter_application']) && !zbx_empty($_REQUEST['filter_application'])) { $options['application'] = $_REQUEST['filter_application']; } if (isset($_REQUEST['filter_name']) && !zbx_empty($_REQUEST['filter_name'])) { $options['search']['name'] = $_REQUEST['filter_name']; }
// get media types $options = array('output' => API_OUTPUT_EXTEND, 'preservekeys' => 1, 'editable' => true, 'limit' => $config['search_limit'] + 1); $data['mediatypes'] = API::Mediatype()->get($options); // get media types used in actions $options = array('mediatypeids' => zbx_objectValues($data['mediatypes'], 'mediatypeid'), 'output' => array('actionid', 'name'), 'preservekeys' => 1); $actions = API::Action()->get($options); foreach ($data['mediatypes'] as $number => $mediatype) { $data['mediatypes'][$number]['listOfActions'] = array(); foreach ($actions as $actionid => $action) { if (!empty($action['mediatypeids'])) { foreach ($action['mediatypeids'] as $actionMediaTypeId) { if ($mediatype['mediatypeid'] == $actionMediaTypeId) { $data['mediatypes'][$number]['listOfActions'][$actionid] = array('actionid' => $actionid, 'name' => $action['name']); } } } } $data['mediatypes'][$number]['usedInActions'] = !isset($mediatype['listOfActions']); // allow sort by mediatype name $data['mediatypes'][$number]['typeid'] = $data['mediatypes'][$number]['type']; $data['mediatypes'][$number]['type'] = media_type2str($data['mediatypes'][$number]['type']); } // sort data order_result($data['mediatypes'], getPageSortField('description'), getPageSortOrder()); $data['paging'] = getPagingLine($data['mediatypes']); // render view $mediaTypeView = new CView('administration.mediatypes.list', $data); $mediaTypeView->render(); $mediaTypeView->show(); } require_once dirname(__FILE__) . '/include/page_footer.php';
*/ $data = array('fullscreen' => $_REQUEST['fullscreen'], 'druleid' => get_request('druleid', 0), 'sort' => get_request('sort'), 'sortorder' => get_request('sortorder'), 'services' => array(), 'drules' => array()); $data['pageFilter'] = new CPageFilter(array('drules' => array('filter' => array('status' => DRULE_STATUS_ACTIVE)), 'druleid' => get_request('druleid', null))); if ($data['pageFilter']->drulesSelected) { // discovery rules $options = array('filter' => array('status' => DRULE_STATUS_ACTIVE), 'selectDHosts' => API_OUTPUT_EXTEND, 'output' => API_OUTPUT_EXTEND); if ($data['pageFilter']->druleid > 0) { $options['druleids'] = $data['pageFilter']->druleid; // set selected discovery rule id } $data['drules'] = API::DRule()->get($options); if (!empty($data['drules'])) { order_result($data['drules'], 'name'); } // discovery services $options = array('selectHosts' => array('hostid', 'name', 'status'), 'output' => API_OUTPUT_EXTEND, 'sortfield' => getPageSortField('ip'), 'sortorder' => getPageSortOrder(), 'limitSelects' => 1); if (!empty($data['druleid'])) { $options['druleids'] = $data['druleid']; } else { $options['druleids'] = zbx_objectValues($data['drules'], 'druleid'); } $dservices = API::DService()->get($options); // user macros $data['macros'] = API::UserMacro()->get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => true)); $data['macros'] = zbx_toHash($data['macros'], 'macro'); // services $data['services'] = array(); foreach ($dservices as $dservice) { $key_ = $dservice['key_']; if (!zbx_empty($key_)) { if (isset($data['macros'][$key_])) {
$numrows = new CDiv(); $numrows->setAttribute('name', 'numrows'); $user_wdgt->addHeader(S_USERS_BIG, $form); $user_wdgt->addHeader($numrows); $form = new CForm(null, 'post'); $form->setName('users'); $table = new CTableInfo(S_NO_USERS_DEFINED); $table->setHeader(array(new CCheckBox('all_users', NULL, "checkAll('" . $form->getName() . "','all_users','group_userid');"), make_sorting_header(S_ALIAS, 'alias'), make_sorting_header(S_NAME, 'name'), make_sorting_header(S_SURNAME, 'surname'), make_sorting_header(S_USER_TYPE, 'type'), S_GROUPS, S_IS_ONLINE_Q, S_LOGIN, S_GUI_ACCESS, S_API_ACCESS, S_DEBUG_MODE, S_STATUS)); // User table $options = array('output' => API_OUTPUT_EXTEND, 'select_usrgrps' => API_OUTPUT_EXTEND, 'get_access' => 1, 'limit' => $config['search_limit'] + 1); if ($_REQUEST['filter_usrgrpid'] > 0) { $options['usrgrpids'] = $_REQUEST['filter_usrgrpid']; } $users = CUser::get($options); // sorting order_result($users, getPageSortField('alias'), getPageSortOrder()); $paging = getPagingLine($users); //--------- // set default lastaccess time to 0. foreach ($users as $unum => $user) { $usessions[$user['userid']] = array('lastaccess' => 0); } $userids = zbx_objectValues($users, 'userid'); $sql = 'SELECT s.userid, MAX(s.lastaccess) as lastaccess, s.status ' . ' FROM sessions s' . ' WHERE ' . DBcondition('s.userid', $userids) . ' GROUP BY s.userid, s.status'; $db_sessions = DBselect($sql); while ($session = DBfetch($db_sessions)) { if ($usessions[$session['userid']]['lastaccess'] < $session['lastaccess']) { $usessions[$session['userid']] = $session; } } foreach ($users as $unum => $user) {
$data['userid'] = $userId; $data['form'] = get_request('form'); $data['form_refresh'] = get_request('form_refresh', 0); // render view $usersView = new CView('administration.users.edit', $data); $usersView->render(); $usersView->show(); } else { $data = array('displayNodes' => is_array(get_current_nodeid())); // get user groups $data['userGroups'] = API::UserGroup()->get(array('output' => API_OUTPUT_EXTEND)); order_result($data['userGroups'], 'name'); // get users $data['users'] = API::User()->get(array('usrgrpids' => $_REQUEST['filter_usrgrpid'] > 0 ? $_REQUEST['filter_usrgrpid'] : null, 'output' => API_OUTPUT_EXTEND, 'selectUsrgrps' => API_OUTPUT_EXTEND, 'getAccess' => 1, 'limit' => $config['search_limit'] + 1)); // sorting & apging order_result($data['users'], getPageSortField('alias'), getPageSortOrder()); $data['paging'] = getPagingLine($data['users'], array('userid')); foreach ($data['users'] as $key => $user) { // nodes $data['users'][$key]['nodename'] = $data['displayNodes'] ? get_node_name_by_elid($user['userid'], true) : ''; // set default lastaccess time to 0 $data['usersSessions'][$user['userid']] = array('lastaccess' => 0); } $dbSessions = DBselect('SELECT s.userid,MAX(s.lastaccess) AS lastaccess,s.status' . ' FROM sessions s' . ' WHERE ' . dbConditionInt('s.userid', zbx_objectValues($data['users'], 'userid')) . ' GROUP BY s.userid,s.status'); while ($session = DBfetch($dbSessions)) { if ($data['usersSessions'][$session['userid']]['lastaccess'] < $session['lastaccess']) { $data['usersSessions'][$session['userid']] = $session; } } // render view $usersView = new CView('administration.users.list', $data);
$_REQUEST['hostid'] = $pageFilter->hostid; $displayNodes = is_array(get_current_nodeid()) && $pageFilter->groupid == 0 && $pageFilter->hostid == 0; $r_form = new CForm('get'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $r_form->addItem(array(_('Group') . SPACE, $pageFilter->getGroupsCB(true))); $r_form->addItem(array(SPACE . _('Host') . SPACE, $pageFilter->getHostsCB(true))); $httpmon_wdgt = new CWidget(); $httpmon_wdgt->addPageHeader(_('STATUS OF WEB MONITORING'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $httpmon_wdgt->addHeader(_('Web scenarios'), $r_form); $httpmon_wdgt->addHeaderRowNumber(); // TABLE $table = new CTableInfo(_('No web scenarios found.')); $table->SetHeader(array($displayNodes ? _('Node') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname') : null, make_sorting_header(_('Name'), 'name'), _('Number of steps'), _('Last check'), _('Status'))); $paging = null; if ($pageFilter->hostsSelected) { $sortfield = getPageSortField('hostname'); $sortorder = getPageSortOrder(); $options = array('output' => array('httptestid', 'name', 'hostid'), 'selectHosts' => array('name', 'status'), 'selectSteps' => API_OUTPUT_COUNT, 'templated' => false, 'preservekeys' => true, 'filter' => array('status' => HTTPTEST_STATUS_ACTIVE), 'limit' => $config['search_limit'] + 1); if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } elseif ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $httpTests = API::HttpTest()->get($options); foreach ($httpTests as &$httpTest) { $httpTest['host'] = reset($httpTest['hosts']); $httpTest['hostname'] = $httpTest['host']['name']; unset($httpTest['hosts']); } unset($httpTest); order_result($httpTests, $sortfield, $sortorder);
$hostinvent_wdgt->addItem(BR()); $table = new CTableInfo(_('No hosts defined.')); $table->setHeader(array(make_sorting_header($groupFieldTitle === '' ? _('Field') : $groupFieldTitle, 'inventory_field'), make_sorting_header(_('Host count'), 'host_count'))); // to show a report, we will need a host group and a field to aggregate if ($pageFilter->groupsSelected && $groupFieldTitle !== '') { $options = array('output' => array('hostid', 'name'), 'selectInventory' => array($_REQUEST['groupby']), 'withInventory' => true); if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $hosts = API::Host()->get($options); // aggregating data by chosen field value $report = array(); foreach ($hosts as $host) { if ($host['inventory'][$_REQUEST['groupby']] !== '') { $lowerValue = zbx_strtolower($host['inventory'][$_REQUEST['groupby']]); if (!isset($report[$lowerValue])) { $report[$lowerValue] = array('inventory_field' => $host['inventory'][$_REQUEST['groupby']], 'host_count' => 1); } else { $report[$lowerValue]['host_count'] += 1; } } } order_result($report, getPageSortField('host_count'), getPageSortOrder()); foreach ($report as $rep) { $row = array(new CSpan($rep['inventory_field'], 'pre'), new CLink($rep['host_count'], 'hostinventories.php?filter_field=' . $_REQUEST['groupby'] . '&filter_field_value=' . urlencode($rep['inventory_field']) . '&filter_set=1&filter_exact=1' . url_param('groupid'))); $table->addRow($row); } } $hostinvent_wdgt->addItem($table); $hostinvent_wdgt->show(); require_once dirname(__FILE__) . '/include/page_footer.php';
* ** 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/hosts.inc.php'; require_once dirname(__FILE__) . '/include/items.inc.php'; $page['title'] = _('Sort hosts by itemvalues'); $page['file'] = 'sort.php'; $page['hist_arg'] = array('group', 'item'); $page['scripts'] = array('class.cswitcher.js'); $page['type'] = detect_page_type(PAGE_TYPE_HTML); if ($page['type'] == PAGE_TYPE_HTML) { define('ZBX_PAGE_DO_REFRESH', 1); } validate_sort_and_sortorder('lastvalue', ZBX_SORT_DOWN); $sortfield = getPageSortField('lastvalue'); $sortorder = getPageSortOrder(); require_once dirname(__FILE__) . '/include/page_header.php'; $fields = array('group' => array(T_ZBX_INT, O_OPT, P_SYS, DB_ID, null), 'item' => array(T_ZBX_STR, O_OPT, P_SYS, null, null)); check_fields($fields); $_REQUEST['group'] = get_request('group'); $_REQUEST['item'] = get_request('item'); if (get_request('group') && !API::HostGroup()->isReadable(array($_REQUEST['group']))) { access_deny(); } $sortWidget = new CWidget(); $groups = API::HostGroup()->get(array('output' => API_OUTPUT_EXTEND)); order_result($groups, 'name'); $group_combo = new CComboBox('group', $_REQUEST['group'], 'javascript: submit();'); foreach ($groups as $group) { $group_combo->addItem($group['groupid'], $group['name']);
$m_form = new CForm('acknow.php'); $m_form->setName('tr_status'); $m_form->addVar('backurl', $page['file']); $admin_links = $USER_DETAILS['type'] == USER_TYPE_ZABBIX_ADMIN || $USER_DETAILS['type'] == USER_TYPE_SUPER_ADMIN; $show_event_col = $config['event_ack_enable'] && $_REQUEST['show_events'] != EVENTS_OPTION_NOEVENT; $table = new CTableInfo(); $switcherName = 'trigger_switchers'; $header_cb = $show_event_col ? new CCheckBox('all_events', false, "checkAll('" . $m_form->GetName() . "','all_events','events');") : new CCheckBox('all_triggers', false, "checkAll('" . $m_form->GetName() . "','all_triggers', 'triggers');"); if ($show_events != EVENTS_OPTION_NOEVENT) { $whow_hide_all = new CDiv(SPACE, 'filterclosed'); $whow_hide_all->setAttribute('id', $switcherName); } else { $whow_hide_all = NULL; } $table->setHeader(array($whow_hide_all, $config['event_ack_enable'] ? $header_cb : null, make_sorting_header(S_SEVERITY, 'priority'), S_STATUS, make_sorting_header(S_LAST_CHANGE, 'lastchange'), S_AGE, $show_event_col ? S_DURATION : NULL, $config['event_ack_enable'] ? S_ACKNOWLEDGED : NULL, is_show_all_nodes() ? S_NODE : null, S_HOST, make_sorting_header(S_NAME, 'description'), S_COMMENTS)); $sortfield = getPageSortField('description'); $sortorder = getPageSortOrder(); $options = array('nodeids' => get_current_nodeid(), 'filter' => array(), 'monitored' => 1, 'output' => API_OUTPUT_EXTEND, 'skipDependent' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'limit' => $config['search_limit'] + 1); // Filtering if ($pageFilter->hostsSelected) { if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } else { if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } } } else { $options['hostids'] = array(); } if (!zbx_empty($_REQUEST['txt_select'])) {
$_REQUEST['prof_type'] = get_request('prof_type', 0); $hostprof_wdgt = new CWidget(); $profile_form = new CForm(null, 'get'); $cmbProf = new CComboBox('prof_type', $_REQUEST['prof_type'], 'javascript: submit();'); $cmbProf->additem(0, S_NORMAL); $cmbProf->additem(1, S_EXTENDED); $profile_form->addItem(array(SPACE . S_HOST_PROFILES . SPACE, $cmbProf)); $hostprof_wdgt->addPageHeader(S_HOST_PROFILES_BIG, $profile_form); if ($_REQUEST['hostid'] > 0) { if ($_REQUEST['prof_type']) { $hostprof_wdgt->addItem(insert_host_profile_ext_form()); } else { $hostprof_wdgt->addItem(insert_host_profile_form()); } } else { $sortfield = getPageSortField('host'); $sortorder = getPageSortOrder(); $options = array('extendoutput' => 1, 'sortfield' => $sortfield, 'sortorder' => $sortorder, 'select_profile' => 1, 'select_groups' => 1, 'limit' => $config['search_limit'] + 1); if ($pageFilter->groupsSelected) { if ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } } else { $options['groupids'] = array(); } $hosts = CHost::get($options); // unset hosts without profiles, and copy some profile fileds to the uppers array level for sorting $pr = $_REQUEST['prof_type'] == 0 ? 'profile' : 'profile_ext'; $profile = array(); foreach ($hosts as $num => $host) { if (empty($host[$pr])) {
if ($pageFilter->hostid > 0) { $options['hostids'] = $pageFilter->hostid; } elseif ($pageFilter->groupid > 0) { $options['groupids'] = $pageFilter->groupid; } $httpTests = API::HttpTest()->get($options); $paging = getPagingLine($httpTests); $httpTests = API::HttpTest()->get(array('httptestids' => zbx_objectValues($httpTests, 'httptestid'), 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND, 'selectHosts' => array('name', 'status'), 'selectSteps' => API_OUTPUT_COUNT)); foreach ($httpTests as &$httpTest) { $httpTest['host'] = reset($httpTest['hosts']); $httpTest['hostname'] = $httpTest['host']['name']; unset($httpTest['hosts']); } unset($httpTest); $httpTests = resolveHttpTestMacros($httpTests, true, false); order_result($httpTests, getPageSortField('name'), getPageSortOrder()); // fetch the latest results of the web scenario $lastHttpTestData = Manager::HttpTest()->getLastData(array_keys($httpTests)); foreach ($httpTests as $httpTest) { $lastData = isset($lastHttpTestData[$httpTest['httptestid']]) ? $lastHttpTestData[$httpTest['httptestid']] : null; // test has history data if ($lastData) { $lastcheck = zbx_date2str(_('d M Y H:i:s'), $lastData['lastcheck']); if ($lastData['lastfailedstep'] != 0) { $step_data = get_httpstep_by_no($httpTest['httptestid'], $lastData['lastfailedstep']); $status['msg'] = _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $step_data['name'], $lastData['lastfailedstep'], $httpTest['steps'], $lastData['error']); $status['style'] = 'disabled'; } else { $status['msg'] = _('OK'); $status['style'] = 'enabled'; }
$filterShowDetails = 0; } if (hasRequest('filter_set') || hasRequest('filter_rst')) { CProfile::update('web.latest.filter.select', $filterSelect, PROFILE_TYPE_STR); CProfile::update('web.latest.filter.show_without_data', $filterShowWithoutData, PROFILE_TYPE_INT); CProfile::update('web.latest.filter.show_details', $filterShowDetails, PROFILE_TYPE_INT); } else { $filterSelect = CProfile::get('web.latest.filter.select', ''); $filterShowWithoutData = CProfile::get('web.latest.filter.show_without_data', 0); $filterShowDetails = CProfile::get('web.latest.filter.show_details', 0); } $pageFilter = new CPageFilter(array('groups' => array('real_hosts' => true), 'hosts' => array('with_monitored_items' => true), 'hostid' => getRequest('hostid', null), 'groupid' => getRequest('groupid', null))); $_REQUEST['groupid'] = $pageFilter->groupid; $_REQUEST['hostid'] = $pageFilter->hostid; validate_sort_and_sortorder('name', ZBX_SORT_UP); $sortField = getPageSortField(); $sortOrder = getPageSortOrder(); $applications = $items = $hostScripts = array(); // get hosts if ($_REQUEST['hostid']) { $availableHostIds = array($_REQUEST['hostid']); } elseif ($pageFilter->hostsSelected) { $availableHostIds = array_keys($pageFilter->hosts); } else { $availableHostIds = array(); } $hosts = API::Host()->get(array('output' => array('name', 'hostid', 'status'), 'hostids' => $availableHostIds, 'with_monitored_items' => true, 'preservekeys' => true)); if ($hosts) { foreach ($hosts as &$host) { $host['item_cnt'] = 0; }