Ejemplo n.º 1
0
$nameTextBox = new CTextBox('host', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE, 'no', 64);
$nameTextBox->attr('autofocus', 'autofocus');
$proxyFormList->addRow(_('Proxy name'), $nameTextBox);
// append status to form list
$statusBox = new CComboBox('status', $this->data['status'], 'submit()');
$statusBox->addItem(HOST_STATUS_PROXY_ACTIVE, _('Active'));
$statusBox->addItem(HOST_STATUS_PROXY_PASSIVE, _('Passive'));
$proxyFormList->addRow(_('Proxy mode'), $statusBox);
if ($this->data['status'] == HOST_STATUS_PROXY_PASSIVE) {
    if (isset($this->data['interface']['interfaceid'])) {
        $proxyForm->addVar('interface[interfaceid]', $this->data['interface']['interfaceid']);
        $proxyForm->addVar('interface[hostid]', $this->data['interface']['hostid']);
    }
    $interfaceTable = new CTable(null, 'formElementTable');
    $interfaceTable->addRow(array(_('IP address'), _('DNS name'), _('Connect to'), _('Port')));
    $connectByComboBox = new CRadioButtonList('interface[useip]', $this->data['interface']['useip']);
    $connectByComboBox->addValue(_('IP'), 1);
    $connectByComboBox->addValue(_('DNS'), 0);
    $connectByComboBox->useJQueryStyle();
    $interfaceTable->addRow(array(new CTextBox('interface[ip]', $this->data['interface']['ip'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), new CTextBox('interface[dns]', $this->data['interface']['dns'], ZBX_TEXTBOX_SMALL_SIZE, 'no', 64), $connectByComboBox, new CTextBox('interface[port]', $this->data['interface']['port'], 18, 'no', 64)));
    $proxyFormList->addRow(_('Interface'), new CDiv($interfaceTable, 'objectgroup inlineblock border_dotted ui-corner-all'));
}
// append hosts to form list
$hostsTweenBox = new CTweenBox($proxyForm, 'hosts', $this->data['hosts']);
foreach ($this->data['dbHosts'] as $host) {
    // show only normal hosts, and discovered hosts monitored by the current proxy
    // for new proxies display only normal hosts
    if ($this->data['proxyid'] && idcmp($this->data['proxyid'], $host['proxy_hostid']) || $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL) {
        $hostsTweenBox->addItem($host['hostid'], $host['name'], null, empty($host['proxy_hostid']) || !empty($this->data['proxyid']) && bccomp($host['proxy_hostid'], $this->data['proxyid']) == 0 && $host['flags'] == ZBX_FLAG_DISCOVERY_NORMAL);
    }
}
Ejemplo n.º 2
0
 $cmdList->setAttribute('id', 'opCmdList');
 $newOperationsTable->addRow(array(_('Target list'), $cmdList), 'indent_top');
 // type
 $typeComboBox = new CComboBox('new_operation[opcommand][type]', $this->data['new_operation']['opcommand']['type'], 'javascript: showOpTypeForm();');
 $typeComboBox->addItem(ZBX_SCRIPT_TYPE_IPMI, _('IPMI'));
 $typeComboBox->addItem(ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT, _('Custom script'));
 $typeComboBox->addItem(ZBX_SCRIPT_TYPE_SSH, _('SSH'));
 $typeComboBox->addItem(ZBX_SCRIPT_TYPE_TELNET, _('Telnet'));
 $typeComboBox->addItem(ZBX_SCRIPT_TYPE_GLOBAL_SCRIPT, _('Global script'));
 $userScriptId = new CVar('new_operation[opcommand][scriptid]', $this->data['new_operation']['opcommand']['scriptid']);
 $userScriptName = new CTextBox('new_operation[opcommand][script]', $this->data['new_operation']['opcommand']['script'], 32, true);
 $userScriptSelect = new CButton('select_opcommand_script', _('Select'), null, 'link_menu');
 $userScript = new CDiv(array($userScriptId, $userScriptName, SPACE, $userScriptSelect), 'class_opcommand_userscript inlineblock hidden');
 $newOperationsTable->addRow(array(_('Type'), array($typeComboBox, SPACE, $userScript)), 'indent_bottom');
 // script
 $executeOnRadioButton = new CRadioButtonList('new_operation[opcommand][execute_on]', $this->data['new_operation']['opcommand']['execute_on']);
 $executeOnRadioButton->makeVertical();
 $executeOnRadioButton->addValue(SPACE . _('Zabbix agent') . SPACE, ZBX_SCRIPT_EXECUTE_ON_AGENT);
 $executeOnRadioButton->addValue(SPACE . _('Zabbix server') . SPACE, ZBX_SCRIPT_EXECUTE_ON_SERVER);
 $newOperationsTable->addRow(array(_('Execute on'), new CDiv($executeOnRadioButton, 'objectgroup border_dotted ui-corner-all inlineblock')), 'class_opcommand_execute_on hidden indent_both');
 // ssh
 $authTypeComboBox = new CComboBox('new_operation[opcommand][authtype]', $this->data['new_operation']['opcommand']['authtype'], 'javascript: showOpTypeAuth();');
 $authTypeComboBox->addItem(ITEM_AUTHTYPE_PASSWORD, _('Password'));
 $authTypeComboBox->addItem(ITEM_AUTHTYPE_PUBLICKEY, _('Public key'));
 $newOperationsTable->addRow(array(_('Authentication method'), $authTypeComboBox), 'class_authentication_method hidden');
 $newOperationsTable->addRow(array(_('User name'), new CTextBox('new_operation[opcommand][username]', $this->data['new_operation']['opcommand']['username'], ZBX_TEXTBOX_SMALL_SIZE)), 'class_authentication_username hidden indent_both');
 $newOperationsTable->addRow(array(_('Public key file'), new CTextBox('new_operation[opcommand][publickey]', $this->data['new_operation']['opcommand']['publickey'], ZBX_TEXTBOX_SMALL_SIZE)), 'class_authentication_publickey hidden indent_both');
 $newOperationsTable->addRow(array(_('Private key file'), new CTextBox('new_operation[opcommand][privatekey]', $this->data['new_operation']['opcommand']['privatekey'], ZBX_TEXTBOX_SMALL_SIZE)), 'class_authentication_privatekey hidden indent_both');
 $newOperationsTable->addRow(array(_('Password'), new CTextBox('new_operation[opcommand][password]', $this->data['new_operation']['opcommand']['password'], ZBX_TEXTBOX_SMALL_SIZE)), 'class_authentication_password hidden indent_both');
 // set custom id because otherwise they are set based on name (sick!) and produce duplicate ids
 $passphraseCB = new CTextBox('new_operation[opcommand][password]', $this->data['new_operation']['opcommand']['password'], ZBX_TEXTBOX_SMALL_SIZE);
$discoveryFormList->addRow(_('Name'), $nameTextBox);
// append proxy to form list
$proxyComboBox = new CComboBox('proxy_hostid', $this->data['drule']['proxy_hostid']);
$proxyComboBox->addItem(0, _('No proxy'));
foreach ($this->data['proxies'] as $proxy) {
    $proxyComboBox->addItem($proxy['proxyid'], $proxy['host']);
}
$discoveryFormList->addRow(_('Discovery by proxy'), $proxyComboBox);
$discoveryFormList->addRow(_('IP range'), new CTextBox('iprange', $this->data['drule']['iprange'], ZBX_TEXTBOX_SMALL_SIZE));
$discoveryFormList->addRow(_('Delay (in sec)'), new CNumericBox('delay', $this->data['drule']['delay'], 8));
// append checks to form list
$checkTable = new CTable(null, 'formElementTable');
$checkTable->addRow(new CRow(new CCol(new CButton('newCheck', _('New'), null, 'link_menu'), null, 2), null, 'dcheckListFooter'));
$discoveryFormList->addRow(_('Checks'), new CDiv($checkTable, 'objectgroup inlineblock border_dotted ui-corner-all', 'dcheckList'));
// append uniqueness criteria to form list
$uniquenessCriteriaRadio = new CRadioButtonList('uniqueness_criteria', $this->data['drule']['uniqueness_criteria']);
$uniquenessCriteriaRadio->addValue(SPACE . _('IP address'), -1, true, zbx_formatDomId('uniqueness_criteria_ip'));
$discoveryFormList->addRow(_('Device uniqueness criteria'), new CDiv($uniquenessCriteriaRadio, 'objectgroup inlineblock border_dotted ui-corner-all', 'uniqList'));
// append status to form list
$status = empty($this->data['druleid']) && empty($this->data['form_refresh']) ? true : $this->data['drule']['status'] == DRULE_STATUS_ACTIVE;
$discoveryFormList->addRow(_('Enabled'), new CCheckBox('status', $status, null, 1));
// append tabs to form
$discoveryTabs = new CTabView();
$discoveryTabs->addTab('druleTab', _('Discovery rule'), $discoveryFormList);
$discoveryForm->addItem($discoveryTabs);
// append buttons to form
$deleteButton = new CButtonDelete(_('Delete discovery rule?'), url_param('form') . url_param('druleid'));
if (empty($this->data['druleid'])) {
    $deleteButton->setAttribute('disabled', 'disabled');
}
$discoveryForm->addItem(makeFormFooter(new CSubmit('save', _('Save')), array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel())));
Ejemplo n.º 4
0
if ($this->get('scriptid')) {
    $scriptForm->addVar('scriptid', $this->get('scriptid'));
}
$scriptFormList = new CFormList('scriptsTab');
// name
$nameTextBox = new CTextBox('name', $this->get('name'), ZBX_TEXTBOX_STANDARD_SIZE);
$nameTextBox->attr('autofocus', 'autofocus');
$nameTextBox->attr('placeholder', _('<Sub-menu/Sub-menu.../>Script'));
$scriptFormList->addRow(_('Name'), $nameTextBox);
// type
$typeComboBox = new CComboBox('type', $this->get('type'));
$typeComboBox->addItem(ZBX_SCRIPT_TYPE_IPMI, _('IPMI'));
$typeComboBox->addItem(ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT, _('Script'));
$scriptFormList->addRow(_('Type'), $typeComboBox);
// execute on
$typeRadioButton = new CRadioButtonList('execute_on', $this->get('execute_on'));
$typeRadioButton->makeVertical();
$typeRadioButton->addValue(_('Zabbix agent'), ZBX_SCRIPT_EXECUTE_ON_AGENT);
$typeRadioButton->addValue(_('Zabbix server'), ZBX_SCRIPT_EXECUTE_ON_SERVER);
$scriptFormList->addRow(_('Execute on'), new CDiv($typeRadioButton, 'objectgroup inlineblock border_dotted ui-corner-all'), $this->get('type') == ZBX_SCRIPT_TYPE_IPMI);
$scriptFormList->addRow(_('Commands'), new CTextArea('command', $this->get('command')), $this->get('type') == ZBX_SCRIPT_TYPE_IPMI);
$scriptFormList->addRow(_('Command'), new CTextBox('commandipmi', $this->get('commandipmi'), ZBX_TEXTBOX_STANDARD_SIZE), $this->get('type') == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT);
$scriptFormList->addRow(_('Description'), new CTextArea('description', $this->get('description')));
// user groups
$userGroups = new CCombobox('usrgrpid', $this->get('usrgrpid'));
$userGroups->addItem(0, _('All'));
foreach ($this->getArray('usergroups') as $userGroup) {
    $userGroups->addItem($userGroup['usrgrpid'], $userGroup['name']);
}
$scriptFormList->addRow(_('User groups'), $userGroups);
// host groups
$discoveryFormList->addRow(_('Name'), new CTextBox('name', $this->data['drule']['name'], ZBX_TEXTBOX_STANDARD_SIZE));
// append proxy to form list
$proxyComboBox = new CComboBox('proxy_hostid', $this->data['drule']['proxy_hostid']);
$proxyComboBox->addItem(0, _('No proxy'));
foreach ($this->data['proxies'] as $proxy) {
    $proxyComboBox->addItem($proxy['proxyid'], $proxy['host']);
}
$discoveryFormList->addRow(_('Discovery by proxy'), $proxyComboBox);
$discoveryFormList->addRow(_('IP range'), new CTextBox('iprange', $this->data['drule']['iprange'], ZBX_TEXTBOX_SMALL_SIZE));
$discoveryFormList->addRow(_('Delay (in sec)'), new CNumericBox('delay', $this->data['drule']['delay'], 8));
// append checks to form list
$checkTable = new CTable(null, 'formElementTable');
$checkTable->addRow(new CRow(new CCol(new CButton('newCheck', _('New'), null, 'link_menu'), null, 2), null, 'dcheckListFooter'));
$discoveryFormList->addRow(_('Checks'), new CDiv($checkTable, 'objectgroup inlineblock border_dotted ui-corner-all', 'dcheckList'));
// append uniqueness criteria to form list
$uniquenessCriteriaRadio = new CRadioButtonList('uniqueness_criteria', $this->data['drule']['uniqueness_criteria']);
$uniquenessCriteriaRadio->addValue(' ' . _('IP address'), -1);
$discoveryFormList->addRow(_('Device uniqueness criteria'), new CDiv($uniquenessCriteriaRadio, 'objectgroup inlineblock border_dotted ui-corner-all', 'uniqList'));
// append status to form list
$discoveryFormList->addRow(_('Enabled'), new CCheckBox('status', !empty($this->data['druleid']) ? $this->data['drule']['status'] == 0 ? 'yes' : 'no' : 'yes', null, 1));
// append tabs to form
$discoveryTabs = new CTabView();
$discoveryTabs->addTab('druleTab', _('Discovery rule'), $discoveryFormList);
$discoveryForm->addItem($discoveryTabs);
// append buttons to form
$deleteButton = new CButtonDelete(_('Delete discovery rule?'), url_param('form') . url_param('druleid'));
if (empty($this->data['druleid'])) {
    $deleteButton->setAttribute('disabled', 'disabled');
}
$discoveryForm->addItem(makeFormFooter(array(new CSubmit('save', _('Save'))), array(new CSubmit('clone', _('Clone')), $deleteButton, new CButtonCancel())));
$discoveryWidget->addItem($discoveryForm);