$inventoryFieldsComboBox->addItem($inventoryField['db_field'], $inventoryField['title']); } $exactComboBox = new CComboBox('filter_exact', $this->data['filterExact']); $exactComboBox->addItem('0', _('like')); $exactComboBox->addItem('1', _('exactly')); $filterTable->addRow(array(array(array(bold(_('Field')), SPACE, $inventoryFieldsComboBox), array($exactComboBox, new CTextBox('filter_field_value', $this->data['filterFieldValue'], 20)))), 'host-inventories'); $filter = new CSubmit('filter_set', _('Filter')); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset')); $reset->useJQueryStyle(); $divButtons = new CDiv(array($filter, SPACE, $reset)); $divButtons->setAttribute('style', 'padding: 4px 0px;'); $footerCol = new CCol($divButtons, 'controls'); $filterTable->addRow($footerCol); $filterForm = new CForm('get'); $filterForm->setAttribute('name', 'zbx_filter'); $filterForm->setAttribute('id', 'zbx_filter'); $filterForm->addItem($filterTable); $hostInventoryWidget->addFlicker($filterForm, CProfile::get('web.hostinventories.filter.state', 0)); $hostInventoryWidget->addHeaderRowNumber(); $table = new CTableInfo(_('No hosts found.')); $table->setHeader(array(make_sorting_header(_('Host'), 'name', $this->data['sort'], $this->data['sortorder']), _('Group'), make_sorting_header(_('Name'), 'pr_name', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Type'), 'pr_type', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('OS'), 'pr_os', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Serial number A'), 'pr_serialno_a', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('Tag'), 'pr_tag', $this->data['sort'], $this->data['sortorder']), make_sorting_header(_('MAC address A'), 'pr_macaddress_a', $this->data['sort'], $this->data['sortorder']))); foreach ($this->data['hosts'] as $host) { $hostGroups = array(); foreach ($host['groups'] as $group) { $hostGroups[] = $group['name']; } natsort($hostGroups); $hostGroups = implode(', ', $hostGroups); $row = array(new CLink($host['name'], '?hostid=' . $host['hostid'] . url_param('groupid'), $host['status'] == HOST_STATUS_NOT_MONITORED ? 'not-monitored' : ''), $hostGroups, zbx_str2links($host['inventory']['name']), zbx_str2links($host['inventory']['type']), zbx_str2links($host['inventory']['os']), zbx_str2links($host['inventory']['serialno_a']), zbx_str2links($host['inventory']['tag']), zbx_str2links($host['inventory']['macaddress_a'])); $table->addRow($row);
$menu_table->setCellSpacing(0); $menu_table->setCellPadding(5); $menu_table->addRow($main_menu); $node_form = null; if (ZBX_DISTRIBUTED && !defined('ZBX_HIDE_NODE_SELECTION')) { insert_js_function('check_all'); $available_nodes = get_accessible_nodes_by_user(CWebUser::$data, PERM_READ, PERM_RES_DATA_ARRAY); $available_nodes = get_tree_by_parentid($ZBX_LOCALNODEID, $available_nodes, 'masterid'); // remove parent nodes if (empty($available_nodes[0])) { unset($available_nodes[0]); } if (!empty($available_nodes)) { $node_form = new CForm('get'); $node_form->cleanItems(); $node_form->setAttribute('id', 'node_form'); // create ComboBox with selected nodes $nodesComboBox = null; if (count($ZBX_VIEWED_NODES['nodes']) > 0) { $nodesComboBox = new CComboBox('switch_node', $ZBX_VIEWED_NODES['selected'], 'submit()'); foreach ($ZBX_VIEWED_NODES['nodes'] as $nodeid => $nodedata) { $nodesComboBox->addItem($nodeid, $nodedata['name']); } } $jscript = 'javascript: ' . " var pos = getPosition('button_show_tree');" . " showHide('div_node_tree', 'table');" . ' pos.top += 20;' . " \$('div_node_tree').setStyle({top: pos.top + 'px'});"; $button_show_tree = new CButton('show_node_tree', _('Select Nodes'), $jscript); $button_show_tree->setAttribute('id', 'button_show_tree'); // create node tree $node_tree = array(); $node_tree[0] = array('id' => 0, 'caption' => _('All'), 'combo_select_node' => new CCheckbox('check_all_nodes', null, "javascript : check_all('node_form', this.checked);"), 'parentid' => 0); foreach ($available_nodes as $node) {
function getItemFilterForm(&$items) { $filter_groupId = $_REQUEST['filter_groupid']; $filter_hostId = $_REQUEST['filter_hostid']; $filter_application = $_REQUEST['filter_application']; $filter_name = $_REQUEST['filter_name']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_port = $_REQUEST['filter_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_state = $_REQUEST['filter_state']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_state = $_REQUEST['subfilter_state']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm('get'); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_state', $subfilter_state); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // type select $fTypeVisibility = array(); $cmbType = new CComboBox('filter_type', $filter_type); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, _('all')); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); unset($itemTypes[ITEM_TYPE_HTTPTEST]); // httptest items are only for internal zabbix logic $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_port_label', 'filter_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ');'); // type of information select $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); $cmbValType->addItem(-1, _('all')); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, _('Numeric (unsigned)')); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, _('Numeric (float)')); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, _('Character')); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, _('Log')); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, _('Text')); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ');'); // status select $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, _('all')); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED) as $status) { $cmbStatus->addItem($status, item_status2str($status)); } // state select $cmbState = new CComboBox('filter_state', $filter_state); $cmbState->addItem(-1, _('all')); foreach (array(ITEM_STATE_NORMAL, ITEM_STATE_NOTSUPPORTED) as $state) { $cmbState->addItem($state, itemState($state)); } // update interval $updateIntervalLabel = new CSpan(array(bold(_('Update interval')), SPACE . _('(in sec)') . NAME_DELIMITER)); $updateIntervalLabel->setAttribute('id', 'filter_delay_label'); $updateIntervalInput = new CNumericBox('filter_delay', $filter_delay, 5, false, true); $updateIntervalInput->setEnabled('no'); // data type $dataTypeLabel = new CSpan(bold(_('Data type') . NAME_DELIMITER)); $dataTypeLabel->setAttribute('id', 'filter_data_type_label'); $dataTypeInput = new CComboBox('filter_data_type', $filter_data_type); $dataTypeInput->addItem(-1, _('all')); $dataTypeInput->addItems(item_data_type2str()); $dataTypeInput->setEnabled('no'); // filter table $table = new CTable('', 'filter'); $table->setCellPadding(0); $table->setCellSpacing(0); // SNMP community $snmpCommunityLabel = new CSpan(array(bold(_('SNMP community')), SPACE . _('like') . NAME_DELIMITER)); $snmpCommunityLabel->setAttribute('id', 'filter_snmp_community_label'); $snmpCommunityField = new CTextBox('filter_snmp_community', $filter_snmp_community, ZBX_TEXTBOX_FILTER_SIZE); $snmpCommunityField->setEnabled('no'); // SNMPv3 security name $snmpSecurityLabel = new CSpan(array(bold(_('Security name')), SPACE . _('like') . NAME_DELIMITER)); $snmpSecurityLabel->setAttribute('id', 'filter_snmpv3_securityname_label'); $snmpSecurityField = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, ZBX_TEXTBOX_FILTER_SIZE); $snmpSecurityField->setEnabled('no'); // SNMP OID $snmpOidLabel = new CSpan(array(bold(_('SNMP OID')), SPACE . _('like') . NAME_DELIMITER)); $snmpOidLabel->setAttribute('id', 'filter_snmp_oid_label'); $snmpOidField = new CTextBox('filter_snmp_oid', $filter_snmp_oid, ZBX_TEXTBOX_FILTER_SIZE); $snmpOidField->setEnabled('no'); // port $portLabel = new CSpan(array(bold(_('Port')), SPACE . _('like') . NAME_DELIMITER)); $portLabel->setAttribute('id', 'filter_port_label'); $portField = new CNumericBox('filter_port', $filter_port, 5, false, true); $portField->setEnabled('no'); // row 1 $groupFilter = null; if (!empty($filter_groupId)) { $getHostInfo = API::HostGroup()->get(array('groupids' => $filter_groupId, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $groupFilter[] = array('id' => $getHostInfo['groupid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host group') . NAME_DELIMITER), 'label col1'), new CCol(array(new CMultiSelect(array('name' => 'filter_groupid', 'selectedLimit' => 1, 'objectName' => 'hostGroup', 'objectOptions' => array('editable' => true), 'data' => $groupFilter, 'popup' => array('parameters' => 'srctbl=host_groups&dstfrm=' . $form->getName() . '&dstfld1=filter_groupid' . '&srcfld1=groupid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol(bold(_('Type') . NAME_DELIMITER), 'label col2'), new CCol($cmbType, 'col2'), new CCol(bold(_('Type of information') . NAME_DELIMITER), 'label col3'), new CCol($cmbValType, 'col3'), new CCol(bold(_('State') . NAME_DELIMITER), 'label'), new CCol($cmbState, 'col4')), 'item-list-row'); // row 2 $hostFilterData = null; if (!empty($filter_hostId)) { $getHostInfo = API::Host()->get(array('hostids' => $filter_hostId, 'templated_hosts' => true, 'output' => array('name'))); $getHostInfo = reset($getHostInfo); if (!empty($getHostInfo)) { $hostFilterData[] = array('id' => $getHostInfo['hostid'], 'name' => $getHostInfo['name']); } } $table->addRow(array(new CCol(bold(_('Host') . NAME_DELIMITER), 'label'), new CCol(array(new CMultiSelect(array('name' => 'filter_hostid', 'selectedLimit' => 1, 'objectName' => 'hosts', 'objectOptions' => array('editable' => true, 'templated_hosts' => true), 'data' => $hostFilterData, 'popup' => array('parameters' => 'srctbl=host_templates&dstfrm=' . $form->getName() . '&dstfld1=filter_hostid' . '&srcfld1=hostid&writeonly=1', 'width' => 450, 'height' => 450, 'buttonClass' => 'input filter-multiselect-select-button')))), 'col1'), new CCol($updateIntervalLabel, 'label'), new CCol($updateIntervalInput), new CCol($dataTypeLabel, 'label'), new CCol($dataTypeInput), new CCol(bold(_('Status') . NAME_DELIMITER), 'label col4'), new CCol($cmbStatus, 'col4')), 'item-list-row'); // row 3 $table->addRow(array(new CCol(bold(_('Application') . NAME_DELIMITER), 'label'), new CCol(array(new CTextBox('filter_application', $filter_application, ZBX_TEXTBOX_FILTER_SIZE), new CButton('btn_app', _('Select'), 'return PopUp("popup.php?srctbl=applications&srcfld1=name' . '&dstfrm=' . $form->getName() . '&dstfld1=filter_application' . '&with_applications=1' . '" + (jQuery("input[name=\'filter_hostid\']").length > 0 ? "&hostid="+jQuery("input[name=\'filter_hostid\']").val() : "")' . ', 550, 450, "application");', 'filter-select-button')), 'col1'), new CCol(array($snmpCommunityLabel, $snmpSecurityLabel), 'label'), new CCol(array($snmpCommunityField, $snmpSecurityField)), new CCol(array(bold(_('History')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_history', $filter_history, 8, false, true)), new CCol(bold(_('Triggers') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_with_triggers', $filter_with_triggers, null, array(-1 => _('all'), 1 => _('With triggers'), 0 => _('Without triggers'))))), 'item-list-row'); // row 4 $table->addRow(array(new CCol(array(bold(_('Name')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_name', $filter_name, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($snmpOidLabel, 'label'), new CCol($snmpOidField), new CCol(array(bold(_('Trends')), SPACE . _('(in days)') . NAME_DELIMITER), 'label'), new CCol(new CNumericBox('filter_trends', $filter_trends, 8, false, true)), new CCol(bold(_('Template') . NAME_DELIMITER), 'label'), new CCol(new CComboBox('filter_templated_items', $filter_templated_items, null, array(-1 => _('all'), 1 => _('Templated items'), 0 => _('Not Templated items'))))), 'item-list-row'); // row 5 $table->addRow(array(new CCol(array(bold(_('Key')), SPACE . _('like') . NAME_DELIMITER), 'label'), new CCol(new CTextBox('filter_key', $filter_key, ZBX_TEXTBOX_FILTER_SIZE), 'col1'), new CCol($portLabel, 'label'), new CCol($portField), new CCol(null, 'label'), new CCol(), new CCol(null, 'label'), new CCol()), 'item-list-row'); $filter = new CSubmit('filter_set', _('Filter'), 'chkbxRange.clearSelectedOnFilterChange();'); $filter->useJQueryStyle('main'); $reset = new CSubmit('filter_rst', _('Reset'), 'chkbxRange.clearSelectedOnFilterChange();'); $reset->useJQueryStyle(); $div_buttons = new CDiv(array($filter, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0px;'); $footer = new CCol($div_buttons, 'controls', 8); $table->addRow($footer); $form->addItem($table); // subfilters $table_subfilter = new CTable(null, 'filter sub-filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'state' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $item) { // hosts if (zbx_empty($filter_hostId)) { $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['name'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications if (!empty($item['applications'])) { foreach ($item['applications'] as $application) { if (!isset($item_params['applications'][$application['name']])) { $item_params['applications'][$application['name']] = array('name' => $application['name'], 'count' => 0); } } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => itemValueTypeString($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // state if ($filter_state == -1) { if (!isset($item_params['state'][$item['state']])) { $item_params['state'][$item['state']] = array('name' => itemState($item['state']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_state') { continue; } $show_item &= $value; } if ($show_item) { $item_params['state'][$item['state']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => _('Not Templated items'), 'count' => 0); } elseif ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => _('Templated items'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => _('Without triggers'), 'count' => 0); } elseif (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => _('With triggers'), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_hostId) && count($item_params['hosts']) > 1) { $hosts_output = prepareSubfilterOutput($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(_('Hosts'), $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepareSubfilterOutput($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(_('Applications'), $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepareSubfilterOutput($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(_('Types'), $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepareSubfilterOutput($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(_('Type of information'), $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepareSubfilterOutput($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(_('Status'), $status_output)); } if ($filter_state == -1 && count($item_params['state']) > 1) { $state_output = prepareSubfilterOutput($item_params['state'], $subfilter_state, 'subfilter_state'); $table_subfilter->addRow(array(_('State'), $state_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepareSubfilterOutput($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(_('Template'), $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepareSubfilterOutput($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(_('With triggers'), $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepareSubfilterOutput($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(_('History'), $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepareSubfilterOutput($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(_('Trends'), $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepareSubfilterOutput($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(_('Interval'), $interval_output)); } $form->addItem(new CDiv(_('Subfilter [affects only filtered data!]'), 'thin_header')); $form->addItem($table_subfilter); return $form; }
** 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. **/ $dashconfWidget = new CWidget(); $dashconfWidget->setClass('header'); $dashconfWidget->addPageHeader(_('DASHBOARD CONFIGURATION')); // create form $dashconfForm = new CForm(); $dashconfForm->setName('dashconf'); $dashconfForm->setAttribute('id', 'dashform'); $dashconfForm->addVar('filterEnable', $this->data['isFilterEnable']); // create form list $dashconfFormList = new CFormList('dashconfFormList'); // append filter status to form list if ($this->data['isFilterEnable']) { $filterStatusSpan = new CSpan(_('Enabled'), 'green underline pointer'); $filterStatusSpan->setAttribute('onclick', "create_var('" . $dashconfForm->getName() . "', 'filterEnable', 0, true);"); } else { $filterStatusSpan = new CSpan(_('Disabled'), 'red underline pointer'); $filterStatusSpan->setAttribute('onclick', "\$('dashform').enable(); create_var('" . $dashconfForm->getName() . "', 'filterEnable', 1, true);"); } $dashconfFormList->addRow(_('Dashboard filter'), $filterStatusSpan); // append host groups to form list $hostGroupsComboBox = new CComboBox('grpswitch', $this->data['grpswitch'], 'submit();'); $hostGroupsComboBox->addItem(0, _('All'));
** 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. **/ $scriptsWidget = new CWidget(); $createForm = new CForm('get'); $createForm->addItem(new CSubmit('form', _('Create script'))); $scriptsWidget->addPageHeader(_('CONFIGURATION OF SCRIPTS'), $createForm); $scriptsWidget->addHeader(_('Scripts')); $scriptsWidget->addHeaderRowNumber(); $scriptsForm = new CForm(); $scriptsForm->setName('scriptsForm'); $scriptsForm->setAttribute('id', 'scripts'); $scriptsTable = new CTableInfo(_('No scripts found.')); $scriptsTable->setHeader(array(new CCheckBox('all_scripts', null, "checkAll('" . $scriptsForm->getName() . "', 'all_scripts', 'scripts');"), make_sorting_header(_('Name'), 'name', $this->data['sort'], $this->data['sortorder']), _('Type'), _('Execute on'), make_sorting_header(_('Commands'), 'command', $this->data['sort'], $this->data['sortorder']), _('User group'), _('Host group'), _('Host access'))); foreach ($this->data['scripts'] as $script) { switch ($script['type']) { case ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT: $scriptType = _('Script'); break; case ZBX_SCRIPT_TYPE_IPMI: $scriptType = _('IPMI'); break; default: $scriptType = ''; break; } if ($script['type'] == ZBX_SCRIPT_TYPE_CUSTOM_SCRIPT) {
$comboform = new CForm(); $comboform->addVar('dstfrm', $dstfrm); // create table header + $cmbGroups = new CComboBox('groupid', $groupid, 'submit()'); $cmbGroups->addItem(0, S_ALL_S); $sql = 'SELECT usrgrpid, name FROM usrgrp WHERE ' . DBin_node('usrgrpid') . ' ORDER BY name'; $result = DBselect($sql); while ($row = DBfetch($result)) { $cmbGroups->addItem($row['usrgrpid'], $row['name']); } $comboform->addItem($cmbGroups); show_table_header(S_USERS, $comboform); // - // create user twinbox + $form = new CForm('users.php'); $form->setAttribute('id', 'users'); $user_tb = new CTweenBox($form, 'usersid', null, 10); $from = ''; $where = ''; if ($groupid > 0) { $from = ', users_groups g '; $where = ' AND u.userid=g.userid AND g.usrgrpid=' . $groupid; } $sql = 'SELECT u.userid, u.alias FROM users u ' . $from . ' WHERE ' . DBin_node('u.userid') . $where . ' ORDER BY name'; $result = DBselect($sql); while ($row = DBfetch($result)) { $user_tb->addItem($row['userid'], $row['alias'], false); } $form->addItem($user_tb->get('asdasda', 'asdasdasdas')); // - $button = new CButton('select', S_SELECT, 'add_users("' . $dstfrm . '")');
$frmTitle->addVar('dstfrm', $dstfrm); $frmTitle->addVar('permission', $permission); if (ZBX_DISTRIBUTED) { $available_nodes = get_accessible_nodes_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY); $cmbResourceNode = new CComboBox('nodeid', $nodeid, 'submit();'); $cmbResourceNode->addItem(0, S_ALL_S); $sql = 'SELECT name,nodeid ' . ' FROM nodes ' . ' WHERE ' . DBcondition('nodeid', $available_nodes); $db_nodes = DBselect($sql); while ($node = DBfetch($db_nodes)) { $cmbResourceNode->addItem($node['nodeid'], $node['name']); } $frmTitle->addItem(array(S_NODE, SPACE, $cmbResourceNode)); } show_table_header(permission2str($permission), $frmTitle); $form = new CForm(); $form->setAttribute('id', 'groups'); $table = new CTableInfo(S_NO_RESOURCES_DEFINED); $table->setHeader(new CCol(array(new CCheckBox('all_groups', NULL, 'check_all(this.checked)'), S_NAME))); // NODES if ($nodeid == 0) { $nodeids = get_current_nodeid(true); } else { $nodeids = $nodeid; } $count = 0; $grouplist = array(); $options = array('nodeids' => $nodeids, 'output' => API_OUTPUT_EXTEND); $groups = CHostGroup::get($options); foreach ($groups as $gnum => $row) { $groups[$gnum]['nodename'] = get_node_name_by_elid($row['groupid'], true, ':') . $row['name']; if ($nodeid == 0) {
} $table->addRow($name); } if ($multiselect) { $button = new CButton('select', _('Select'), "javascript: addSelectedValues('slides', " . zbx_jsvalue($reference) . ');'); $table->setFooter(new CCol($button, 'right')); insert_js('var popupReference = ' . zbx_jsvalue($slideshows, true) . ';'); } zbx_add_post_js('chkbxRange.pageGoName = "slides";'); $form->addItem($table); $form->show(); } elseif ($srctbl == 'screens') { require_once dirname(__FILE__) . '/include/screens.inc.php'; $form = new CForm(); $form->setName('screenform'); $form->setAttribute('id', 'screens'); $table = new CTableInfo(_('No screens found.')); if ($multiselect) { $header = array(array(new CCheckBox('all_screens', null, "javascript: checkAll('" . $form->getName() . "', 'all_screens', 'screens');"), _('Name'))); } else { $header = array(_('Name')); } $table->setHeader($header); $screens = API::Screen()->get(array('nodeids' => $nodeId, 'output' => array('screenid', 'name'), 'preservekeys' => true, 'editable' => $writeonly === null ? null : true)); order_result($screens, 'name'); foreach ($screens as $screen) { $name = new CSpan($screen['name'], 'link'); if ($multiselect) { $js_action = 'javascript: addValue(' . zbx_jsvalue($reference) . ', ' . zbx_jsvalue($screen['screenid']) . ');'; } else { $values = array($dstfld1 => $screen[$srcfld1], $dstfld2 => $screen[$srcfld2]);
function make_hint_row($type, $instance) { $state = $instance['state']; if ($type == "other" && $instance["stuck_state"] == 1) { $state = "stuck"; } $r = new CRow(); if (in_array($type, array("poweron", "poweroff", "suspend"))) { $r->addItem(new CCheckBox("hostids[]", null, null, $instance['hostid'])); } $hostScripts = API::Script()->getScriptsByHosts(zbx_objectValues(array($instance['host']), 'hostid')); $hostSpan = new CSpan(nbsp($instance['name']), 'link_menu menu-host'); $hostSpan->setAttribute('data-menu', hostMenuData($instance['host'], $hostScripts[$instance['hostid']])); $r->addItem($hostSpan); $r->addItem(new CCol($state, get_item_level($state))); $r->addItem($instance['cpu']); $r->addItem($instance['memory']); $r->addItem($instance['main_interface']); if ($type == "other" && $instance["stuck_state"] == 1) { $question = $instance['stuck_question']; $json = new CJSON(); $choiceinfos = $json->decode($instance['stuck_choices'], true); $answer_form = new CForm(); $answer_form->setAction('#'); $answer_form->setAttribute('id', "answer"); $answer_form->addVar("driver", "vsphere"); $answer_form->addVar("hostids[]", $instance['hostid']); $instancename = $instance['host']['host']; $answer_button = new CButton('answer', _('Answer'), "return checkAnswer('answer', 'choice', '{$instancename}', 'Execute');"); $choice_table = new CTableInfo(); foreach ($choiceinfos as $choice) { $radio = new CRadioButton('choice', $choice['key']); $label = new CLabel($choice['label']); $choice_table->addRow(new CRow(array($radio, $label))); } $answer_form->addItem($choice_table); $answer_form->addItem($answer_button); $question_span = new CSpan($question); $question_span->setHint($answer_form); $question_col = new CCol($question_span, 'warning'); $r->addItem($question_col); } else { if ($type == "poweron") { $ssh_link = new CLink(_('connect'), "gateone.php?hostid={$instance['hostid']}"); $ssh_link->setTarget("_blank"); $r->addItem($ssh_link); } } return $r; }
function make_ipmistat_summary($preloading = false) { $form_name = 'ipmi_control'; $table = new CTableInfo(); $ipmicontrol_form = new CForm(); $ipmicontrol_form->setName('ipmi_control'); $ipmicontrol_form->setAttribute('id', 'ipmi_control'); $ipmicontrol_form->addVar('driver', 'ipmi'); $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ipmi,{HOST.HOST}]'; $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, new CCheckBox('all_physical_hosts', null, "checkAllHosts('" . $ipmicontrol_form->getName() . "', 'all_physical_hosts', '');"), _('Host name'), _('IPMI interface'), _('Status'), _('Problems'))); $hosts = get_ipmi_hosts(); if (empty($hosts)) { return null; } foreach ($hosts as $host) { $triggers = get_triggers($host['hostid']); $trigger_count = count($triggers); // get State if (!$preloading) { if (is_script_success($host['hostid'], $script_itemkey)) { $state = strtolower(get_item_value($host['hostid'], "ipmi.state.text")); } else { $state = _('script failed'); } } else { $state = _('loading...'); } // Check box $checkbox_col = new CCheckBox("hostids[]", null, null, $host['hostid']); if (!is_operation_available("ipmi", $state)) { $checkbox_col->attributes['disabled'] = 'disabled'; } // Host name if ($trigger_count == 0) { $hostname_col = new CCol(new CSpan($host['host'])); } else { $hostname_col = new CLink(new CSpan($host['host']), 'tr_status.php?&hostid=' . $host['hostid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE); } // IPMI Interfaces $ipmi_addresses = get_addresses($host['hostid'], INTERFACE_TYPE_IPMI); $ipmi_ip_col = new CCol(reset($ipmi_addresses)); // Status $state_col = new CCol($state, get_item_level($state)); // Problem if ($trigger_count == 0) { $problem_col = new CCol($trigger_count, 'normal'); } else { $problem_col = new CCol($trigger_count, 'high'); $problem_col->setHint(make_trigger_table($triggers, $hostname_col)); } $r = new CRow(); $r->addItem($checkbox_col); $r->addItem($hostname_col); $r->addItem($ipmi_ip_col); $r->addItem($state_col); $r->addItem($problem_col); $table->addRow($r); } $table->setFooter(new CCol(make_operation_box_footer(zbx_objectValues($hosts, 'hostid'), $form_name))); $ipmicontrol_form->addItem($table); $script = new CJSScript(get_js("jQuery('#hat_ipmistat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')")); return new CDiv(array($ipmicontrol_form, $script)); }
$page['title'] = _('Resource'); $page['file'] = 'popup_right.php'; define('ZBX_PAGE_NO_MENU', 1); require_once dirname(__FILE__) . '/include/page_header.php'; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = array('dstfrm' => array(T_ZBX_STR, O_MAND, P_SYS, NOT_EMPTY, null), 'permission' => array(T_ZBX_INT, O_MAND, P_SYS, IN(PERM_DENY . ',' . PERM_READ . ',' . PERM_READ_WRITE), null)); check_fields($fields); $dstfrm = getRequest('dstfrm', 0); $permission = getRequest('permission', PERM_DENY); /* * Display */ show_table_header(permission2str($permission)); // host groups $hostGroupForm = new CForm(); $hostGroupForm->setAttribute('id', 'groups'); $hostGroupTable = new CTableInfo(_('No host groups found.')); $hostGroupTable->setHeader(new CCol(array(new CCheckBox('all_groups', null, 'checkAll(this.checked)'), _('Name')))); $hostGroups = API::HostGroup()->get(array('output' => array('groupid', 'name'))); order_result($hostGroups, 'name'); foreach ($hostGroups as $hostGroup) { $hostGroupCheckBox = new CCheckBox(); $hostGroupCheckBox->setAttribute('data-id', $hostGroup['groupid']); $hostGroupCheckBox->setAttribute('data-name', $hostGroup['name']); $hostGroupCheckBox->setAttribute('data-permission', $permission); $hostGroupTable->addRow(new CCol(array($hostGroupCheckBox, $hostGroup['name']))); } $hostGroupTable->setFooter(new CCol(new CButton('select', _('Select'), 'addGroups("' . $dstfrm . '")'), 'right')); $hostGroupForm->addItem($hostGroupTable); $hostGroupForm->show(); ?>
while ($row = DBfetch($result)) { $name = new CLink($row["key_"], "#", "action"); if (isset($_REQUEST['reference']) && $_REQUEST['reference'] == 'dashboard') { $action = get_window_opener($dstfrm, $dstfld1, $srcfld2) . get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) . "window.opener.setTimeout('add2favorites();', 1000);"; } else { $action = get_window_opener($dstfrm, $dstfld1, html_entity_decode($row[$srcfld1])) . (isset($srcfld2) ? get_window_opener($dstfrm, $dstfld2, $row[$srcfld2]) : ''); } $name->SetAction($action . " close_window(); return false;"); $table->addRow(array($name, $row["description"])); } $table->Show(); } else { if ($srctbl == 'triggers') { $available_triggers = get_accessible_triggers(PERM_READ_ONLY, $available_hosts, PERM_RES_IDS_ARRAY, $nodeid); $form = new CForm(); $form->setAttribute('id', S_TRIGGERS); $table = new CTableInfo(S_NO_TRIGGERS_DEFINED); if ($multiselect) { insert_js_function('add_selected_values'); insert_js_function('check_all'); $header = array(new CCol(array(new CCheckBox("check", NULL, 'check_all("' . S_TRIGGERS . '", this.checked);'), S_NAME)), S_SEVERITY, S_STATUS); $button = new CButton('select', S_SELECT, 'add_selected_values("' . S_TRIGGERS . '", "' . $dstfrm . '", "' . $dstfld1 . '", "' . $dstact . '")'); $button->setType('button'); $table->setFooter(new CCol($button, 'right')); } else { insert_js_function('add_value'); $header = array(S_NAME, S_SEVERITY, S_STATUS); } $table->SetHeader($header); $sql = 'SELECT h.host,t.triggerid,t.description,t.expression,t.priority,t.status,count(d.triggerid_up) as dep_count ' . ' FROM hosts h,items i,functions f, triggers t' . ' LEFT JOIN trigger_depends d ON d.triggerid_down=t.triggerid ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.triggerid=f.triggerid' . ' AND ' . DBin_node('t.triggerid', $nodeid) . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status in (' . implode(',', $host_status) . ')'; if ($hostid > 0) {
function get_item_filter_form(&$items) { $filter_group = $_REQUEST['filter_group']; $filter_host = $_REQUEST['filter_host']; $filter_application = $_REQUEST['filter_application']; $filter_description = $_REQUEST['filter_description']; $filter_type = $_REQUEST['filter_type']; $filter_key = $_REQUEST['filter_key']; $filter_snmp_community = $_REQUEST['filter_snmp_community']; $filter_snmpv3_securityname = $_REQUEST['filter_snmpv3_securityname']; $filter_snmp_oid = $_REQUEST['filter_snmp_oid']; $filter_snmp_port = $_REQUEST['filter_snmp_port']; $filter_value_type = $_REQUEST['filter_value_type']; $filter_data_type = $_REQUEST['filter_data_type']; $filter_delay = $_REQUEST['filter_delay']; $filter_history = $_REQUEST['filter_history']; $filter_trends = $_REQUEST['filter_trends']; $filter_status = $_REQUEST['filter_status']; $filter_templated_items = $_REQUEST['filter_templated_items']; $filter_with_triggers = $_REQUEST['filter_with_triggers']; // subfilter $subfilter_hosts = $_REQUEST['subfilter_hosts']; $subfilter_apps = $_REQUEST['subfilter_apps']; $subfilter_types = $_REQUEST['subfilter_types']; $subfilter_value_types = $_REQUEST['subfilter_value_types']; $subfilter_status = $_REQUEST['subfilter_status']; $subfilter_templated_items = $_REQUEST['subfilter_templated_items']; $subfilter_with_triggers = $_REQUEST['subfilter_with_triggers']; $subfilter_history = $_REQUEST['subfilter_history']; $subfilter_trends = $_REQUEST['subfilter_trends']; $subfilter_interval = $_REQUEST['subfilter_interval']; $form = new CForm(); $form->setAttribute('name', 'zbx_filter'); $form->setAttribute('id', 'zbx_filter'); $form->setMethod('get'); $form->addVar('filter_hostid', get_request('filter_hostid', get_request('hostid'))); $form->addVar('subfilter_hosts', $subfilter_hosts); $form->addVar('subfilter_apps', $subfilter_apps); $form->addVar('subfilter_types', $subfilter_types); $form->addVar('subfilter_value_types', $subfilter_value_types); $form->addVar('subfilter_status', $subfilter_status); $form->addVar('subfilter_templated_items', $subfilter_templated_items); $form->addVar('subfilter_with_triggers', $subfilter_with_triggers); $form->addVar('subfilter_history', $subfilter_history); $form->addVar('subfilter_trends', $subfilter_trends); $form->addVar('subfilter_interval', $subfilter_interval); // FORM FOR FILTER DISPLAY { $table = new CTable('', 'itemfilter'); $table->setCellPadding(0); $table->setCellSpacing(0); // 1st col $col_table1 = new CTable(); $col_table1->setClass('filter'); $col_table1->addRow(array(bold(S_HOST_GROUP . ': '), array(new CTextBox('filter_group', $filter_group, 20), new CButton('btn_group', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_group&srctbl=host_group&srcfld1=name",450,450);', 'G')))); $col_table1->addRow(array(bold(S_HOST . ': '), array(new CTextBox('filter_host', $filter_host, 20), new CButton('btn_host', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_host&srctbl=hosts_and_templates&srcfld1=host",450,450);', 'H')))); $col_table1->addRow(array(bold(S_APPLICATION . ': '), array(new CTextBox('filter_application', $filter_application, 20), new CButton('btn_app', S_SELECT, 'return PopUp("popup.php?dstfrm=' . $form->getName() . '&dstfld1=filter_application&srctbl=applications&srcfld1=name",400,300,"application");', 'A')))); $col_table1->addRow(array(array(bold(S_DESCRIPTION), SPACE . S_LIKE_SMALL . ': '), new CTextBox("filter_description", $filter_description, 30))); $col_table1->addRow(array(array(bold(S_KEY), SPACE . S_LIKE_SMALL . ': '), new CTextBox("filter_key", $filter_key, 30))); // 2nd col $col_table2 = new CTable(); $col_table2->setClass('filter'); $fTypeVisibility = array(); //first row $cmbType = new CComboBox("filter_type", $filter_type); //"javascript: create_var('zbx_filter', 'filter_set', '1', true); "); $cmbType->setAttribute('id', 'filter_type'); $cmbType->addItem(-1, S_ALL_SMALL); foreach (array('filter_delay_label', 'filter_delay') as $vItem) { zbx_subarray_push($fTypeVisibility, -1, $vItem); } $itemTypes = item_type2str(); // httptest items are only for internal zabbix logic unset($itemTypes[ITEM_TYPE_HTTPTEST]); $cmbType->addItems($itemTypes); foreach ($itemTypes as $typeNum => $typeLabel) { if ($typeNum != ITEM_TYPE_TRAPPER) { zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay_label'); zbx_subarray_push($fTypeVisibility, $typeNum, 'filter_delay'); } switch ($typeNum) { case ITEM_TYPE_SNMPV1: case ITEM_TYPE_SNMPV2C: $snmp_types = array('filter_snmp_community_label', 'filter_snmp_community', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_snmp_port_label', 'filter_snmp_port'); foreach ($snmp_types as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; case ITEM_TYPE_SNMPV3: foreach (array('filter_snmpv3_securityname_label', 'filter_snmpv3_securityname', 'filter_snmp_oid_label', 'filter_snmp_oid', 'filter_snmp_port_label', 'filter_snmp_port') as $vItem) { zbx_subarray_push($fTypeVisibility, $typeNum, $vItem); } break; } } zbx_add_post_js("var filterTypeSwitcher = new CViewSwitcher('filter_type', 'change', " . zbx_jsvalue($fTypeVisibility, true) . ");"); $col21 = new CCol(bold(S_TYPE . ': ')); $col21->setAttribute('style', 'width: 170px'); $col_table2->addRow(array($col21, $cmbType)); //second row $label221 = new CSpan(bold(S_UPDATE_INTERVAL_IN_SEC . ': ')); $label221->setAttribute('id', 'filter_delay_label'); $field221 = new CNumericBox('filter_delay', $filter_delay, 5, null, true); $field221->setEnabled('no'); $col_table2->addRow(array(array($label221, SPACE), array($field221, SPACE))); //third row $label231 = new CSpan(array(bold(S_SNMP_COMMUNITY), SPACE . S_LIKE_SMALL . ': ')); $label231->setAttribute('id', 'filter_snmp_community_label'); $field231 = new CTextBox('filter_snmp_community', $filter_snmp_community, 40); $field231->setEnabled('no'); $label232 = new CSpan(array(bold(S_SNMPV3_SECURITY_NAME), SPACE . S_LIKE_SMALL . ': ')); $label232->setAttribute('id', 'filter_snmpv3_securityname_label'); $field232 = new CTextBox('filter_snmpv3_securityname', $filter_snmpv3_securityname, 40); $field232->setEnabled('no'); $col_table2->addRow(array(array($label231, $label232, SPACE), array($field231, $field232, SPACE))); //fourth row $label241 = new CSpan(array(bold(S_SNMP_OID), SPACE . S_LIKE_SMALL . ': ')); $label241->setAttribute('id', 'filter_snmp_oid_label'); $field241 = new CTextBox('filter_snmp_oid', $filter_snmp_oid, 40); $field241->setEnabled('no'); $col_table2->addRow(array(array($label241, SPACE), array($field241, SPACE))); //fifth row $label251 = new CSpan(array(bold(S_SNMP_PORT), SPACE . S_LIKE_SMALL . ': ')); $label251->setAttribute('id', 'filter_snmp_port_label'); $field251 = new CNumericBox('filter_snmp_port', $filter_snmp_port, 5, null, true); $field251->setEnabled('no'); $col_table2->addRow(array(array($label251, SPACE), array($field251, SPACE))); // 3rd col $col_table3 = new CTable(); $col_table3->setClass('filter'); $fVTypeVisibility = array(); $cmbValType = new CComboBox('filter_value_type', $filter_value_type); //, "javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $cmbValType->addItem(-1, S_ALL_SMALL); $cmbValType->addItem(ITEM_VALUE_TYPE_UINT64, S_NUMERIC_UNSIGNED); $cmbValType->addItem(ITEM_VALUE_TYPE_FLOAT, S_NUMERIC_FLOAT); $cmbValType->addItem(ITEM_VALUE_TYPE_STR, S_CHARACTER); $cmbValType->addItem(ITEM_VALUE_TYPE_LOG, S_LOG); $cmbValType->addItem(ITEM_VALUE_TYPE_TEXT, S_TEXT); foreach (array('filter_data_type_label', 'filter_data_type') as $vItem) { zbx_subarray_push($fVTypeVisibility, ITEM_VALUE_TYPE_UINT64, $vItem); } $col_table3->addRow(array(bold(S_TYPE_OF_INFORMATION . ': '), $cmbValType)); zbx_add_post_js("var filterValueTypeSwitcher = new CViewSwitcher('filter_value_type', 'change', " . zbx_jsvalue($fVTypeVisibility, true) . ");"); //second row $label321 = new CSpan(bold(S_DATA_TYPE . ': ')); $label321->setAttribute('id', 'filter_data_type_label'); $field321 = new CComboBox('filter_data_type', $filter_data_type); //, 'submit()'); $field321->addItem(-1, S_ALL_SMALL); $field321->addItem(ITEM_DATA_TYPE_DECIMAL, item_data_type2str(ITEM_DATA_TYPE_DECIMAL)); $field321->addItem(ITEM_DATA_TYPE_OCTAL, item_data_type2str(ITEM_DATA_TYPE_OCTAL)); $field321->addItem(ITEM_DATA_TYPE_HEXADECIMAL, item_data_type2str(ITEM_DATA_TYPE_HEXADECIMAL)); $field321->setEnabled('no'); $col_table3->addRow(array(array($label321, SPACE), array($field321, SPACE))); $col_table3->addRow(array(bold(S_KEEP_HISTORY_IN_DAYS . ': '), new CNumericBox('filter_history', $filter_history, 8, null, true))); $col_table3->addRow(array(bold(S_KEEP_TRENDS_IN_DAYS . ': '), new CNumericBox('filter_trends', $filter_trends, 8, null, true))); // 4th col $col_table4 = new CTable(); $col_table4->setClass('filter'); $cmbStatus = new CComboBox('filter_status', $filter_status); $cmbStatus->addItem(-1, S_ALL_SMALL); foreach (array(ITEM_STATUS_ACTIVE, ITEM_STATUS_DISABLED, ITEM_STATUS_NOTSUPPORTED) as $st) { $cmbStatus->addItem($st, item_status2str($st)); } $cmbBelongs = new CComboBox('filter_templated_items', $filter_templated_items); $cmbBelongs->addItem(-1, S_ALL_SMALL); $cmbBelongs->addItem(1, S_TEMPLATED_ITEMS); $cmbBelongs->addItem(0, S_NOT_TEMPLATED_ITEMS); $cmbWithTriggers = new CComboBox('filter_with_triggers', $filter_with_triggers); $cmbWithTriggers->addItem(-1, S_ALL_SMALL); $cmbWithTriggers->addItem(1, S_WITH_TRIGGERS); $cmbWithTriggers->addItem(0, S_WITHOUT_TRIGGERS); $col_table4->addRow(array(bold(S_STATUS . ': '), $cmbStatus)); $col_table4->addRow(array(bold(S_TRIGGERS . ': '), $cmbWithTriggers)); $col_table4->addRow(array(bold(S_TEMPLATE . ': '), $cmbBelongs)); //adding all cols tables to main table $col1 = new CCol($col_table1, 'top'); $col1->setAttribute('style', 'width: 280px'); $col2 = new CCol($col_table2, 'top'); $col2->setAttribute('style', 'width: 410px'); $col3 = new CCol($col_table3, 'top'); $col3->setAttribute('style', 'width: 160px'); $col4 = new CCol($col_table4, 'top'); $table->addRow(array($col1, $col2, $col3, $col4)); $reset = new CSpan(S_RESET, 'biglink'); $reset->onClick("javascript: clearAllForm('zbx_filter');"); $filter = new CSpan(S_FILTER, 'biglink'); $filter->onClick("javascript: create_var('zbx_filter', 'filter_set', '1', true);"); $div_buttons = new CDiv(array($filter, SPACE, SPACE, SPACE, $reset)); $div_buttons->setAttribute('style', 'padding: 4px 0;'); $footer = new CCol($div_buttons, 'center'); $footer->setColSpan(4); $table->addRow($footer); $form->addItem($table); // } FORM FOR FILTER DISPLAY // SUBFILTERS { $h = new CDiv(S_SUBFILTER . SPACE . '[' . S_AFFECTS_ONLY_FILTERED_DATA_SMALL . ']'); $h->setClass('thin_header'); $form->addItem($h); $table_subfilter = new Ctable(); $table_subfilter->setClass('filter'); // array contains subfilters and number of items in each $item_params = array('hosts' => array(), 'applications' => array(), 'types' => array(), 'value_types' => array(), 'status' => array(), 'templated_items' => array(), 'with_triggers' => array(), 'history' => array(), 'trends' => array(), 'interval' => array()); // generate array with values for subfilters of selected items foreach ($items as $num => $item) { if (zbx_empty($filter_host)) { // hosts $host = reset($item['hosts']); if (!isset($item_params['hosts'][$host['hostid']])) { $item_params['hosts'][$host['hostid']] = array('name' => $host['host'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_hosts') { continue; } $show_item &= $value; } if ($show_item) { $host = reset($item['hosts']); $item_params['hosts'][$host['hostid']]['count']++; } } // applications foreach ($item['applications'] as $appid => $app) { if (!isset($item_params['applications'][$app['name']])) { $item_params['applications'][$app['name']] = array('name' => $app['name'], 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_apps') { continue; } $show_item &= $value; } $sel_app = false; if ($show_item) { // if any of item applications are selected foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps)) { $sel_app = true; break; } } foreach ($item['applications'] as $app) { if (str_in_array($app['name'], $subfilter_apps) || !$sel_app) { $item_params['applications'][$app['name']]['count']++; } } } // types if ($filter_type == -1) { if (!isset($item_params['types'][$item['type']])) { $item_params['types'][$item['type']] = array('name' => item_type2str($item['type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['types'][$item['type']]['count']++; } } // value types if ($filter_value_type == -1) { if (!isset($item_params['value_types'][$item['value_type']])) { $item_params['value_types'][$item['value_type']] = array('name' => item_value_type2str($item['value_type']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_value_types') { continue; } $show_item &= $value; } if ($show_item) { $item_params['value_types'][$item['value_type']]['count']++; } } // status if ($filter_status == -1) { if (!isset($item_params['status'][$item['status']])) { $item_params['status'][$item['status']] = array('name' => item_status2str($item['status']), 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_status') { continue; } $show_item &= $value; } if ($show_item) { $item_params['status'][$item['status']]['count']++; } } // template if ($filter_templated_items == -1) { if ($item['templateid'] == 0 && !isset($item_params['templated_items'][0])) { $item_params['templated_items'][0] = array('name' => S_NOT_TEMPLATED_ITEMS, 'count' => 0); } else { if ($item['templateid'] > 0 && !isset($item_params['templated_items'][1])) { $item_params['templated_items'][1] = array('name' => S_TEMPLATED_ITEMS, 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_templated_items') { continue; } $show_item &= $value; } if ($show_item) { if ($item['templateid'] == 0) { $item_params['templated_items'][0]['count']++; } else { $item_params['templated_items'][1]['count']++; } } } // with triggers if ($filter_with_triggers == -1) { if (count($item['triggers']) == 0 && !isset($item_params['with_triggers'][0])) { $item_params['with_triggers'][0] = array('name' => S_WITHOUT_TRIGGERS, 'count' => 0); } else { if (count($item['triggers']) > 0 && !isset($item_params['with_triggers'][1])) { $item_params['with_triggers'][1] = array('name' => S_WITH_TRIGGERS, 'count' => 0); } } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_with_triggers') { continue; } $show_item &= $value; } if ($show_item) { if (count($item['triggers']) == 0) { $item_params['with_triggers'][0]['count']++; } else { $item_params['with_triggers'][1]['count']++; } } } // trends if (zbx_empty($filter_trends)) { if (!isset($item_params['trends'][$item['trends']])) { $item_params['trends'][$item['trends']] = array('name' => $item['trends'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_trends') { continue; } $show_item &= $value; } if ($show_item) { $item_params['trends'][$item['trends']]['count']++; } } // history if (zbx_empty($filter_history)) { if (!isset($item_params['history'][$item['history']])) { $item_params['history'][$item['history']] = array('name' => $item['history'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_history') { continue; } $show_item &= $value; } if ($show_item) { $item_params['history'][$item['history']]['count']++; } } // interval if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER) { if (!isset($item_params['interval'][$item['delay']])) { $item_params['interval'][$item['delay']] = array('name' => $item['delay'], 'count' => 0); } $show_item = true; foreach ($item['subfilters'] as $name => $value) { if ($name == 'subfilter_interval') { continue; } $show_item &= $value; } if ($show_item) { $item_params['interval'][$item['delay']]['count']++; } } } // output if (zbx_empty($filter_host) && count($item_params['hosts']) > 1) { $hosts_output = prepare_subfilter_output($item_params['hosts'], $subfilter_hosts, 'subfilter_hosts'); $table_subfilter->addRow(array(S_HOSTS, $hosts_output)); } if (!empty($item_params['applications']) && count($item_params['applications']) > 1) { $application_output = prepare_subfilter_output($item_params['applications'], $subfilter_apps, 'subfilter_apps'); $table_subfilter->addRow(array(S_APPLICATIONS, $application_output)); } if ($filter_type == -1 && count($item_params['types']) > 1) { $type_output = prepare_subfilter_output($item_params['types'], $subfilter_types, 'subfilter_types'); $table_subfilter->addRow(array(S_TYPES, $type_output)); } if ($filter_value_type == -1 && count($item_params['value_types']) > 1) { $value_types_output = prepare_subfilter_output($item_params['value_types'], $subfilter_value_types, 'subfilter_value_types'); $table_subfilter->addRow(array(S_TYPE_OF_INFORMATION, $value_types_output)); } if ($filter_status == -1 && count($item_params['status']) > 1) { $status_output = prepare_subfilter_output($item_params['status'], $subfilter_status, 'subfilter_status'); $table_subfilter->addRow(array(S_STATUS, $status_output)); } if ($filter_templated_items == -1 && count($item_params['templated_items']) > 1) { $templated_items_output = prepare_subfilter_output($item_params['templated_items'], $subfilter_templated_items, 'subfilter_templated_items'); $table_subfilter->addRow(array(S_TEMPLATE, $templated_items_output)); } if ($filter_with_triggers == -1 && count($item_params['with_triggers']) > 1) { $with_triggers_output = prepare_subfilter_output($item_params['with_triggers'], $subfilter_with_triggers, 'subfilter_with_triggers'); $table_subfilter->addRow(array(S_WITH_TRIGGERS, $with_triggers_output)); } if (zbx_empty($filter_history) && count($item_params['history']) > 1) { $history_output = prepare_subfilter_output($item_params['history'], $subfilter_history, 'subfilter_history'); $table_subfilter->addRow(array(S_HISTORY, $history_output)); } if (zbx_empty($filter_trends) && count($item_params['trends']) > 1) { $trends_output = prepare_subfilter_output($item_params['trends'], $subfilter_trends, 'subfilter_trends'); $table_subfilter->addRow(array(S_TRENDS, $trends_output)); } if (zbx_empty($filter_delay) && $filter_type != ITEM_TYPE_TRAPPER && count($item_params['interval']) > 1) { $interval_output = prepare_subfilter_output($item_params['interval'], $subfilter_interval, 'subfilter_interval'); $table_subfilter->addRow(array(S_INTERVAL, $interval_output)); } //} SUBFILTERS $form->addItem($table_subfilter); return $form; }
if (isset($row['servicedownid'])) { $services[$row['serviceid']]['childs'][] = array('id' => $row['servicedownid'], 'soft' => 1, 'linkid' => $row['linkid']); } } $treeServ = array(); createShowServiceTree($services, $treeServ); //return into $treeServ parametr //permission issue $treeServ = del_empty_nodes($treeServ); $tree = new CTree('service_status_tree', $treeServ, array('caption' => bold(S_SERVICE), 'status' => bold(S_STATUS), 'reason' => bold(S_REASON), 'sla' => bold('SLA (' . $periods[$period_start] . ')'), 'sla2' => bold(nbsp(S_SLA)), 'graph' => bold(S_GRAPH))); if ($tree) { // creates form for choosing a preset interval $r_form = new CForm(); $r_form->setClass('nowrap'); $r_form->setMethod('get'); $r_form->setAttribute('name', 'period_choice'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $period_combo = new CComboBox('period_start', $period_start, 'javascript: submit();'); foreach ($periods as $key => $val) { $period_combo->AddItem($key, $val); } $r_form->AddItem(array(S_PERIOD, $period_combo)); $url = '?period_start=' . $period_start . '&fullscreen=' . ($_REQUEST['fullscreen'] ? '0' : '1'); $fs_icon = new CDiv(SPACE, 'fullscreen'); $fs_icon->setAttribute('title', $_REQUEST['fullscreen'] ? S_NORMAL . ' ' . S_VIEW : S_FULLSCREEN); $fs_icon->addAction('onclick', new CScript("javascript: document.location = '" . $url . "';")); $srv_wdgt = new CWidget('hat_services', $tree->getHTML()); $srv_wdgt->addHeader(S_IT_SERVICES_BIG, array($r_form, $fs_icon)); $srv_wdgt->show(); } else { error('Can not format Tree. Check logik structure in service links');
$slaData = API::Service()->getSla(array('intervals' => array(array('from' => $period_start, 'to' => $period_end)))); // expand problem trigger descriptions foreach ($slaData as &$serviceSla) { foreach ($serviceSla['problems'] as &$problemTrigger) { $problemTrigger['description'] = $triggers[$problemTrigger['triggerid']]['description']; } unset($problemTrigger); } unset($serviceSla); $treeData = array(); createServiceMonitoringTree($services, $slaData, $period, $treeData); $tree = new CServiceTree('service_status_tree', $treeData, array('caption' => _('Service'), 'status' => _('Status'), 'reason' => _('Reason'), 'sla' => _('Problem time'), 'sla2' => nbsp(_('SLA') . ' / ' . _('Acceptable SLA')))); if ($tree) { // creates form for choosing a preset interval $r_form = new CForm(); $r_form->setAttribute('class', 'nowrap'); $r_form->setMethod('get'); $r_form->setAttribute('name', 'period_choice'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); $period_combo = new CComboBox('period', $period, 'javascript: submit();'); foreach ($periods as $key => $val) { $period_combo->addItem($key, $val); } $r_form->addItem(array(_('Period') . SPACE, $period_combo)); $srv_wdgt = new CWidget('hat_services', 'service-list service-mon'); $srv_wdgt->addPageHeader(_('IT SERVICES'), get_icon('fullscreen', array('fullscreen' => $_REQUEST['fullscreen']))); $srv_wdgt->addHeader(_('IT services'), $r_form); $srv_wdgt->addItem(BR()); $srv_wdgt->addItem($tree->getHTML()); $srv_wdgt->show(); } else {
$_REQUEST['nav_time'] = get_request('nav_time', get_profile('web.events.filter.nav_time', time())); $_REQUEST['triggerid'] = get_request('triggerid', get_profile('web.events.filter.triggerid', 0)); $show_unknown = get_request('show_unknown', get_profile('web.events.filter.show_unknown', 0)); if (isset($_REQUEST['filter_set']) || isset($_REQUEST['filter_rst'])) { update_profile('web.events.filter.nav_time', $_REQUEST['nav_time'], PROFILE_TYPE_INT); update_profile('web.events.filter.triggerid', $_REQUEST['triggerid']); update_profile('web.events.filter.show_unknown', $show_unknown, PROFILE_TYPE_INT); } // -------------- validate_sort_and_sortorder('e.clock', ZBX_SORT_DOWN); $source = get_request('source', EVENT_SOURCE_TRIGGERS); update_profile('web.events.source', $source, PROFILE_TYPE_INT); $source = get_request('source', EVENT_SOURCE_TRIGGERS); $r_form = new CForm(); $r_form->setMethod('get'); $r_form->setAttribute('name', 'events_menu'); $r_form->addVar('fullscreen', $_REQUEST['fullscreen']); // $r_form->addVar('nav_time',$_REQUEST['nav_time']); if (EVENT_SOURCE_TRIGGERS == $source) { if (isset($_REQUEST['triggerid']) && $_REQUEST['triggerid'] > 0) { $sql = 'SELECT DISTINCT hg.groupid, hg.hostid ' . ' FROM hosts_groups hg, functions f, items i' . ' WHERE i.itemid=f.itemid ' . ' AND hg.hostid=i.hostid ' . ' AND f.triggerid=' . $_REQUEST['triggerid']; if ($host_group = DBfetch(DBselect($sql, 1))) { $_REQUEST['groupid'] = $host_group['groupid']; $_REQUEST['hostid'] = $host_group['hostid']; } else { unset($_REQUEST['triggerid']); } } $options = array('allow_all_hosts', 'monitored_hosts', 'with_items'); if (!$ZBX_WITH_ALL_NODES) { array_push($options, 'only_current_node');
if (isset($page['menu']) && $page['menu'] == $label) { $menu_selected = true; $sub_menu_div->setAttribute('style', 'display: block;'); insert_js('MMenu.def_label = ' . zbx_jsvalue($label)); } else { $sub_menu_div->setAttribute('style', 'display: none;'); } $menu_divs[] = $sub_menu_div; } $sub_menu_div = new CDiv(SPACE); $sub_menu_div->setAttribute('id', 'sub_empty'); $sub_menu_div->setAttribute('style', 'display: ' . ($menu_selected ? 'none;' : 'block;')); $menu_divs[] = $sub_menu_div; $search_form = new CForm('search.php'); $search_form->setMethod('get'); $search_form->setAttribute('class', 'thin'); $search_form->addItem(new CDiv(array(S_SEARCH_BIG . ': ', new CTextBox('search', '', 15)))); $search_div = new CDiv($search_form); $search_div->setAttribute('id', 'zbx_search'); $search_div->setAttribute('class', 'zbx_search'); $sub_menu_table->addRow(array($menu_divs, $search_div)); $page_menu->addItem($sub_menu_table); //--- /* SEARCH form $search_form = new CForm('search.php'); $search_form->addItem(new CDiv(array(S_SEARCH_BIG.': ', new CTextBox('search','',20)))); $search_div = new CDiv($search_form); $search_div->setAttribute('id','zbx_search'); $search_div->setAttribute('class','zbx_search');
S_GRAPH, null,//make_webmon_overview(), null, 'hat_custom', get_profile('web.dashboard.hats.hat_custom.state',1) )); */ $td_l = new CCol($left_tab); $td_l->setAttribute('valign', 'top'); $td_r = new CCol($right_tab); $td_r->setAttribute('valign', 'top'); $outer_table = new CTable(); $outer_table->setAttribute('border', 0); $outer_table->setCellPadding(1); $outer_table->setCellSpacing(1); $outer_table->addRow(array($td_l, $td_r)); $dashboard_wdgt->addItem($outer_table); $fav_form = new CForm(); $fav_form->setAttribute('name', 'fav_form'); $fav_form->setAttribute('id', 'fav_form'); $fav_form->setAttribute('style', 'display: inline; margin: 0px;'); $fav_form->addVar('favobj', ''); $fav_form->addVar('favid', ''); $fav_form->addVar('source', ''); $dashboard_wdgt->addItem($fav_form); $dashboard_wdgt->show(); $jsmenu = new CPUMenu(null, 170); $jsmenu->InsertJavaScript(); // $link = new CLink('Click Me','javascript: callJSON();','highlight'); // $link->Show(); include_once "include/page_footer.php";