Exemple #1
0
function show_report2_header($config, &$PAGE_GROUPS, &$PAGE_HOSTS)
{
    global $USER_DETAILS;
    $available_groups = $PAGE_GROUPS['groupids'];
    $available_hosts = $PAGE_HOSTS['hostids'];
    //	$available_groups = $PAGE_GROUPS['groupids'];
    //	$available_hosts = $PAGE_HOSTS['hostids'];
    $r_form = new CForm();
    $r_form->setMethod('get');
    $cmbConf = new CComboBox('config', $config, 'submit()');
    $cmbConf->addItem(0, S_BY_HOST);
    $cmbConf->addItem(1, S_BY_TRIGGER_TEMPLATE);
    $r_form->addItem(array(S_MODE . SPACE, $cmbConf, SPACE));
    $cmbGroups = new CComboBox('groupid', $PAGE_GROUPS['selected'], 'javascript: submit();');
    $cmbHosts = new CComboBox('hostid', $PAGE_HOSTS['selected'], 'javascript: submit();');
    foreach ($PAGE_GROUPS['groups'] as $groupid => $name) {
        $cmbGroups->addItem($groupid, get_node_name_by_elid($groupid) . $name);
    }
    foreach ($PAGE_HOSTS['hosts'] as $hostid => $name) {
        $cmbHosts->addItem($hostid, get_node_name_by_elid($hostid) . $name);
    }
    $r_form->addItem(array(S_GROUP . SPACE, $cmbGroups));
    $r_form->addItem(array(SPACE . S_HOST . SPACE, $cmbHosts));
    if (1 == $config) {
        $cmbTrigs = new CComboBox('tpl_triggerid', get_request('tpl_triggerid', 0), 'submit()');
        $cmbHGrps = new CComboBox('hostgroupid', get_request('hostgroupid', 0), 'submit()');
        $cmbTrigs->addItem(0, S_ALL_SMALL);
        $cmbHGrps->addItem(0, S_ALL_SMALL);
    }
    if (0 == $config) {
        show_table_header(S_AVAILABILITY_REPORT_BIG, $r_form);
    } else {
        $sql_cond = ' AND h.hostid=ht.hostid ';
        if ($_REQUEST['hostid'] > 0) {
            $sql_cond .= ' AND ht.templateid=' . $_REQUEST['hostid'];
        }
        if (isset($_REQUEST['tpl_triggerid']) && $_REQUEST['tpl_triggerid'] > 0) {
            $sql_cond .= ' AND t.templateid=' . $_REQUEST['tpl_triggerid'];
        }
        $result = DBselect('SELECT DISTINCT g.groupid,g.name ' . ' FROM triggers t,hosts h,items i,functions f, hosts_templates ht, groups g, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid' . ' AND g.groupid=hg.groupid ' . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND h.status=' . HOST_STATUS_MONITORED . $sql_cond . ' ORDER BY g.name');
        while ($row = DBfetch($result)) {
            $cmbHGrps->addItem($row['groupid'], get_node_name_by_elid($row['groupid']) . $row['name']);
        }
        $sql_cond = $_REQUEST['hostid'] > 0 ? ' AND h.hostid=' . $_REQUEST['hostid'] : ' AND ' . DBcondition('h.hostid', $available_hosts);
        $sql = 'SELECT DISTINCT t.triggerid,t.description ' . ' FROM triggers t,hosts h,items i,functions f ' . ' WHERE f.itemid=i.itemid ' . ' AND h.hostid=i.hostid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND t.triggerid=f.triggerid ' . ' AND h.status=' . HOST_STATUS_TEMPLATE . ' AND ' . DBin_node('t.triggerid') . ' AND i.status=' . ITEM_STATUS_ACTIVE . $sql_cond . ' ORDER BY t.description';
        $result = DBselect($sql);
        while ($row = DBfetch($result)) {
            $cmbTrigs->addItem($row['triggerid'], get_node_name_by_elid($row['triggerid']) . expand_trigger_description($row['triggerid']));
        }
        $rr_form = new CForm();
        $rr_form->setMethod('get');
        $rr_form->addVar('config', $config);
        $rr_form->addVar('groupid', $_REQUEST['groupid']);
        $rr_form->addVar('hostid', $_REQUEST['hostid']);
        $rr_form->addItem(array(S_TRIGGER . SPACE, $cmbTrigs, BR(), S_FILTER, SPACE, S_HOST_GROUP . SPACE, $cmbHGrps));
        show_table_header(S_AVAILABILITY_REPORT_BIG, array($r_form, $rr_form));
    }
}
Exemple #2
0
     $sub_menu_div->addAction('onmouseout', 'javascript: MMenu.mouseOut();');
     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');
 // 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 {
     error(_('Cannot format Tree. Check logic structure in service links.'));
Exemple #4
0
                        $host = get_host_by_hostid($db_host['hostid']);
                        $result &= update_host_status($db_host['hostid'], $status);
                        /*			add_audit(AUDIT_ACTION_UPDATE,AUDIT_RESOURCE_HOST,
                        				'Old status ['.$host['status'].'] '.'New status ['.$status.']');*/
                    }
                    $result = DBend($result);
                    show_messages($result, S_HOST_STATUS_UPDATED, S_CANNOT_UPDATE_HOST);
                    unset($_REQUEST['activate']);
                }
            }
        }
    }
}
/*** --->>> ACTIONS <<<--- ***/
$frmForm = new CForm();
$frmForm->setMethod('get');
if (!isset($_REQUEST['form'])) {
    $frmForm->addItem(new CButton('form', S_CREATE_GROUP));
}
show_table_header(S_CONFIGURATION_OF_GROUPS, $frmForm);
if (isset($_REQUEST['form'])) {
    echo SBR;
    global $USER_DETAILS;
    $groupid = get_request('groupid', 0);
    $hosts = get_request('hosts', array());
    SDII($hosts);
    $frm_title = S_HOST_GROUP;
    if ($groupid > 0) {
        $group = get_hostgroup_by_groupid($_REQUEST['groupid']);
        $name = $group['name'];
        $frm_title .= ' [' . $group['name'] . ']';
Exemple #5
0
            }
        } else {
            $details = $row['details'];
        }
        $table->addRow(array(date('Y.M.d H:i:s', $row['clock']), $row['alias'], $row['ip'], $row['resourcetype'], $row['action'], $row['resourceid'], $row['resourcename'], new CCol($details, 'wraptext')));
    }
} else {
    if (1 == $config) {
        $table = get_history_of_actions($limit, $last_clock, $sql_cond);
        $count = $table->getNumRows();
    }
}
// Navigation
$next_clock = $last_clock;
$navForm = new CForm('audit.php');
$navForm->setMethod('get');
$navForm->addVar('config', $_REQUEST['config']);
$navForm->addVar('prev_clock', $prev_clock);
$navForm->addVar('curr_clock', $curr_clock);
$navForm->addVar('next_clock', $next_clock);
/*
	$prev_page = new CDiv(SPACE,'arrowleft');
	$prev_page->setAttribute('title','Previous page');
	$prev_page->addAction('onclick',new CScript("javascript: alert('left');"));

	$next_page = new CDiv(SPACE,'arrowright');
	$next_page->setAttribute('title','Next page');
	$next_page->addAction('onclick',new CScript("javascript: alert('right');"));
//*/
//*
$prev_page = new CButton('prev_page', '« ' . S_BACK);
Exemple #6
0
$filter_table->setAttribute('border', 0);
$filter_table->setAttribute('width', '100%');
$cmbGroups = $pageFilter->getGroupsCB(true);
$cmbHosts = $pageFilter->getHostsCB(true);
$filter_table->addRow(array(array(bold(_('Group')), ': ', $cmbGroups), array(bold(_('Host')), ': ', $cmbHosts), array()));
$groupids = checkAccessGroup('groupid');
$hostids = checkAccessHost('hostid');
// --------------------------- Fim Filtro ---------------------------------------------------------------------
$options = array();
$options['templated_hosts'] = 1;
$hosts = API::Host()->get($options);
$filtroSegHosts = " hos.status <> 1 AND " . dbConditionInt('hos.hostid', zbx_objectValues($hosts, 'hostid'));
$rep2_wdgt = new CWidget();
$rep2_wdgt->addPageHeader(_zeT('Not Supported Items Report'));
$filter_form = new CForm();
$filter_form->setMethod('get');
$filter_form->setAttribute('name', 'zbx_filter');
$filter_form->setAttribute('id', 'zbx_filter');
$filter = new CButton('filter', _("Filter"));
$filter->onClick("javascript: submit();");
$reset = new CButton('reset', _('Reset'));
$reset->onClick("javascript: clearAllForm('zbx_filter');");
$footer_col = new CCol(array($filter, SPACE, $reset), 'center');
$footer_col->setColSpan(4);
$filter_table->addRow($footer_col);
$filter_form->addItem($filter_table);
//		$filterForm = get_report2_filter($config, $PAGE_GROUPS, $PAGE_HOSTS);
$rep2_wdgt->addFlicker($filter_form, true);
if (isset($hostid)) {
    $sql_from = '';
    $sql_where = '';
     show_messages($result, _('Item added'), _('Cannot add item'));
     $result = DBend($result);
     $itemids = array();
     if ($result) {
         $itemids = $result['itemids'];
     }
     // Create graphs
     if ($graph_create) {
         createGraph($itemids, $graph_name, $graph_width, $graph_height, $graph_type, $graph_func, $draw_type, $yaxisside);
     }
 } else {
     // Build widget
     //Header
     $form = new CForm();
     $form->cleanItems();
     $form->setMethod('post');
     if (isset($_REQUEST['form'])) {
         // MIB file import
         $import_wdgt = new CWidget();
         $import_wdgt->addPageHeader(_('SNMP Builder'), $form);
         $data = array();
         $data['form'] = get_request('form');
         $data['widget'] = $import_wdgt;
         $importForm = new CView('administration.snmp_builder', $data);
         $import_wdgt->addItem($importForm->render());
         $import_wdgt->show();
     } else {
         $snmp_wdgt = new CWidget();
         $message_div = new CDiv();
         $message_div->setAttribute("id", "message");
         $snmp_wdgt->addItem($message_div);
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;
}
Exemple #9
0
    show_history($_REQUEST['itemid'], $_REQUEST['from'], $bstime, $effectiveperiod);
} else {
    if ($_REQUEST['action'] == 'showvalues' || $_REQUEST['action'] == 'showlatest') {
        if ($_REQUEST['action'] == 'showvalues') {
            $time = mktime(substr($bstime, 8, 2), substr($bstime, 10, 2), 0, substr($bstime, 4, 2), substr($bstime, 6, 2), substr($bstime, 0, 4));
            $till = $time + $effectiveperiod;
        }
        $l_header = null;
        if (!isset($_REQUEST['plaintext'])) {
            if ($item_type == ITEM_VALUE_TYPE_LOG) {
                $to_save_request = array('filter_task', 'filter', 'mark_color');
                $filter_task = get_request('filter_task', 0);
                $filter = get_request('filter', '');
                $mark_color = get_request('mark_color', 0);
                $r_header = new CForm();
                $r_header->setMethod('get');
                $r_header->addVar('action', $_REQUEST['action']);
                $r_header->addVar('from', $_REQUEST['from']);
                $r_header->addVar('period', $_REQUEST['period']);
                $r_header->addVar('itemid', $_REQUEST['itemid']);
                $cmbFTask = new CComboBox('filter_task', $filter_task, 'submit()');
                $cmbFTask->addItem(FILTER_TAST_SHOW, S_SHOW_SELECTED);
                $cmbFTask->addItem(FILTER_TAST_HIDE, S_HIDE_SELECTED);
                $cmbFTask->addItem(FILTER_TAST_MARK, S_MARK_SELECTED);
                $cmbFTask->addItem(FILTER_TAST_INVERT_MARK, S_MARK_OTHERS);
                $r_header->addItem(array(S_SELECT_ROWS_WITH_VALUE_LIKE, SPACE, new CTextBox('filter', $filter, 25), $cmbFTask, SPACE));
                if (str_in_array($filter_task, array(FILTER_TAST_MARK, FILTER_TAST_INVERT_MARK))) {
                    $cmbColor = new CComboBox('mark_color', $mark_color);
                    $cmbColor->addItem(MARK_COLOR_RED, S_AS_RED);
                    $cmbColor->addItem(MARK_COLOR_GREEN, S_AS_GREEN);
                    $cmbColor->addItem(MARK_COLOR_BLUE, S_AS_BLUE);