$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'; } } else { $lastcheck = _('Never'); $status['msg'] = _('Unknown'); $status['style'] = 'unknown'; } $cpsan = new CSpan($httpTest['hostname'], $httpTest['host']['status'] == HOST_STATUS_NOT_MONITORED ? 'not-monitored' : ''); $table->addRow(new CRow(array($displayNodes ? get_node_name_by_elid($httpTest['httptestid'], true) : null, $_REQUEST['hostid'] > 0 ? null : $cpsan, new CLink($httpTest['name'], 'httpdetails.php?httptestid=' . $httpTest['httptestid']), $httpTest['steps'], $lastcheck, new CSpan($status['msg'], $status['style'])))); } } else {
} elseif ($data['pageFilter']->groupid > 0) { $options['groupids'] = $data['pageFilter']->groupid; } $httpTests = API::HttpTest()->get($options); $dbHttpTests = DBselect('SELECT ht.httptestid,ht.name,ht.delay,ht.status,ht.hostid,ht.templateid,h.name AS hostname,ht.retries,' . 'ht.authentication,ht.http_proxy,a.applicationid,a.name AS application_name' . ' FROM httptest ht' . ' INNER JOIN hosts h ON h.hostid=ht.hostid' . ' LEFT JOIN applications a ON a.applicationid=ht.applicationid' . ' WHERE ' . dbConditionInt('ht.httptestid', zbx_objectValues($httpTests, 'httptestid'))); $httpTests = array(); while ($dbHttpTest = DBfetch($dbHttpTests)) { $httpTests[$dbHttpTest['httptestid']] = $dbHttpTest; } order_result($httpTests, $sortField, $sortOrder); $data['paging'] = getPagingLine($httpTests, $sortOrder); if ($data['showInfoColumn']) { $httpTestsLastData = Manager::HttpTest()->getLastData(array_keys($httpTests)); foreach ($httpTestsLastData as $httpTestId => &$lastData) { if ($lastData['lastfailedstep'] !== null) { $lastData['failedstep'] = get_httpstep_by_no($httpTestId, $lastData['lastfailedstep']); } } unset($lastData); } else { $httpTestsLastData = array(); } $dbHttpSteps = DBselect('SELECT hs.httptestid,COUNT(*) AS stepscnt' . ' FROM httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', zbx_objectValues($httpTests, 'httptestid')) . ' GROUP BY hs.httptestid'); while ($dbHttpStep = DBfetch($dbHttpSteps)) { $httpTests[$dbHttpStep['httptestid']]['stepscnt'] = $dbHttpStep['stepscnt']; } order_result($httpTests, $sortField, $sortOrder); $data['parentTemplates'] = getHttpTestsParentTemplates($httpTests); $data['httpTests'] = $httpTests; $data['httpTestsLastData'] = $httpTestsLastData; }