$httpWidget->addHeaderRowNumber(array('[ ', new CLink($this->data['showDisabled'] ? _('Hide disabled scenarios') : _('Show disabled scenarios'), '?showdisabled=' . ($this->data['showDisabled'] ? 0 : 1), null), ' ]'));
// create form
$httpForm = new CForm();
$httpForm->setName('scenarios');
$httpForm->addVar('hostid', $this->data['hostid']);
$httpTable = new CTableInfo(_('No web scenarios found.'));
$httpTable->setHeader(array(new CCheckBox('all_httptests', null, "checkAll('" . $httpForm->getName() . "', 'all_httptests', 'group_httptestid');"), $this->data['displayNodes'] ? _('Node') : null, $this->data['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname') : null, make_sorting_header(_('Name'), 'name'), _('Number of steps'), _('Update interval'), make_sorting_header(_('Status'), 'status')));
foreach ($this->data['httpTests'] as $httpTestId => $httpTest) {
    $name = array();
    if (isset($this->data['parentTemplates'][$httpTestId])) {
        $template = $this->data['parentTemplates'][$httpTestId];
        $name[] = new CLink($template['name'], '?groupid=0&hostid=' . $template['id'], 'unknown');
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid']);
    $httpTable->addRow(array(new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', null, null, $httpTest['httptestid']), $this->data['displayNodes'] ? $httpTest['nodename'] : null, $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], $httpTest['delay'], new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&go=' . ($httpTest['status'] ? 'activate' : 'disable'), httptest_status2style($httpTest['status']))));
}
// create go buttons
$goComboBox = new CComboBox('go');
$goOption = new CComboItem('activate', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('disable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('clean_history', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected WEB scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected WEB scenarios?'));
$goComboBox->addItem($goOption);
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTestId . '&hostid=' . $httpTest['hostid']);
    if ($this->data['showInfoColumn']) {
        if ($httpTest['status'] == HTTPTEST_STATUS_ACTIVE && isset($httpTestsLastData[$httpTestId]) && $httpTestsLastData[$httpTestId]['lastfailedstep']) {
            $lastData = $httpTestsLastData[$httpTestId];
            $failedStep = $lastData['failedstep'];
            $errorMessage = $failedStep ? _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $failedStep['name'], $failedStep['no'], $httpTest['stepscnt'], $lastData['error'] === null ? _('Unknown error') : $lastData['error']) : _s('Unknown step failed: %1$s', $lastData['error']);
            $infoIcon = new CDiv(SPACE, 'status_icon iconerror');
            $infoIcon->setHint($errorMessage, 'on');
        } else {
            $infoIcon = '';
        }
    } else {
        $infoIcon = null;
    }
    $httpTable->addRow(array(new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', null, null, $httpTest['httptestid']), $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], $httpTest['delay'], $httpTest['retries'], httptest_authentications($httpTest['authentication']), $httpTest['http_proxy'] !== '' ? _('Yes') : _('No'), $httpTest['applicationid'] != 0 ? $httpTest['application_name'] : '-', new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&action=' . ($httpTest['status'] == HTTPTEST_STATUS_DISABLED ? 'httptest.massenable' : 'httptest.massdisable'), httptest_status2style($httpTest['status'])), $infoIcon));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('httptest.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massclearhistory', _('Clear history for selected'));
$goOption->setAttribute('confirm', _('Delete history of selected web scenarios?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('httptest.massdelete', _('Delete selected'));
$goOption->setAttribute('confirm', _('Delete selected web scenarios?'));
$goComboBox->addItem($goOption);
Пример #3
0
function insert_httptest_form()
{
    $form = new CFormTable(S_SCENARIO, null, 'post');
    $form->SetHelp("web.webmon.httpconf.php");
    if ($_REQUEST['groupid'] > 0) {
        $form->addVar('groupid', $_REQUEST['groupid']);
    }
    $form->addVar('hostid', $_REQUEST['hostid']);
    if (isset($_REQUEST["httptestid"])) {
        $form->addVar("httptestid", $_REQUEST["httptestid"]);
    }
    $name = get_request('name', '');
    $application = get_request('application', '');
    $delay = get_request('delay', 60);
    $status = get_request('status', HTTPTEST_STATUS_ACTIVE);
    $agent = get_request('agent', '');
    $macros = get_request('macros', array());
    $steps = get_request('steps', array());
    if (isset($_REQUEST["httptestid"]) && !isset($_REQUEST["form_refresh"]) || isset($limited)) {
        $httptest_data = DBfetch(DBselect("SELECT wt.*, a.name as application " . " FROM httptest wt,applications a WHERE wt.httptestid=" . $_REQUEST["httptestid"] . " AND a.applicationid=wt.applicationid"));
        $name = $httptest_data['name'];
        $application = $httptest_data['application'];
        $delay = $httptest_data['delay'];
        $status = $httptest_data['status'];
        $agent = $httptest_data['agent'];
        $macros = $httptest_data['macros'];
        $steps = array();
        $db_steps = DBselect('SELECT * FROM httpstep WHERE httptestid=' . $_REQUEST["httptestid"] . ' order by no');
        while ($step_data = DBfetch($db_steps)) {
            $steps[] = $step_data;
        }
    }
    $form->addRow(S_APPLICATION, array(new CTextBox('application', $application, 40), SPACE, new CButton('select_app', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->GetName() . '&dstfld1=application&srctbl=applications' . '&srcfld1=name&only_hostid=' . $_REQUEST['hostid'] . '",200,300,"application");')));
    $form->addRow(S_NAME, new CTextBox('name', $name, 40));
    $form->addRow(S_UPDATE_INTERVAL_IN_SEC, new CNumericBox("delay", $delay, 5));
    $cmbAgent = new CEditableComboBox('agent', $agent, 80);
    // IE6
    $cmbAgent->addItem('Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1; SV1; .NET CLR 2.0.50727)', 'Internet Explorer 6.0 on Windows XP SP2 with .NET Framework 2.0 installed');
    // IE7
    $cmbAgent->addItem('Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.648; .NET CLR 3.5.21022)', 'Internet Explorer 7.0 on Windows XP SP3 with .NET Framework 3.5 installed');
    // FF 1.5
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-GB; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7', 'Mozilla Firefox 1.5.0.7 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.0.7) Gecko/20060909 Firefox/1.5.0.7', 'Mozilla Firefox 1.5.0.7 on Linux');
    // FF 2.0
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.8.1.18) Gecko/20081029 Firefox/2.0.0.18', 'Mozilla Firefox 2.0.0.18 on Linux');
    // FF 3.0
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.1) Gecko/2008070208 Firefox/3.0.1', 'Mozilla Firefox 3.0.1 on Linux');
    // OP 9.0
    $cmbAgent->addItem('Opera/9.02 (Windows NT 5.1; U; en)', 'Opera 9.02 on Windows XP');
    $cmbAgent->addItem('Opera/9.02 (X11; Linux i686; U; en)', 'Opera 9.02 on Linux');
    // OP 9.6
    $cmbAgent->addItem('Opera/9.61 (Windows NT 5.1; U; en) Presto/2.1.1', 'Opera 9.61 on Windows XP');
    $cmbAgent->addItem('Opera/9.61 (X11; Linux i686; U; en) Presto/2.1.1', 'Opera 9.61 on Linux');
    // SF 3.1
    $cmbAgent->addItem('Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/525.19 (KHTML, like Gecko) Version/3.1.2 Safari/525.21', 'Safari 3.1.2 on Windows XP');
    $cmbAgent->addItem('Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_5_4; en-us) AppleWebKit/527.2+ (KHTML, like Gecko) Version/3.1.2 Safari/525.20.1', 'Safari 3.1.2 on Intel Mac OS X 10.5.4');
    $cmbAgent->addItem('Mozilla/5.0 (iPhone; U; CPU iPhone OS 2_1 like Mac OS X; fr-fr) AppleWebKit/525.18.1 (KHTML, like Gecko) Mobile/5F136', 'Safari on iPhone');
    $cmbAgent->addItem('Lynx/2.8.4rel.1 libwww-FM/2.14', 'Lynx 2.8.4rel.1 on Linux');
    $cmbAgent->addItem('Googlebot/2.1 (+http://www.google.com/bot.html)', 'Googlebot');
    $form->addRow(S_AGENT, $cmbAgent);
    $cmbStatus = new CComboBox("status", $status);
    foreach (array(HTTPTEST_STATUS_ACTIVE, HTTPTEST_STATUS_DISABLED) as $st) {
        $cmbStatus->addItem($st, httptest_status2str($st));
    }
    $form->addRow(S_STATUS, $cmbStatus);
    $form->addRow(S_VARIABLES, new CTextArea('macros', $macros, 84, 5));
    $tblSteps = new CTableInfo();
    $tblSteps->SetHeader(array(S_NAME, S_TIMEOUT, S_URL, S_REQUIRED, S_STATUS, SPACE));
    if (count($steps) > 0) {
        $first = min(array_keys($steps));
        $last = max(array_keys($steps));
    }
    foreach ($steps as $stepid => $s) {
        if (!isset($s['name'])) {
            $s['name'] = '';
        }
        if (!isset($s['timeout'])) {
            $s['timeout'] = 15;
        }
        if (!isset($s['url'])) {
            $s['url'] = '';
        }
        if (!isset($s['posts'])) {
            $s['posts'] = '';
        }
        if (!isset($s['required'])) {
            $s['required'] = '';
        }
        $up = null;
        if ($stepid != $first) {
            $up = new CLink(S_UP, '#', 'action');
            $up->OnClick("return create_var('" . $form->GetName() . "','move_up'," . $stepid . ", true);");
        }
        $down = null;
        if ($stepid != $last) {
            $down = new CLink(S_DOWN, '#', 'action');
            $down->OnClick("return create_var('" . $form->GetName() . "','move_down'," . $stepid . ", true);");
        }
        $name = new CLink($s['name'], '#', 'action');
        $name->OnClick('return PopUp("popup_httpstep.php?dstfrm=' . $form->GetName() . '&list_name=steps&stepid=' . $stepid . url_param($s['name'], false, 'name') . url_param($s['timeout'], false, 'timeout') . url_param($s['url'], false, 'url') . url_param($s['posts'], false, 'posts') . url_param($s['required'], false, 'required') . url_param($s['status_codes'], false, 'status_codes') . '");');
        if (strlen($s['url']) > 70) {
            $url = new CTag('span', 'yes', substr($s['url'], 0, 35) . SPACE . '...' . SPACE . substr($s['url'], strlen($s['url']) - 25, 25));
            $url->SetHint($s['url']);
        } else {
            $url = $s['url'];
        }
        $tblSteps->addRow(array(array(new CCheckBox('sel_step[]', null, null, $stepid), $name), $s['timeout'] . SPACE . S_SEC_SMALL, $url, $s['required'], $s['status_codes'], array($up, isset($up) && isset($down) ? SPACE : null, $down)));
    }
    $form->addVar('steps', $steps);
    $form->addRow(S_STEPS, array(count($steps) > 0 ? array($tblSteps, BR()) : null, new CButton('add_step', S_ADD, 'return PopUp("popup_httpstep.php?dstfrm=' . $form->GetName() . '");'), count($steps) > 0 ? new CButton('del_sel_step', S_DELETE_SELECTED) : null));
    $form->addItemToBottomRow(new CButton("save", S_SAVE));
    if (isset($_REQUEST["httptestid"])) {
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButton("clone", S_CLONE));
        $form->addItemToBottomRow(SPACE);
        $form->addItemToBottomRow(new CButtonDelete(S_DELETE_SCENARIO_Q, url_param("form") . url_param("httptestid") . url_param('hostid')));
    }
    $form->addItemToBottomRow(SPACE);
    $form->addItemToBottomRow(new CButtonCancel());
    $form->Show();
}
    $expandLink = new CLink(new CImg('images/general/minus.png'), '?close=1' . url_param('groupid') . url_param('hostid'));
} else {
    $expandLink = new CLink(new CImg('images/general/plus.png'), '?open=1' . url_param('groupid') . url_param('hostid'));
}
$httpTable = new CTableInfo(_('No web scenarios defined.'));
$httpTable->setHeader(array(new CCheckBox('all_httptests', null, "checkAll('" . $httpForm->getName() . "', 'all_httptests', 'group_httptestid');"), is_show_all_nodes() ? make_sorting_header(_('Node'), 'h.hostid') : null, $_REQUEST['hostid'] == 0 ? make_sorting_header(_('Host'), 'host') : null, make_sorting_header(array($expandLink, SPACE, _('Name')), 'name'), _('Number of steps'), _('Update interval'), make_sorting_header(_('Status'), 'status')));
$httpTableRows = array();
foreach ($this->data['db_httptests'] as $httptestid => $httptest_data) {
    $db_app = $this->data['db_apps'][$httptest_data['applicationid']];
    if (!isset($httpTableRows[$db_app['applicationid']])) {
        $httpTableRows[$db_app['applicationid']] = array();
    }
    if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($this->data['showAllApps'])) {
        continue;
    }
    $httpTableRows[$db_app['applicationid']][] = array(new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']), is_show_all_nodes() ? SPACE : null, $_REQUEST['hostid'] > 0 ? null : $db_app['hostname'], new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid')), $httptest_data['step_count'], $httptest_data['delay'], new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&go=' . ($httptest_data['status'] ? 'activate' : 'disable'), httptest_status2style($httptest_data['status']))));
}
foreach ($httpTableRows as $appid => $app_rows) {
    $db_app = $this->data['db_apps'][$appid];
    if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($this->data['showAllApps'])) {
        $link = new CLink(new CImg('images/general/minus.png'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
    } else {
        $link = new CLink(new CImg('images/general/plus.png'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
    }
    $column = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . _n('%1$d scenario', '%1$d scenarios', $db_app['scenarios_cnt']) . ')'));
    $column->setColSpan(6);
    $httpTable->addRow(array(get_node_name_by_elid($db_app['applicationid']), $column));
    foreach ($app_rows as $row) {
        $httpTable->addRow($row);
    }
}
Пример #5
0
 while ($step_cout = DBfetch($httpstep_res)) {
     $db_httptests[$step_cout['httptestid']]['step_cout'] = $step_cout['cnt'];
 }
 $tab_rows = array();
 foreach ($db_httptests as $httptestid => $httptest_data) {
     $db_app =& $db_apps[$httptest_data['applicationid']];
     if (!isset($tab_rows[$db_app['applicationid']])) {
         $tab_rows[$db_app['applicationid']] = array();
     }
     $app_rows =& $tab_rows[$db_app['applicationid']];
     if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
         continue;
     }
     $name = array();
     array_push($name, new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid'), NULL));
     $status = new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&group_task=' . ($httptest_data['status'] ? S_ACTIVATE_SELECTED : S_DISABLE_SELECTED), httptest_status2style($httptest_data['status'])));
     $chkBox = new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']);
     $step_cout = DBfetch(DBselect('select count(*) as cnt from httpstep where httptestid=' . $httptest_data['httptestid']));
     $step_cout = $step_cout['cnt'];
     array_push($app_rows, new CRow(array($chkBox, is_show_all_nodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? NULL : SPACE, array(str_repeat(SPACE, 4), $name), $step_cout, $httptest_data['delay'], $status)));
 }
 unset($app_rows);
 unset($db_app);
 foreach ($tab_rows as $appid => $app_rows) {
     $db_app =& $db_apps[$appid];
     if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
         $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     } else {
         $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     }
     $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));
Пример #6
0
 while ($step_cout = DBfetch($httpstep_res)) {
     $db_httptests[$step_cout['httptestid']]['step_cout'] = $step_cout['cnt'];
 }
 $tab_rows = array();
 foreach ($db_httptests as $httptestid => $httptest_data) {
     $db_app =& $db_apps[$httptest_data['applicationid']];
     if (!isset($tab_rows[$db_app['applicationid']])) {
         $tab_rows[$db_app['applicationid']] = array();
     }
     $app_rows =& $tab_rows[$db_app['applicationid']];
     if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
         continue;
     }
     $name = array();
     array_push($name, new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid'), NULL));
     $status = new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . '&group_task=' . ($httptest_data['status'] ? 'Activate+selected' : 'Disable+selected'), httptest_status2style($httptest_data['status'])));
     $chkBox = new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']);
     $step_cout = DBfetch(DBselect('select count(*) as cnt from httpstep where httptestid=' . $httptest_data['httptestid']));
     $step_cout = $step_cout['cnt'];
     array_push($app_rows, new CRow(array(is_show_subnodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? NULL : SPACE, array(str_repeat(SPACE, 4), $chkBox, $name), $step_cout, $httptest_data['delay'], $status)));
 }
 unset($app_rows);
 unset($db_app);
 foreach ($tab_rows as $appid => $app_rows) {
     $db_app =& $db_apps[$appid];
     if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
         $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     } else {
         $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     }
     $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));
$httpTable = (new CTableInfo())->setHeader([(new CColHeader((new CCheckBox('all_httptests'))->onClick("checkAll('" . $httpForm->getName() . "', 'all_httptests', 'group_httptestid');")))->addClass(ZBX_STYLE_CELL_WIDTH), $this->data['hostid'] == 0 ? make_sorting_header(_('Host'), 'hostname', $this->data['sort'], $this->data['sortorder']) : null, make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Number of steps'), _('Update interval'), _('Attempts'), _('Authentication'), _('HTTP proxy'), _('Application'), make_sorting_header(_('Status'), 'status', $this->data['sort'], $this->data['sortorder']), $this->data['showInfoColumn'] ? _('Info') : null]);
$httpTestsLastData = $this->data['httpTestsLastData'];
$httpTests = $this->data['httpTests'];
foreach ($httpTests as $httpTestId => $httpTest) {
    $name = [];
    if (isset($this->data['parentTemplates'][$httpTestId])) {
        $template = $this->data['parentTemplates'][$httpTestId];
        $name[] = (new CLink($template['name'], '?groupid=0&hostid=' . $template['id']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY);
        $name[] = NAME_DELIMITER;
    }
    $name[] = new CLink($httpTest['name'], '?form=update' . '&httptestid=' . $httpTestId . '&hostid=' . $httpTest['hostid']);
    if ($this->data['showInfoColumn']) {
        if ($httpTest['status'] == HTTPTEST_STATUS_ACTIVE && isset($httpTestsLastData[$httpTestId]) && $httpTestsLastData[$httpTestId]['lastfailedstep']) {
            $lastData = $httpTestsLastData[$httpTestId];
            $failedStep = $lastData['failedstep'];
            $errorMessage = $failedStep ? _s('Step "%1$s" [%2$s of %3$s] failed: %4$s', $failedStep['name'], $failedStep['no'], $httpTest['stepscnt'], $lastData['error'] === null ? _('Unknown error') : $lastData['error']) : _s('Unknown step failed: %1$s', $lastData['error']);
            $infoIcon = makeErrorIcon($errorMessage);
        } else {
            $infoIcon = '';
        }
    } else {
        $infoIcon = null;
    }
    $httpTable->addRow([new CCheckBox('group_httptestid[' . $httpTest['httptestid'] . ']', $httpTest['httptestid']), $this->data['hostid'] > 0 ? null : $httpTest['hostname'], $name, $httpTest['stepscnt'], convertUnitsS($httpTest['delay']), $httpTest['retries'], httptest_authentications($httpTest['authentication']), $httpTest['http_proxy'] !== '' ? _('Yes') : _('No'), $httpTest['applicationid'] != 0 ? $httpTest['application_name'] : '', (new CLink(httptest_status2str($httpTest['status']), '?group_httptestid[]=' . $httpTest['httptestid'] . '&hostid=' . $httpTest['hostid'] . '&action=' . ($httpTest['status'] == HTTPTEST_STATUS_DISABLED ? 'httptest.massenable' : 'httptest.massdisable')))->addClass(ZBX_STYLE_LINK_ACTION)->addClass(httptest_status2style($httpTest['status']))->addSID(), $infoIcon]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['hostid'] . '";');
// append table to form
$httpForm->addItem([$httpTable, $this->data['paging'], new CActionButtonList('action', 'group_httptestid', ['httptest.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected web scenarios?')], 'httptest.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected web scenarios?')], 'httptest.massclearhistory' => ['name' => _('Clear history'), 'confirm' => _('Delete history of selected web scenarios?')], 'httptest.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected web scenarios?')]], $this->data['hostid'])]);
// append form to widget
$widget->addItem($httpForm);
return $widget;
Пример #8
0
 while ($step_cout = DBfetch($httpstep_res)) {
     $db_httptests[$step_cout['httptestid']]['step_cout'] = $step_cout['cnt'];
 }
 $tab_rows = array();
 foreach ($db_httptests as $httptestid => $httptest_data) {
     $db_app =& $db_apps[$httptest_data['applicationid']];
     if (!isset($tab_rows[$db_app['applicationid']])) {
         $tab_rows[$db_app['applicationid']] = array();
     }
     $app_rows =& $tab_rows[$db_app['applicationid']];
     if (!uint_in_array($db_app['applicationid'], $_REQUEST['applications']) && !isset($show_all_apps)) {
         continue;
     }
     $name = array();
     array_push($name, new CLink($httptest_data['name'], '?form=update' . '&httptestid=' . $httptest_data['httptestid'] . '&hostid=' . $db_app['hostid'] . url_param('groupid'), NULL));
     $status = new CCol(new CLink(httptest_status2str($httptest_data['status']), '?group_httptestid[]=' . $httptest_data['httptestid'] . '&go=' . ($httptest_data['status'] ? 'activate' : 'disable'), httptest_status2style($httptest_data['status'])));
     $chkBox = new CCheckBox('group_httptestid[' . $httptest_data['httptestid'] . ']', null, null, $httptest_data['httptestid']);
     $step_cout = DBfetch(DBselect('select count(*) as cnt from httpstep where httptestid=' . $httptest_data['httptestid']));
     $step_cout = $step_cout['cnt'];
     array_push($app_rows, new CRow(array($chkBox, is_show_all_nodes() ? SPACE : NULL, $_REQUEST['hostid'] > 0 ? null : $db_app['host'], $name, $step_cout, $httptest_data['delay'], $status)));
 }
 unset($app_rows);
 unset($db_app);
 foreach ($tab_rows as $appid => $app_rows) {
     $db_app =& $db_apps[$appid];
     if (uint_in_array($db_app['applicationid'], $_REQUEST['applications']) || isset($show_all_apps)) {
         $link = new CLink(new CImg('images/general/opened.gif'), '?close=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     } else {
         $link = new CLink(new CImg('images/general/closed.gif'), '?open=1&applicationid=' . $db_app['applicationid'] . url_param('groupid') . url_param('hostid') . url_param('applications') . url_param('select'));
     }
     $col = new CCol(array($link, SPACE, bold($db_app['name']), SPACE . '(' . $db_app['scenarios_cnt'] . SPACE . S_SCENARIOS . ')'));