}
    $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);
$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);
    $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);
    }
}
Esempio n. 4
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 . ')'));
Esempio n. 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'] . '&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;
Esempio n. 7
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 . ')'));