Ejemplo n.º 1
0
    $dashForm->addRow(S_GROUPS, array($lstGroups, BR(), $addButton, $delButton));
}
//HOSTS
// SPACE added to extend CB width in Chrome
$cbMain = new CCheckBox('maintenance', $maintenance, null, '1');
if (!$filterEnable) {
    $cbMain->setAttribute('disabled', 'disabled');
}
$dashForm->addRow(S_HOSTS, array($cbMain, S_SHOW_HOSTS_IN_MAINTENANCE));
// Trigger
$severity = zbx_toHash($severity);
$trgSeverities = array();
$severities = array(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_INFORMATION, TRIGGER_SEVERITY_WARNING, TRIGGER_SEVERITY_AVERAGE, TRIGGER_SEVERITY_HIGH, TRIGGER_SEVERITY_DISASTER);
foreach ($severities as $snum => $sever) {
    $cb = new CCheckBox('trgSeverity[' . $sever . ']', isset($severity[$sever]), '', 1);
    $cb->setEnabled($filterEnable);
    $trgSeverities[] = array($cb, getSeverityCaption($sever));
    $trgSeverities[] = BR();
}
array_pop($trgSeverities);
$dashForm->addRow(S_TRIGGERS_WITH_SEVERITY, $trgSeverities);
$config = select_config();
$cb = new CComboBox('extAck', $extAck);
$cb->addItems(array(EXTACK_OPTION_ALL => S_O_ALL, EXTACK_OPTION_BOTH => S_O_SEPARATED, EXTACK_OPTION_UNACK => S_O_UNACKNOWLEDGED_ONLY));
$cb->setEnabled($filterEnable && $config['event_ack_enable']);
if (!$config['event_ack_enable']) {
    $cb->setAttribute('title', S_EVENT_ACKNOWLEDGING_DISABLED);
}
$dashForm->addRow(S_PROBLEM_DISPLAY, $cb);
//-----
$dashForm->addItemToBottomRow(new CButton('save', S_SAVE));
$dashconfFormList->addRow(_('Host groups'), $hostGroupsComboBox);
if ($this->data['grpswitch']) {
    $dashconfFormList->addRow(_('Show selected groups'), new CMultiSelect(array('name' => 'groupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['groups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $dashconfForm->getName() . '&dstfld1=groupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450))));
    $dashconfFormList->addRow(_('Hide selected groups'), new CMultiSelect(array('name' => 'hidegroupids[]', 'objectName' => 'hostGroup', 'data' => $this->data['hideGroups'], 'disabled' => !$this->data['isFilterEnable'], 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $dashconfForm->getName() . '&dstfld1=hidegroupids_' . '&srcfld1=groupid&multiselect=1', 'width' => 450, 'height' => 450))));
}
// append host in maintenance checkbox to form list
$maintenanceCheckBox = new CCheckBox('maintenance', $this->data['maintenance'], null, '1');
if (!$this->data['isFilterEnable']) {
    $maintenanceCheckBox->setAttribute('disabled', 'disabled');
}
$dashconfFormList->addRow(_('Hosts'), array($maintenanceCheckBox, _('Show hosts in maintenance')));
// append trigger severities to form list
$severities = array();
foreach ($this->data['severities'] as $severity) {
    $serverityCheckBox = new CCheckBox('trgSeverity[' . $severity . ']', isset($this->data['severity'][$severity]), '', 1);
    $serverityCheckBox->setEnabled($this->data['isFilterEnable']);
    $severities[] = array($serverityCheckBox, getSeverityCaption($severity));
    $severities[] = BR();
}
array_pop($severities);
$dashconfFormList->addRow(_('Triggers with severity'), $severities);
// append problem display to form list
$extAckComboBox = new CComboBox('extAck', $this->data['extAck']);
$extAckComboBox->addItems(array(EXTACK_OPTION_ALL => _('All'), EXTACK_OPTION_BOTH => _('Separated'), EXTACK_OPTION_UNACK => _('Unacknowledged only')));
$extAckComboBox->setEnabled($this->data['isFilterEnable'] && $this->data['config']['event_ack_enable']);
if (!$this->data['config']['event_ack_enable']) {
    $extAckComboBox->setAttribute('title', _('Event acknowledging disabled'));
}
$dashconfFormList->addRow(_('Problem display'), $extAckComboBox);
// create tab
$dashconfTab = new CTabView();
        $realHosts = get_realhosts_by_graphid($graph['templateid']);
        $realHosts = DBfetch($realHosts);
        $name[] = new CLink($realHosts['name'], 'graphs.php?hostid=' . $realHosts['hostid'], 'unknown');
        $name[] = NAME_DELIMITER;
        $name[] = new CLink($graph['name'], 'graphs.php?' . 'form=update' . '&graphid=' . $graphid . url_param('parent_discoveryid') . '&hostid=' . $this->data['hostid']);
        $isCheckboxEnabled = false;
    } elseif (!empty($graph['discoveryRule']) && empty($this->data['parent_discoveryid'])) {
        $name[] = new CLink($graph['discoveryRule']['name'], 'host_discovery.php?form=update&itemid=' . $graph['discoveryRule']['itemid'], 'parent-discovery');
        $name[] = NAME_DELIMITER;
        $name[] = new CSpan($graph['name']);
        $isCheckboxEnabled = false;
    } else {
        $name[] = new CLink($graph['name'], 'graphs.php?' . 'form=update' . '&graphid=' . $graphid . url_param('parent_discoveryid') . '&hostid=' . $this->data['hostid']);
    }
    $checkBox = new CCheckBox('group_graphid[' . $graphid . ']', null, null, $graphid);
    $checkBox->setEnabled($isCheckboxEnabled);
    $graphTable->addRow(array($checkBox, $this->data['displayNodes'] ? $graph['nodename'] : null, $hostList, $name, $graph['width'], $graph['height'], $graph['graphtype']));
}
// create go buttons
$goComboBox = new CComboBox('go');
if (!$this->data['parent_discoveryid']) {
    $goComboBox->addItem('copy_to', _('Copy selected to ...'));
}
$goOption = new CComboItem('delete', _('Delete selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Delete selected graph prototypes?') : _('Delete selected graphs?'));
$goComboBox->addItem($goOption);
$goButton = new CSubmit('goButton', _('Go') . ' (0)');
$goButton->attr('id', 'goButton');
zbx_add_post_js('chkbxRange.pageGoName = "group_graphid";');
if ($this->data['parent_discoveryid']) {
    zbx_add_post_js('chkbxRange.prefix = "' . $this->data['parent_discoveryid'] . '";');
        $triggers = array();
        foreach ($item['triggers'] as $trigger) {
            foreach ($trigger['functions'] as $function) {
                if (!str_in_array($function['function'], array('regexp', 'iregexp'))) {
                    continue 2;
                }
            }
            $triggers[] = array('id' => $trigger['triggerid'], 'name' => $trigger['description']);
        }
        $menuIcon = new CIcon(_('Menu'), 'iconmenu_b');
        $menuIcon->setMenuPopup(CMenuPopupHelper::getTriggerLog($item['itemid'], $item['name'], $triggers));
    } else {
        $menuIcon = SPACE;
    }
    $checkBox = new CCheckBox('group_itemid[' . $item['itemid'] . ']', null, null, $item['itemid']);
    $checkBox->setEnabled(empty($item['discoveryRule']));
    $itemTable->addRow(array($checkBox, $menuIcon, empty($this->data['filter_hostid']) ? $item['host'] : null, $description, $triggerInfo, CHtml::encode($item['key_']), $item['type'] == ITEM_TYPE_TRAPPER || $item['type'] == ITEM_TYPE_SNMPTRAP ? '' : $item['delay'], $item['history'], in_array($item['value_type'], array(ITEM_VALUE_TYPE_STR, ITEM_VALUE_TYPE_LOG, ITEM_VALUE_TYPE_TEXT)) ? '' : $item['trends'], item_type2str($item['type']), new CCol(CHtml::encode($item['applications_list']), 'wraptext'), $status, $infoIcons));
}
// create go buttons
$goComboBox = new CComboBox('action');
$goOption = new CComboItem('item.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', _('Enable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', _('Disable selected items?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.masscopyto', _('Copy selected to ...'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem('item.massclearhistory', _('Clear history for selected'));
Ejemplo n.º 5
0
     }
     // for 'unixtime' change should be calculated as uptime
     $change .= convert_units(array('value' => bcsub($lastHistory['value'], $prevHistory['value'], $digits), 'units' => $item['units'] == 'unixtime' ? 'uptime' : $item['units']));
     $change = nbsp($change);
 } else {
     $change = UNKNOWN_VALUE;
 }
 // column "action"
 $showLink = ($config['hk_history_global'] && $config['hk_history'] == 0 || $item['history'] == 0) && ($config['hk_trends_global'] && $config['hk_trends'] == 0 || $item['trends'] == 0);
 $checkbox = new CCheckBox('itemids[' . $item['itemid'] . ']', null, null, $item['itemid']);
 $checkbox->removeAttribute('id');
 if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('Graph'), 'history.php?action=' . HISTORY_GRAPH . '&itemids[]=' . $item['itemid']);
 } else {
     $actions = $showLink ? UNKNOWN_VALUE : new CLink(_('History'), 'history.php?action=' . HISTORY_VALUES . '&itemids[]=' . $item['itemid']);
     $checkbox->setEnabled(false);
 }
 $stateCss = $item['state'] == ITEM_STATE_NOTSUPPORTED ? 'unknown' : '';
 $host = $hosts[$item['hostid']];
 if ($filter['showDetails']) {
     // item key
     $itemKey = $item['type'] == ITEM_TYPE_HTTPTEST || $item['flags'] == ZBX_FLAG_DISCOVERY_CREATED ? new CSpan($item['key_expanded'], 'enabled') : new CLink($item['key_expanded'], 'items.php?form=update&itemid=' . $item['itemid'], 'enabled');
     // info
     if ($item['status'] == ITEM_STATUS_ACTIVE && $item['error'] !== '') {
         $info = new CDiv(null, 'status_icon iconerror');
         $info->setHint($item['error'], 'on');
     } else {
         $info = '';
     }
     // trend value
     if ($item['value_type'] == ITEM_VALUE_TYPE_FLOAT || $item['value_type'] == ITEM_VALUE_TYPE_UINT64) {
    } else {
        $status = new CLink(triggerIndicator($trigger['status'], $trigger['state']), 'triggers.php?' . 'action=' . ($trigger['status'] == TRIGGER_STATUS_DISABLED ? 'trigger.massenable' : 'trigger.massdisable') . '&hostid=' . $this->data['hostid'] . '&g_triggerid=' . $triggerid, triggerIndicatorStyle($trigger['status'], $trigger['state']));
    }
    // hosts
    $hosts = null;
    if (empty($this->data['hostid'])) {
        foreach ($trigger['hosts'] as $hostid => $host) {
            if (!empty($hosts)) {
                $hosts[] = ', ';
            }
            $hosts[] = $host['name'];
        }
    }
    // checkbox
    $checkBox = new CCheckBox('g_triggerid[' . $triggerid . ']', null, null, $triggerid);
    $checkBox->setEnabled(empty($trigger['discoveryRule']));
    $triggersTable->addRow(array($checkBox, getSeverityCell($trigger['priority']), $hosts, $description, new CCol(triggerExpression($trigger, true), 'trigger-expression'), $status, $info));
}
// create go button
$actionObject = $this->data['parent_discoveryid'] ? 'triggerprototype' : 'trigger';
$goComboBox = new CComboBox('action');
$goOption = new CComboItem($actionObject . '.massenable', _('Enable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Enable selected trigger prototypes?') : _('Enable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massdisable', _('Disable selected'));
$goOption->setAttribute('confirm', $this->data['parent_discoveryid'] ? _('Disable selected trigger prototypes?') : _('Disable selected triggers?'));
$goComboBox->addItem($goOption);
$goOption = new CComboItem($actionObject . '.massupdateform', _('Mass update'));
$goComboBox->addItem($goOption);
if (empty($this->data['parent_discoveryid'])) {
    $goOption = new CComboItem($actionObject . '.masscopyto', _('Copy selected to ...'));
Ejemplo n.º 7
0
 $hostgroups = API::HostGroup()->get($options);
 order_result($hostgroups, 'name');
 $data = array();
 $parentId = $dstfld1 ? zbx_jsvalue($dstfld1) : 'null';
 foreach ($hostgroups as &$hostgroup) {
     $name = new CSpan($hostgroup['name'], 'link');
     $name->attr('id', 'spanid' . $hostgroup['groupid']);
     $jsAction = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($hostgroup['groupid']) . ', ' . $parentId . ');';
     if ($multiselect) {
         $checkBox = new CCheckBox('hostGroups[' . zbx_jsValue('groupid') . ']', null, null, $hostgroup['groupid']);
     }
     // check for existing
     if (isset($excludeids[$hostgroup['groupid']])) {
         if ($multiselect) {
             $checkBox->setChecked(1);
             $checkBox->setEnabled('disabled');
         }
         $name->removeAttr('class');
     } else {
         $name->setAttribute('onclick', $jsAction . ' jQuery(this).removeAttr("onclick");');
         $data[$hostgroup['groupid']] = array('id' => $hostgroup['groupid'], 'name' => $hostgroup['name'], 'prefix' => get_node_name_by_elid($hostgroup['groupid'], null, NAME_DELIMITER));
     }
     $table->addRow(array($multiselect ? $checkBox : null, $name));
 }
 unset($hostgroup);
 if ($multiselect) {
     $button = new CButton('select', _('Select'), "javascript: addSelectedValues('hostGroups', " . zbx_jsvalue($reference) . ', ' . $parentId . ');');
     $table->setFooter(new CCol($button, 'right'));
 }
 insert_js('var popupReference = ' . zbx_jsvalue($data, true) . ';');
 zbx_add_post_js('chkbxRange.pageGoName = "hostGroups";');
Ejemplo n.º 8
0
         unset($new_templates);
     }
 }
 $table = new CTableInfo(S_NO_TEMPLATES_DEFINED);
 $table->SetHeader(array(S_NAME));
 $sql_from = '';
 $sql_where = '';
 if ($groupid > 0) {
     $sql_from .= ',hosts_groups hg ';
     $sql_where .= ' AND hg.groupid=' . $groupid . ' AND h.hostid=hg.hostid ';
 }
 $sql = 'SELECT DISTINCT h.* ' . ' FROM hosts h' . $sql_from . ' WHERE ' . DBin_node('h.hostid', $nodeid) . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND h.status=' . HOST_STATUS_TEMPLATE . $sql_where . ' ORDER BY h.host,h.hostid';
 $db_hosts = DBselect($sql);
 while ($host = DBfetch($db_hosts)) {
     $chk = new CCheckBox('templates[' . $host['hostid'] . ']', isset($templates[$host['hostid']]), null, $host['host']);
     $chk->setEnabled(!isset($existed_templates[$host['hostid']]));
     $table->addRow(array(array($chk, $host['host'])));
     unset($host);
 }
 $table->SetFooter(new CButton('select', S_SELECT));
 $form = new CForm();
 $form->addVar('existed_templates', $existed_templates);
 if ($monitored_hosts) {
     $form->addVar('monitored_hosts', 1);
 }
 if ($real_hosts) {
     $form->addVar('real_hosts', 1);
 }
 $form->addVar('dstfrm', $dstfrm);
 $form->addVar('dstfld1', $dstfld1);
 $form->addVar('srctbl', $srctbl);
Ejemplo n.º 9
0
             $host_list[] = $template['host'];
         }
         $host_list = implode(', ', $host_list);
     }
     $name = array();
     if ($graph['templateid'] != 0) {
         $real_hosts = get_realhosts_by_graphid($graph['templateid']);
         $real_host = DBfetch($real_hosts);
         $name[] = new CLink($real_host['host'], 'graphs.php?' . 'hostid=' . $real_host['hostid'], 'unknown');
         $name[] = ':' . $graph['name'];
     } else {
         $name[] = new CLink($graph['name'], 'graphs.php?graphid=' . $graphid . '&form=update');
     }
     $chkBox = new CCheckBox('group_graphid[' . $graphid . ']', NULL, NULL, $graphid);
     if ($graph['templateid'] > 0) {
         $chkBox->setEnabled(false);
     }
     $table->addRow(array($chkBox, $host_list, $name, $graph['width'], $graph['height'], $graph['graphtype']));
 }
 //----- GO ------
 $goBox = new CComboBox('go');
 $goBox->addItem('copy_to', S_COPY_SELECTED_TO);
 $goOption = new CComboItem('delete', S_DELETE_SELECTED);
 $goOption->setAttribute('confirm', S_DELETE_SELECTED_GRAPHS);
 $goBox->addItem($goOption);
 // goButton name is necessary!!!
 $goButton = new CButton('goButton', S_GO);
 $goButton->setAttribute('id', 'goButton');
 zbx_add_post_js('chkbxRange.pageGoName = "group_graphid";');
 $footer = get_table_header(new CCol(array($goBox, $goButton)));
 //----
        CArrayHelper::sort($application['sourceTemplates'], ['name']);
        foreach ($application['sourceTemplates'] as $template) {
            $name[] = (new CLink($template['name'], 'applications.php?hostid=' . $template['hostid']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_GREY);
            $name[] = ', ';
        }
        array_pop($name);
        $name[] = NAME_DELIMITER;
        $name[] = $application['name'];
        $info_icons[] = '';
    } elseif ($application['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $application['discoveryRule']) {
        $name = [(new CLink(CHtml::encode($application['discoveryRule']['name']), 'disc_prototypes.php?parent_discoveryid=' . $application['discoveryRule']['itemid']))->addClass(ZBX_STYLE_LINK_ALT)->addClass(ZBX_STYLE_ORANGE)];
        $name[] = NAME_DELIMITER . $application['name'];
        if ($application['applicationDiscovery']['ts_delete'] != 0) {
            $info_icons[] = getApplicationLifetimeIndicator($current_time, $application['applicationDiscovery']['ts_delete']);
        } else {
            $info_icons[] = '';
        }
    } else {
        $name = new CLink($application['name'], 'applications.php?form=update&applicationid=' . $application['applicationid'] . '&hostid=' . $application['hostid']);
        $info_icons[] = '';
    }
    $checkBox = new CCheckBox('applications[' . $application['applicationid'] . ']', $application['applicationid']);
    $checkBox->setEnabled(!$application['discoveryRule']);
    $applicationTable->addRow([$checkBox, $this->data['hostid'] > 0 ? null : $application['host']['name'], (new CCol($name))->addClass(ZBX_STYLE_NOWRAP), [new CLink(_('Items'), 'items.php?' . 'hostid=' . $application['hostid'] . '&filter_set=1' . '&filter_application=' . urlencode($application['name'])), CViewHelper::showNum(count($application['items']))], $data['showInfoColumn'] ? $info_icons : null]);
}
zbx_add_post_js('cookie.prefix = "' . $this->data['hostid'] . '";');
// append table to form
$form->addItem([$applicationTable, $this->data['paging'], new CActionButtonList('action', 'applications', ['application.massenable' => ['name' => _('Enable'), 'confirm' => _('Enable selected applications?')], 'application.massdisable' => ['name' => _('Disable'), 'confirm' => _('Disable selected applications?')], 'application.massdelete' => ['name' => _('Delete'), 'confirm' => _('Delete selected applications?')]], $this->data['hostid'])]);
// append form to widget
$widget->addItem($form);
return $widget;