Exemple #1
0
function insert_node_form()
{
    global $ZBX_CURMASTERID;
    $frm_title = S_NODE;
    if (isset($_REQUEST['nodeid'])) {
        $node_data = get_node_by_nodeid($_REQUEST['nodeid']);
        $node_type = detect_node_type($node_data);
        $masterid = $node_data['masterid'];
        $frm_title = S_NODE . ' "' . $node_data['name'] . '"';
    }
    $frmNode = new CFormTable($frm_title);
    $frmNode->SetHelp("node.php");
    if (isset($_REQUEST['nodeid'])) {
        $frmNode->addVar('nodeid', $_REQUEST['nodeid']);
    }
    if (isset($_REQUEST['nodeid']) && (!isset($_REQUEST["form_refresh"]) || isset($_REQUEST["register"]))) {
        $new_nodeid = $node_data['nodeid'];
        $name = $node_data['name'];
        $timezone = $node_data['timezone'];
        $ip = $node_data['ip'];
        $port = $node_data['port'];
        $slave_history = $node_data['slave_history'];
        $slave_trends = $node_data['slave_trends'];
    } else {
        $new_nodeid = get_request('new_nodeid', 0);
        $name = get_request('name', '');
        $timezone = get_request('timezone', 0);
        $ip = get_request('ip', '127.0.0.1');
        $port = get_request('port', 10051);
        $slave_history = get_request('slave_history', 90);
        $slave_trends = get_request('slave_trends', 365);
        $node_type = get_request('node_type', ZBX_NODE_REMOTE);
        $masterid = get_request('masterid', get_current_nodeid(false));
    }
    $master_node = DBfetch(DBselect('SELECT name FROM nodes WHERE nodeid=' . $masterid));
    $frmNode->addRow(S_NAME, new CTextBox('name', $name, 40));
    $frmNode->addRow(S_ID, new CNumericBox('new_nodeid', $new_nodeid, 10));
    if (!isset($_REQUEST['nodeid'])) {
        $cmbNodeType = new CComboBox('node_type', $node_type, 'submit()');
        $cmbNodeType->addItem(ZBX_NODE_REMOTE, S_REMOTE);
        if ($ZBX_CURMASTERID == 0) {
            $cmbNodeType->addItem(ZBX_NODE_MASTER, S_MASTER);
        }
    } else {
        $cmbNodeType = new CTextBox('node_type_name', node_type2str($node_type), null, 'yes');
    }
    $frmNode->addRow(S_TYPE, $cmbNodeType);
    if ($node_type == ZBX_NODE_REMOTE) {
        $frmNode->addRow(S_MASTER_NODE, new CTextBox('master_name', $master_node['name'], 40, 'yes'));
    }
    $cmbTimeZone = new CComboBox('timezone', $timezone);
    for ($i = -12; $i <= 13; $i++) {
        $cmbTimeZone->addItem($i, "GMT" . sprintf("%+03d:00", $i));
    }
    $frmNode->addRow(S_TIME_ZONE, $cmbTimeZone);
    $frmNode->addRow(S_IP, new CTextBox('ip', $ip, 15));
    $frmNode->addRow(S_PORT, new CNumericBox('port', $port, 5));
    $frmNode->addRow(S_DO_NOT_KEEP_HISTORY_OLDER_THAN, new CNumericBox('slave_history', $slave_history, 6));
    $frmNode->addRow(S_DO_NOT_KEEP_TRENDS_OLDER_THAN, new CNumericBox('slave_trends', $slave_trends, 6));
    $frmNode->addItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['nodeid']) && $node_type != ZBX_NODE_LOCAL) {
        $frmNode->addItemToBottomRow(SPACE);
        $frmNode->addItemToBottomRow(new CButtonDelete("Delete selected node?", url_param("form") . url_param("nodeid")));
    }
    $frmNode->addItemToBottomRow(SPACE);
    $frmNode->addItemToBottomRow(new CButtonCancel(url_param("config")));
    $frmNode->Show();
}
** (at your option) any later version.
**
** This program is distributed in the hope that it will be useful,
** but WITHOUT ANY WARRANTY; without even the implied warranty of
** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
** GNU General Public License for more details.
**
** You should have received a copy of the GNU General Public License
** along with this program; if not, write to the Free Software
** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
**/
$nodeWidget = new CWidget();
$configComboBox = new CComboBox('config', 'nodes.php', 'javascript: redirect(this.options[this.selectedIndex].value);');
$configComboBox->addItem('nodes.php', _('Nodes'));
$configComboBox->addItem('proxies.php', _('Proxies'));
$nodeTable = new CTableInfo(_('Your setup is not configured for distributed monitoring.'));
$createForm = null;
if (ZBX_DISTRIBUTED) {
    $nodeWidget->addHeader(_('Nodes'));
    $createForm = new CForm();
    $createForm->cleanItems();
    $createForm->addItem(new CSubmit('form', _('Create node')));
    $nodeTable = new CTableInfo();
    $nodeTable->setHeader(array(make_sorting_header(_('ID'), 'n.nodeid'), make_sorting_header(_('Name'), 'n.name'), _('Type'), make_sorting_header(_('IP') . ' : ' . _('Port'), 'n.ip')));
    while ($node = DBfetch($this->data['nodes'])) {
        $nodeTable->addRow(array($node['nodeid'], array(get_node_path($node['masterid']), new CLink($node['name'], '?form=update&nodeid=' . $node['nodeid'])), node_type2str($node['nodetype']), $node['ip'] . ' : ' . $node['port']));
    }
}
$nodeWidget->addPageHeader(_('CONFIGURATION OF NODES'), array($configComboBox, $createForm));
$nodeWidget->addItem($nodeTable);
return $nodeWidget;
Exemple #3
0
    $cmbTimeZone = new CComboBox('timezone', $timezone);
    for ($i = -12; $i <= 13; $i++) {
        $cmbTimeZone->addItem($i, 'GMT' . sprintf('%+03d:00', $i));
    }
    $frmNode->addRow(S_TIME_ZONE, $cmbTimeZone);
    $frmNode->addRow(S_IP, new CTextBox('ip', $ip, 15));
    $frmNode->addRow(S_PORT, new CNumericBox('port', $port, 5));
    $frmNode->addRow(S_DO_NOT_KEEP_HISTORY_OLDER_THAN, new CNumericBox('slave_history', $slave_history, 6));
    $frmNode->addRow(S_DO_NOT_KEEP_TRENDS_OLDER_THAN, new CNumericBox('slave_trends', $slave_trends, 6));
    $frmNode->addItemToBottomRow(new CButton('save', S_SAVE));
    if (isset($_REQUEST['nodeid']) && $node_type != ZBX_NODE_LOCAL) {
        $frmNode->addItemToBottomRow(SPACE);
        $frmNode->addItemToBottomRow(new CButtonDelete('Delete selected node?', url_param('form') . url_param('nodeid')));
    }
    $frmNode->addItemToBottomRow(SPACE);
    $frmNode->addItemToBottomRow(new CButtonCancel(url_param('config')));
    $frmNode->Show();
} else {
    show_table_header(S_NODES_BIG);
    $table = new CTableInfo(S_NO_NODES_DEFINED);
    $table->SetHeader(array(make_sorting_link(S_ID, 'n.nodeid'), make_sorting_link(S_NAME, 'n.name'), make_sorting_link(S_TYPE, 'n.nodetype'), make_sorting_link(S_TIME_ZONE, 'n.timezone'), make_sorting_link(S_IP . ':' . S_PORT, 'n.ip')));
    $sql = 'SELECT n.* ' . ' FROM nodes n' . ' WHERE ' . DBcondition('n.nodeid', $available_nodes) . order_by('n.nodeid,n.name,n.nodetype,n.timezone,n.ip', 'n.masterid');
    $db_nodes = DBselect($sql);
    while ($row = DBfetch($db_nodes)) {
        $node_type = detect_node_type($row);
        $node_type_name = node_type2str($node_type);
        $table->AddRow(array($row['nodeid'], array(get_node_path($row['masterid']), new CLink($row['nodetype'] ? new CSpan($row['name'], 'bold') : $row['name'], '?&form=update&nodeid=' . $row['nodeid'], 'action')), $node_type == ZBX_NODE_LOCAL ? new CSpan($node_type_name, 'bold') : $node_type_name, new CSpan('GMT' . sprintf('%+03d:00', $row['timezone']), $row['nodetype'] ? 'bold' : null), new CSpan($row['ip'] . ':' . $row['port'], $row['nodetype'] ? 'bold' : null)));
    }
    $table->Show();
}
include_once 'include/page_footer.php';
Exemple #4
0
     $node_type = detect_node_type($node_data);
 } else {
     $new_nodeid = get_request('new_nodeid', 0);
     $name = get_request('name', '');
     $timezone = get_request('timezone', 0);
     $ip = get_request('ip', '127.0.0.1');
     $port = get_request('port', 10051);
     $slave_history = get_request('slave_history', 90);
     $slave_trends = get_request('slave_trends', 365);
     $node_type = get_request('node_type', ZBX_NODE_CHILD);
     $masterid = get_request('masterid', get_current_nodeid(false));
 }
 $frmNode->addRow(S_NAME, new CTextBox('name', $name, 40));
 $frmNode->addRow(S_ID, new CNumericBox('new_nodeid', $new_nodeid, 10));
 if (isset($_REQUEST['nodeid'])) {
     $cmbNodeType = new CTextBox('node_type_name', node_type2str($node_type), null, 'yes');
 } else {
     $cmbNodeType = new CComboBox('node_type', $node_type, 'submit()');
     $cmbNodeType->addItem(ZBX_NODE_CHILD, S_CHILD);
     if (!$has_master) {
         $cmbNodeType->addItem(ZBX_NODE_MASTER, S_MASTER);
     }
 }
 $frmNode->addRow(S_TYPE, $cmbNodeType);
 if ($node_type == ZBX_NODE_CHILD) {
     if (isset($_REQUEST['nodeid'])) {
         $master_cb = new CTextBox('master_name', $ZBX_NODES[$ZBX_NODES[$_REQUEST['nodeid']]['masterid']]['name'], null, 'yes');
     } else {
         $master_cb = new CComboBox('masterid', $masterid);
         foreach ($ZBX_NODES as $node) {
             if ($node['nodeid'] == $ZBX_LOCMASTERID) {
if (!empty($this->data['nodeid'])) {
    $nodeForm->addVar('nodeid', $this->data['nodeid']);
}
// create form list
$nodeFormList = new CFormList('nodeFormList');
// Name
$nodeFormList->addRow(_('Name'), new CTextBox('name', $this->data['name'], ZBX_TEXTBOX_STANDARD_SIZE));
// ID
$nodeFormList->addRow(_('ID'), new CNumericBox('new_nodeid', $this->data['new_nodeid'], 10, isset($this->data['nodeid'])));
// Type
if (empty($this->data['masterNode']) && empty($this->data['nodeid'])) {
    $nodeTypeField = new CComboBox('nodetype', $this->data['nodetype'], 'submit()');
    $nodeTypeField->addItem(ZBX_NODE_CHILD, node_type2str(ZBX_NODE_CHILD));
    $nodeTypeField->addItem(ZBX_NODE_MASTER, node_type2str(ZBX_NODE_MASTER));
} else {
    $nodeTypeField = node_type2str($this->data['nodetype']);
    $nodeForm->addVar('nodetype', $this->data['nodetype']);
}
$nodeFormList->addRow(_('Type'), $nodeTypeField);
// Master node
if ($this->data['masterid'] != 0 && $this->data['nodetype'] != ZBX_NODE_MASTER) {
    if (empty($this->data['nodeid'])) {
        $masterField = new CComboBox('masterid', $this->data['masterid']);
        foreach ($ZBX_NODES as $node) {
            if ($node['nodeid'] == $ZBX_LOCMASTERID) {
                continue;
            }
            $masterField->addItem($node['nodeid'], $node['name']);
        }
    } else {
        $masterField = $ZBX_NODES[$this->data['masterid']]['name'];