コード例 #1
0
 public function _getContent($refresh = false)
 {
     if (!isset($this->config['sql'])) {
         return "SQL not set";
     }
     $table = new CTableInfo($this->emptyText);
     $resultSet = DBselect($this->config['sql']);
     $result = DbFetchArray($resultSet);
     if (!empty($this->columns)) {
         $headers = array();
         foreach ($this->columns as $column) {
             $headers[] = !empty($column['name']) ? $column['name'] : $column['field'];
         }
     } else {
         if (isset($result[0])) {
             foreach ($result[0] as $key => $value) {
                 $headers[] = $key;
                 $column = array('eval' => false, 'evalClass' => false, 'class' => null, 'width' => null, 'name' => $key, 'value' => $key);
                 $this->columns[] = $column;
             }
         } else {
             $headers[] = "Empty Table";
         }
     }
     if ($this->headers) {
         $table->setHeader($headers);
     }
     $index = 0;
     foreach ($result as $row) {
         $row['index'] = $index++;
         $crow = new CRow(null, $this->getRowClass($row));
         foreach ($this->columns as $column) {
             $cell = new CCol($this->getValue($column, $row), $this->getClass($column, $row));
             $crow->addItem($cell);
         }
         $table->addRow($crow);
     }
     return $table;
 }
コード例 #2
0
$this->data['widget']->addHeader(_('Images'), $imageComboBoxForm);
// form
$imageForm = new CForm();
$imageForm->setName('imageForm');
$imageForm->addItem(BR());
$imageTable = new CTable(_('No images found.'), 'header_wide padding_standard');
$count = 0;
$imageRow = new CRow();
foreach ($this->data['images'] as $image) {
    $img = $image['imagetype'] == IMAGE_TYPE_BACKGROUND ? new CLink(new CImg('imgstore.php?width=200&height=200&iconid=' . $image['imageid'], 'no image'), 'image.php?imageid=' . $image['imageid']) : new CImg('imgstore.php?iconid=' . $image['imageid'], 'no image');
    $nodeName = $this->data['displayNodes'] ? new CSpan($image['nodename'], 'unknown') : null;
    $name = new CLink($image['name'], 'adm.images.php?form=update&imageid=' . $image['imageid']);
    $imgColumn = new CCol();
    $imgColumn->setAttribute('align', 'center');
    $imgColumn->addItem(array($img, BR(), $nodeName, $name), 'center');
    $imageRow->addItem($imgColumn);
    $count++;
    if ($count % 4 == 0) {
        $imageTable->addRow($imageRow);
        $imageRow = new CRow();
    }
}
if ($count > 0) {
    while ($count % 4 != 0) {
        $imageRow->addItem(SPACE);
        $count++;
    }
    $imageTable->addRow($imageRow);
}
$imageForm->addItem($imageTable);
return $imageForm;
コード例 #3
0
ファイル: forms.inc.php プロジェクト: omidmt/zabbix-greenplum
function getPermissionsFormList($rights = array(), $user_type = USER_TYPE_ZABBIX_USER, $rightsFormList = null)
{
    // group
    $lists['group']['label'] = _('Host groups');
    $lists['group']['read_write'] = new CListBox('groups_write', null, 15);
    $lists['group']['read_only'] = new CListBox('groups_read', null, 15);
    $lists['group']['deny'] = new CListBox('groups_deny', null, 15);
    $groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY);
    foreach ($groups as $group) {
        switch ($group['permission']) {
            case PERM_READ:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
        }
        $lists['group'][$list_name]->addItem($group['groupid'], $group['name']);
    }
    unset($groups);
    // host
    $lists['host']['label'] = _('Hosts');
    $lists['host']['read_write'] = new CListBox('hosts_write', null, 15);
    $lists['host']['read_only'] = new CListBox('hosts_read', null, 15);
    $lists['host']['deny'] = new CListBox('hosts_deny', null, 15);
    $hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY);
    foreach ($hosts as $host) {
        switch ($host['permission']) {
            case PERM_READ:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
        }
        if (HOST_STATUS_PROXY_ACTIVE == $host['status'] || HOST_STATUS_PROXY_PASSIVE == $host['status']) {
            $host['host_name'] = $host['host'];
        }
        $lists['host'][$list_name]->addItem($host['hostid'], $host['host_name']);
    }
    unset($hosts);
    // display
    if (empty($rightsFormList)) {
        $rightsFormList = new CFormList('rightsFormList');
    }
    $isHeaderDisplayed = false;
    foreach ($lists as $list) {
        $sLabel = '';
        $row = new CRow();
        foreach ($list as $class => $item) {
            if (is_string($item)) {
                $sLabel = $item;
            } else {
                $row->addItem(new CCol($item, $class));
            }
        }
        $table = new CTable(_('No accessible resources'), 'right_table calculated');
        if (!$isHeaderDisplayed) {
            $table->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header');
            $isHeaderDisplayed = true;
        }
        $table->addRow($row);
        $rightsFormList->addRow($sLabel, $table);
    }
    return $rightsFormList;
}
コード例 #4
0
        }
        if (!isset($hosts_data[$group['groupid']])) {
            $hosts_data[$group['groupid']] = ['problematic' => 0, 'ok' => 0, 'lastUnack' => 0];
        }
        if (!isset($problematic_host_list[$host['hostid']])) {
            $hosts_data[$group['groupid']]['ok']++;
        }
    }
}
foreach ($groups as $group) {
    if (!isset($hosts_data[$group['groupid']])) {
        continue;
    }
    $group_row = new CRow();
    $name = new CLink($group['name'], 'tr_status.php?filter_set=1&groupid=' . $group['groupid'] . '&hostid=0' . '&show_triggers=' . TRIGGERS_OPTION_RECENT_PROBLEM);
    $group_row->addItem($name);
    $group_row->addItem((new CCol($hosts_data[$group['groupid']]['ok']))->addClass(ZBX_STYLE_NORMAL_BG));
    if ($data['filter']['extAck']) {
        if ($hosts_data[$group['groupid']]['lastUnack']) {
            $table_inf = new CTableInfo();
            // set trigger severities as table header starting from highest severity
            $header = [];
            for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
                $header[] = $data['filter']['severity'] === null || isset($data['filter']['severity'][$severity]) ? getSeverityName($severity, $data['config']) : null;
            }
            krsort($header);
            array_unshift($header, _('Host'));
            $table_inf->setHeader($header);
            $popup_rows = 0;
            foreach ($group['hosts'] as $host) {
                $hostid = $host['hostid'];
コード例 #5
0
    $ifTab->setAttribute('id', 'JMXInterfaces');
    $ifTab->setAttribute('data-type', 'jmx');
    $row = new CRow(null, null, 'JMXIterfacesFooter');
    if (!isset($existingInterfaceTypes[INTERFACE_TYPE_JMX])) {
        $row->addItem(new CCol(null, 'interface-drag-control'));
        $row->addItem(new CCol(_('No JMX interfaces found.'), null, 5));
    }
    $ifTab->addRow($row);
    $hostList->addRow(_('JMX interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row');
    // table for IPMI interfaces with footer
    $ifTab = new CTable(null, 'formElementTable');
    $ifTab->setAttribute('id', 'IPMIInterfaces');
    $ifTab->setAttribute('data-type', 'ipmi');
    $row = new CRow(null, null, 'IPMIIterfacesFooter');
    if (!isset($existingInterfaceTypes[INTERFACE_TYPE_IPMI])) {
        $row->addItem(new CCol(null, 'interface-drag-control'));
        $row->addItem(new CCol(_('No IPMI interfaces found.'), null, 5));
    }
    $ifTab->addRow($row);
    $hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row interface-row-last');
}
// Proxy
if (!$isDiscovered) {
    $proxyControl = new CComboBox('proxy_hostid', $proxy_hostid);
    $proxyControl->addItem(0, _('(no proxy)'));
    $db_proxies = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND));
    order_result($db_proxies, 'host');
    foreach ($db_proxies as $proxy) {
        $proxyControl->addItem($proxy['proxyid'], $proxy['host']);
    }
} else {
コード例 #6
0
    $text2 = new CTextBox('macros[' . $i . '][value]', $macro['value'], 40, $readonly, 255);
    $text2->setAttribute('placeholder', _('value'));
    $span = new CSpan('&rArr;');
    $span->addStyle('vertical-align:top;');
    $deleteButtonCell = null;
    if (!$readonly) {
        $deleteButtonCell = array(new CButton('macros_' . $i . '_remove', _('Remove'), null, 'link_menu element-table-remove'));
        if (isset($macro['globalmacroid'])) {
            $deleteButtonCell[] = new CVar('macros[' . $i . '][globalmacroid]', $macro['globalmacroid'], 'macros_' . $i . '_id');
        }
        if (isset($macro['hostmacroid'])) {
            $deleteButtonCell[] = new CVar('macros[' . $i . '][hostmacroid]', $macro['hostmacroid'], 'macros_' . $i . '_id');
        }
    }
    $row = array($text1, $span, $text2, $deleteButtonCell);
    $macrosTable->addRow($row, 'form_row');
}
// buttons
if (!$readonly) {
    $addButton = new CButton('macro_add', _('Add'), null, 'link_menu element-table-add');
    $buttonColumn = new CCol($addButton);
    $buttonColumn->setAttribute('colspan', 5);
    $buttonRow = new CRow();
    $buttonRow->setAttribute('id', 'row_new_macro');
    $buttonRow->addItem($buttonColumn);
    $macrosTable->addRow($buttonRow);
}
// form list
$macrosFormList = new CFormList('macrosFormList');
$macrosFormList->addRow($macrosTable);
return $macrosFormList;
コード例 #7
0
function get_macros_widget($hostid = null)
{
    if (isset($_REQUEST['form_refresh'])) {
        $macros = get_request('macros', array());
    } else {
        if ($hostid > 0) {
            $macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'hostids' => $hostid));
            order_result($macros, 'macro');
        } else {
            if ($hostid === null) {
                $macros = CUserMacro::get(array('output' => API_OUTPUT_EXTEND, 'globalmacro' => 1));
                order_result($macros, 'macro');
            } else {
                $macros = array();
            }
        }
    }
    if (empty($macros)) {
        $macros = array(0 => array('macro' => '', 'value' => ''));
    }
    $macros_tbl = new CTable(SPACE, 'formElementTable');
    $macros_tbl->setAttribute('id', 'tbl_macros');
    $macros_tbl->addRow(array(SPACE, S_MACRO, SPACE, S_VALUE));
    insert_js('
			function addMacroRow(){

				if(typeof(addMacroRow.macro_count) == "undefined"){
					addMacroRow.macro_count = ' . count($macros) . ';
				}

				var tr = document.createElement("tr");
				tr.className = (addMacroRow.macro_count % 2) ? "form_even_row" : "form_odd_row";

				var td1 = document.createElement("td");
				tr.appendChild(td1);

				var cb = document.createElement("input");
				cb.setAttribute("type", "checkbox");
				cb.className = "checkbox";
				td1.appendChild(cb);
				td1.appendChild(document.createTextNode(" "));

				var td2 = document.createElement("td");
				tr.appendChild(td2);

				var text1 = document.createElement("input");
				text1.setAttribute("type", "text");
				text1.setAttribute("name", "macros["+addMacroRow.macro_count+"][macro]");
				text1.className = "biginput";
				text1.setAttribute("size",30);
				text1.setAttribute("placeholder","{$MACRO}");
				td2.appendChild(text1);
				td2.appendChild(document.createTextNode(" "));

				var td3 = document.createElement("td");
				tr.appendChild(td3);

				var span = document.createElement("span");
				span.innerHTML = "&rArr;";
				span.setAttribute("style", "vertical-align:top;");
				td3.appendChild(span);

				var td4 = document.createElement("td");
				tr.appendChild(td4);

				var text2 = document.createElement("input");
				text2.setAttribute("type", "text");
				text2.setAttribute("placeholder","<' . S_VALUE . '>");
				text2.setAttribute("name","macros["+addMacroRow.macro_count+"][value]");
				text2.className = "biginput";
				text2.setAttribute("size",40);
				td4.appendChild(text2);

				var sd = $("row_new_macro").insert({before : tr});
				addMacroRow.macro_count++;
			}
		');
    $macros = array_values($macros);
    foreach ($macros as $macroid => $macro) {
        $text1 = new CTextBox('macros[' . $macroid . '][macro]', $macro['macro'], 30);
        $text1->setAttribute('placeholder', '{$MACRO}');
        $text2 = new CTextBox('macros[' . $macroid . '][value]', $macro['value'], 40);
        $text2->setAttribute('placeholder', '<' . S_VALUE . '>');
        $span = new CSpan(RARR);
        $span->addStyle('vertical-align:top;');
        $macros_tbl->addRow(array(new CCheckBox(), $text1, $span, $text2));
    }
    $script = '$$("#tbl_macros input:checked").each(function(obj){ $(obj.parentNode.parentNode).remove(); if (typeof(deleted_macro_cnt) == \'undefined\') deleted_macro_cnt=1; else deleted_macro_cnt++; });';
    $delete_btn = new CButton('macros_del', S_DELETE_SELECTED, $script);
    $delete_btn->setType('button');
    $add_button = new CButton('macro_add', S_ADD, 'javascript: addMacroRow()');
    $add_button->setType('button');
    $buttonRow = new CRow();
    $buttonRow->setAttribute('id', 'row_new_macro');
    $col = new CCol(array($add_button, SPACE, $delete_btn));
    $col->setAttribute('colspan', 4);
    $buttonRow->addItem($col);
    $macros_tbl->addRow($buttonRow);
    $footer = null;
    if ($hostid === null) {
        $footer = array(new CButton('save', S_SAVE, "if (deleted_macro_cnt > 0) return confirm('" . S_ARE_YOU_SURE_YOU_WANT_TO_DELETE . " '+deleted_macro_cnt+' " . S_MACROS_ES . "?');"));
    }
    return new CFormElement(S_MACROS, $macros_tbl, $footer);
}
コード例 #8
0
ファイル: blocks.inc.php プロジェクト: SandipSingh14/Zabbix_
function make_hoststat_summary($filter)
{
    $table = new CTableInfo(_('No host groups found.'));
    $table->setHeader(array(is_show_all_nodes() ? _('Node') : null, _('Host group'), _('Without problems'), _('With problems'), _('Total')));
    // get host groups
    $groups = API::HostGroup()->get(array('nodeids' => get_current_nodeid(), 'groupids' => $filter['groupids'], 'monitored_hosts' => 1, 'output' => array('groupid', 'name')));
    $groups = zbx_toHash($groups, 'groupid');
    foreach ($groups as &$group) {
        $group['nodename'] = get_node_name_by_elid($group['groupid']);
    }
    unset($group);
    CArrayHelper::sort($groups, array(array('field' => 'nodename', 'order' => ZBX_SORT_UP), array('field' => 'name', 'order' => ZBX_SORT_UP)));
    // get hosts
    $hosts = API::Host()->get(array('nodeids' => get_current_nodeid(), 'groupids' => zbx_objectValues($groups, 'groupid'), 'hostids' => !empty($filter['hostids']) ? $filter['hostids'] : null, 'monitored_hosts' => true, 'filter' => array('maintenance_status' => $filter['maintenance']), 'output' => array('hostid', 'name'), 'selectGroups' => array('groupid')));
    $hosts = zbx_toHash($hosts, 'hostid');
    CArrayHelper::sort($hosts, array('name'));
    // get triggers
    $triggers = API::Trigger()->get(array('nodeids' => get_current_nodeid(), 'monitored' => true, 'maintenance' => $filter['maintenance'], 'expandData' => true, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => array('triggerid', 'priority'), 'selectHosts' => array('hostid')));
    if ($filter['extAck']) {
        $triggers_unack = API::Trigger()->get(array('nodeids' => get_current_nodeid(), 'monitored' => true, 'maintenance' => $filter['maintenance'], 'withLastEventUnacknowledged' => true, 'selectHosts' => API_OUTPUT_REFER, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => API_OUTPUT_REFER));
        $triggers_unack = zbx_toHash($triggers_unack, 'triggerid');
        foreach ($triggers_unack as $tunack) {
            foreach ($tunack['hosts'] as $unack_host) {
                $hosts_with_unack_triggers[$unack_host['hostid']] = $unack_host['hostid'];
            }
        }
    }
    $hosts_data = array();
    $problematic_host_list = array();
    $lastUnack_host_list = array();
    $highest_severity = array();
    $highest_severity2 = array();
    foreach ($triggers as $trigger) {
        foreach ($trigger['hosts'] as $trigger_host) {
            if (!isset($hosts[$trigger_host['hostid']])) {
                continue;
            } else {
                $host = $hosts[$trigger_host['hostid']];
            }
            if ($filter['extAck'] && isset($hosts_with_unack_triggers[$host['hostid']])) {
                if (!isset($lastUnack_host_list[$host['hostid']])) {
                    $lastUnack_host_list[$host['hostid']] = array();
                    $lastUnack_host_list[$host['hostid']]['host'] = $host['name'];
                    $lastUnack_host_list[$host['hostid']]['hostid'] = $host['hostid'];
                    $lastUnack_host_list[$host['hostid']]['severities'] = array();
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
                }
                if (isset($triggers_unack[$trigger['triggerid']])) {
                    $lastUnack_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
                }
                foreach ($host['groups'] as $gnum => $group) {
                    if (!isset($highest_severity2[$group['groupid']])) {
                        $highest_severity2[$group['groupid']] = 0;
                    }
                    if ($trigger['priority'] > $highest_severity2[$group['groupid']]) {
                        $highest_severity2[$group['groupid']] = $trigger['priority'];
                    }
                    if (!isset($hosts_data[$group['groupid']])) {
                        $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
                    }
                    if (!isset($hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']])) {
                        $hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']] = $host['hostid'];
                        $hosts_data[$group['groupid']]['lastUnack']++;
                    }
                }
            }
            if (!isset($problematic_host_list[$host['hostid']])) {
                $problematic_host_list[$host['hostid']] = array();
                $problematic_host_list[$host['hostid']]['host'] = $host['name'];
                $problematic_host_list[$host['hostid']]['hostid'] = $host['hostid'];
                $problematic_host_list[$host['hostid']]['severities'] = array();
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
            }
            $problematic_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
            foreach ($host['groups'] as $gnum => $group) {
                if (!isset($highest_severity[$group['groupid']])) {
                    $highest_severity[$group['groupid']] = 0;
                }
                if ($trigger['priority'] > $highest_severity[$group['groupid']]) {
                    $highest_severity[$group['groupid']] = $trigger['priority'];
                }
                if (!isset($hosts_data[$group['groupid']])) {
                    $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
                }
                if (!isset($hosts_data[$group['groupid']]['hostids_all'][$host['hostid']])) {
                    $hosts_data[$group['groupid']]['hostids_all'][$host['hostid']] = $host['hostid'];
                    $hosts_data[$group['groupid']]['problematic']++;
                }
            }
        }
    }
    foreach ($hosts as $host) {
        foreach ($host['groups'] as $group) {
            if (!isset($groups[$group['groupid']])) {
                continue;
            }
            if (!isset($groups[$group['groupid']]['hosts'])) {
                $groups[$group['groupid']]['hosts'] = array();
            }
            $groups[$group['groupid']]['hosts'][$host['hostid']] = array('hostid' => $host['hostid']);
            if (!isset($highest_severity[$group['groupid']])) {
                $highest_severity[$group['groupid']] = 0;
            }
            if (!isset($hosts_data[$group['groupid']])) {
                $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0);
            }
            if (!isset($problematic_host_list[$host['hostid']])) {
                $hosts_data[$group['groupid']]['ok']++;
            }
        }
    }
    foreach ($groups as $group) {
        if (!isset($hosts_data[$group['groupid']])) {
            continue;
        }
        $group_row = new CRow();
        if (is_show_all_nodes()) {
            $group_row->addItem($group['nodename']);
        }
        $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=0&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
        $group_row->addItem($name);
        $group_row->addItem(new CCol($hosts_data[$group['groupid']]['ok'], 'normal'));
        if ($filter['extAck']) {
            if ($hosts_data[$group['groupid']]['lastUnack']) {
                $table_inf = new CTableInfo();
                $table_inf->setAttribute('style', 'width: 400px;');
                $table_inf->setHeader(array(_('Host'), is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? getSeverityCaption(TRIGGER_SEVERITY_DISASTER) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? getSeverityCaption(TRIGGER_SEVERITY_HIGH) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? getSeverityCaption(TRIGGER_SEVERITY_AVERAGE) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? getSeverityCaption(TRIGGER_SEVERITY_WARNING) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? getSeverityCaption(TRIGGER_SEVERITY_INFORMATION) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED) : null));
                $popup_rows = 0;
                foreach ($group['hosts'] as $host) {
                    $hostid = $host['hostid'];
                    if (!isset($lastUnack_host_list[$hostid])) {
                        continue;
                    }
                    if ($popup_rows >= ZBX_WIDGET_ROWS) {
                        break;
                    }
                    $popup_rows++;
                    $host_data = $lastUnack_host_list[$hostid];
                    $r = new CRow();
                    $r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
                    foreach ($lastUnack_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
                        if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                            continue;
                        }
                        $r->addItem(new CCol($trigger_count, getSeverityStyle($severity, $trigger_count)));
                    }
                    $table_inf->addRow($r);
                }
                $lastUnack_count = new CSpan($hosts_data[$group['groupid']]['lastUnack'], 'pointer red bold');
                $lastUnack_count->setHint($table_inf);
            } else {
                $lastUnack_count = 0;
            }
        }
        // if hostgroup contains problematic hosts, hint should be built
        if ($hosts_data[$group['groupid']]['problematic']) {
            $table_inf = new CTableInfo();
            $table_inf->setAttribute('style', 'width: 400px;');
            $table_inf->setHeader(array(_('Host'), is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? getSeverityCaption(TRIGGER_SEVERITY_DISASTER) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? getSeverityCaption(TRIGGER_SEVERITY_HIGH) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? getSeverityCaption(TRIGGER_SEVERITY_AVERAGE) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? getSeverityCaption(TRIGGER_SEVERITY_WARNING) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? getSeverityCaption(TRIGGER_SEVERITY_INFORMATION) : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? getSeverityCaption(TRIGGER_SEVERITY_NOT_CLASSIFIED) : null));
            $popup_rows = 0;
            foreach ($group['hosts'] as $host) {
                $hostid = $host['hostid'];
                if (!isset($problematic_host_list[$hostid])) {
                    continue;
                }
                if ($popup_rows >= ZBX_WIDGET_ROWS) {
                    break;
                }
                $popup_rows++;
                $host_data = $problematic_host_list[$hostid];
                $r = new CRow();
                $r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
                foreach ($problematic_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
                    if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                        continue;
                    }
                    $r->addItem(new CCol($trigger_count, getSeverityStyle($severity, $trigger_count)));
                }
                $table_inf->addRow($r);
            }
            $problematic_count = new CSpan($hosts_data[$group['groupid']]['problematic'], 'pointer');
            $problematic_count->setHint($table_inf);
        } else {
            $problematic_count = 0;
        }
        switch ($filter['extAck']) {
            case EXTACK_OPTION_ALL:
                $group_row->addItem(new CCol($problematic_count, getSeverityStyle($highest_severity[$group['groupid']], $hosts_data[$group['groupid']]['problematic'])));
                $group_row->addItem($hosts_data[$group['groupid']]['problematic'] + $hosts_data[$group['groupid']]['ok']);
                break;
            case EXTACK_OPTION_UNACK:
                $group_row->addItem(new CCol($lastUnack_count, getSeverityStyle(isset($highest_severity2[$group['groupid']]) ? $highest_severity2[$group['groupid']] : 0, $hosts_data[$group['groupid']]['lastUnack'])));
                $group_row->addItem($hosts_data[$group['groupid']]['lastUnack'] + $hosts_data[$group['groupid']]['ok']);
                break;
            case EXTACK_OPTION_BOTH:
                $unackspan = $lastUnack_count ? new CSpan(array($lastUnack_count, SPACE . _('of') . SPACE)) : null;
                $group_row->addItem(new CCol(array($unackspan, $problematic_count), getSeverityStyle($highest_severity[$group['groupid']], $hosts_data[$group['groupid']]['problematic'])));
                $group_row->addItem($hosts_data[$group['groupid']]['problematic'] + $hosts_data[$group['groupid']]['ok']);
                break;
        }
        $table->addRow($group_row);
    }
    $script = new CJSScript(get_js("jQuery('#hat_hoststat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    return new CDiv(array($table, $script));
}
コード例 #9
0
ファイル: forms.inc.php プロジェクト: rennhak/zabbix
function get_rights_of_elements_table($rights = array(), $user_type = USER_TYPE_ZABBIX_USER)
{
    global $ZBX_LOCALNODEID;
    $table = new CTable('S_NO_ACCESSIBLE_RESOURCES', 'right_table');
    $table->SetHeader(array(SPACE, S_READ_WRITE, S_READ_ONLY, S_DENY), 'header');
    if (ZBX_DISTRIBUTED) {
        $lst['node']['label'] = S_NODES;
        $lst['node']['read_write'] = new CListBox('nodes_write', null, 10);
        $lst['node']['read_only'] = new CListBox('nodes_read', null, 10);
        $lst['node']['deny'] = new CListBox('nodes_deny', null, 10);
        $nodes = get_accessible_nodes_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY);
        foreach ($nodes as $node) {
            switch ($node['permission']) {
                case PERM_READ_ONLY:
                    $list_name = 'read_only';
                    break;
                case PERM_READ_WRITE:
                    $list_name = 'read_write';
                    break;
                default:
                    $list_name = 'deny';
                    break;
            }
            $lst['node'][$list_name]->addItem($node['nodeid'], $node['name']);
        }
        unset($nodes);
    }
    $lst['group']['label'] = S_HOST_GROUPS;
    $lst['group']['read_write'] = new CListBox('groups_write', null, 15);
    $lst['group']['read_only'] = new CListBox('groups_read', null, 15);
    $lst['group']['deny'] = new CListBox('groups_deny', null, 15);
    $groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
    foreach ($groups as $group) {
        switch ($group['permission']) {
            case PERM_READ_ONLY:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
        }
        $lst['group'][$list_name]->addItem($group['groupid'], $group['node_name'] . ':' . $group['name']);
    }
    unset($groups);
    $lst['host']['label'] = S_HOSTS;
    $lst['host']['read_write'] = new CListBox('hosts_write', null, 15);
    $lst['host']['read_only'] = new CListBox('hosts_read', null, 15);
    $lst['host']['deny'] = new CListBox('hosts_deny', null, 15);
    $hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
    foreach ($hosts as $host) {
        switch ($host['permission']) {
            case PERM_READ_ONLY:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
                break;
        }
        $lst['host'][$list_name]->addItem($host['hostid'], $host['node_name'] . ':' . $host['host']);
    }
    unset($hosts);
    foreach ($lst as $name => $lists) {
        $row = new CRow();
        foreach ($lists as $class => $list_obj) {
            $row->addItem(new CCol($list_obj, $class));
        }
        $table->addRow($row);
    }
    unset($lst);
    return $table;
}
コード例 #10
0
function make_trigger_table($triggers, $host_name)
{
    $table = new CTableInfo();
    $table->setHeader(array(_('Host'), _('Problem'), _('Age')));
    foreach ($triggers as $trigger) {
        $description = $trigger["description"];
        $r = new CRow();
        $r->addItem($host_name);
        $r->addItem(new CCol($description, getSeverityStyle($trigger['priority'])));
        $r->addItem(zbx_date2age($trigger['lastchange']));
        $table->addRow($r);
    }
    return $table;
}
コード例 #11
0
ファイル: class.ctree.php プロジェクト: phedders/zabbix
 private function makeSImgStr($id)
 {
     $tr = new CRow();
     $td = new CCol();
     $count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0;
     for ($i = 0; $i < $count; $i++) {
         switch ($this->tree[$id]['nodeimg'][$i]) {
             case 'O':
                 $td->setAttribute('style', 'width: 22px');
                 $img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
                 break;
             case 'I':
                 $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                 $img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
                 break;
             case 'L':
                 $td->setAttribute('valign', 'top');
                 //					$td->setAttribute('style','width:22px; background-image:url(images/general/tree/pointc.gif);');
                 $div = new CTag('div', 'yes');
                 $div->setAttribute('style', 'height: 10px; width:22px; background-image:url(images/general/tree/pointc.gif);');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
                     $img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
                     // IE6 Fix
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setClass('imgnode');
                 } else {
                     $img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
                 }
                 $div->addItem($img);
                 $img = $div;
                 break;
             case 'T':
                 $td->setAttribute('valign', 'top');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
                     $img->setAttribute('onclick', 'javascript: ' . $this->treename . '.closeSNodeX(' . $id . ',this);' . " showPopupDiv('div_node_tree','select_iframe');");
                     // IE6 Fix
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setClass('imgnode');
                 } else {
                     $td->setAttribute('style', 'width:22px; background-image:url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
                 }
                 break;
         }
         $td->addItem($img);
         $tr->addItem($td);
         $td = new CCol();
     }
     //	echo $txt.' '.$this->tree[$id]['Name'].'<br />';
     return $tr;
 }
コード例 #12
0
function make_awsstat_summary($preloading = false)
{
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, _('Account name'), _('PoweredOn'), _('PoweredOff'), _('Billing/Month')));
    $script_itemkey = 'push_message.py[{$HYCLOPS_SERVER},{$HYCLOPS_PORT},ec2,{HOST.HOST}]';
    $aws_accounts = get_aws_accounts();
    if (empty($aws_accounts)) {
        return null;
    }
    foreach ($aws_accounts as $host) {
        if (!$preloading) {
            if (is_script_success($host['hostid'], $script_itemkey)) {
                $instances = get_instances($host['hostid']);
                $instances = filter_instances($instances);
                $r = new CRow();
                // Account name
                $col = new CCol($host['host']);
                $r->addItem($col);
                // Poweron (running + pending)
                $poweron_vms = array_merge($instances["running"], $instances["pending"]);
                $poweron_count = new CSpan(count($poweron_vms), 'pointer');
                if (!empty($poweron_vms)) {
                    $poweron_count->setHint(make_ec2_table('ec2_poweron', $poweron_vms));
                }
                $r->addItem(new CCol($poweron_count));
                // Poweroff (stopped + terminated + stopping + shutting-down)
                $poweroff_vms = $instances["stopped"];
                $poweroff_count = new CSpan(count($poweroff_vms), 'pointer');
                if (!empty($poweroff_vms)) {
                    $poweroff_count->setHint(make_ec2_table('ec2_poweroff', $poweroff_vms));
                }
                $r->addItem(new CCol($poweroff_count));
                // AWS Charges
                $item = get_item_by_key('get_aws_charges.py[{$KEY},{$SECRET}]', $host["host"]);
                if (array_key_exists('lastvalue', $item)) {
                    $r->addItem(new CLink($item["lastvalue"], "history.php?action=showgraph&itemid={$item["itemid"]}"));
                } else {
                    $r->addItem(new CCol(_('No data')));
                }
                $table->addRow($r);
                zbx_add_post_js('chkbxRange.pageGoName = "vms";');
            } else {
                $r = new CRow();
                $r->addItem($host['host']);
                $r->addItem(new CCol(_('script failed'), "high"));
                $r->addItem(array("-"));
                $table->addRow($r);
            }
        } else {
            $r = new CRow();
            $r->addItem($host['host']);
            $r->addItem(new CCol(_('loading...')));
            $r->addItem(array("-"));
            $table->addRow($r);
        }
    }
    $script = new CJSScript(get_js("jQuery('#hat_awsstat_footer').html('" . _s('Updated: %s', zbx_date2str(_('H:i:s'))) . "')"));
    return new CDiv(array($table, $script));
}
コード例 #13
0
function make_hoststat_summary($filter)
{
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST_GROUP, S_WITHOUT_PROBLEMS, S_WITH_PROBLEMS, S_TOTAL));
    // SELECT HOST GROUPS {{{
    $options = array('nodeids' => get_current_nodeid(), 'groupids' => $filter['groupids'], 'monitored_hosts' => 1, 'output' => API_OUTPUT_EXTEND);
    $groups = CHostGroup::get($options);
    $groups = zbx_toHash($groups, 'groupid');
    order_result($groups, 'name');
    // }}} SELECT HOST GROUPS
    // SELECT HOSTS {{{
    $options = array('nodeids' => get_current_nodeid(), 'groupids' => zbx_objectValues($groups, 'groupid'), 'monitored_hosts' => 1, 'filter' => array('maintenance_status' => $filter['maintenance']), 'output' => array('hostid', 'host'));
    $hosts = CHost::get($options);
    $hosts = zbx_toHash($hosts, 'hostid');
    // }}} SELECT HOSTS
    // SELECT TRIGGERS {{{
    $options = array('nodeids' => get_current_nodeid(), 'monitored' => 1, 'maintenance' => $filter['maintenance'], 'expandData' => 1, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => API_OUTPUT_EXTEND);
    $triggers = CTrigger::get($options);
    if ($filter['extAck']) {
        $options = array('nodeids' => get_current_nodeid(), 'monitored' => 1, 'maintenance' => $filter['maintenance'], 'withLastEventUnacknowledged' => 1, 'select_hosts' => API_OUTPUT_REFER, 'filter' => array('priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE), 'output' => API_OUTPUT_REFER);
        $triggers_unack = CTrigger::get($options);
        $triggers_unack = zbx_toHash($triggers_unack, 'triggerid');
        foreach ($triggers_unack as $tunack) {
            foreach ($tunack['hosts'] as $unack_host) {
                $hosts_with_unack_triggers[$unack_host['hostid']] = $unack_host['hostid'];
            }
        }
    }
    // }}} SELECT TRIGGERS
    $hosts_data = array();
    $problematic_host_list = array();
    $lastUnack_host_list = array();
    $highest_severity = array();
    $highest_severity2 = array();
    foreach ($triggers as $tnum => $trigger) {
        foreach ($trigger['hosts'] as $thnum => $trigger_host) {
            if (!isset($hosts[$trigger_host['hostid']])) {
                continue;
            } else {
                $host = $hosts[$trigger_host['hostid']];
            }
            if ($filter['extAck'] && isset($hosts_with_unack_triggers[$host['hostid']])) {
                if (!isset($lastUnack_host_list[$host['hostid']])) {
                    $lastUnack_host_list[$host['hostid']] = array();
                    $lastUnack_host_list[$host['hostid']]['host'] = $host['host'];
                    $lastUnack_host_list[$host['hostid']]['hostid'] = $host['hostid'];
                    $lastUnack_host_list[$host['hostid']]['severities'] = array();
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
                    $lastUnack_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
                }
                if (isset($triggers_unack[$trigger['triggerid']])) {
                    $lastUnack_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
                }
                foreach ($host['groups'] as $gnum => $group) {
                    if (!isset($highest_severity2[$group['groupid']])) {
                        $highest_severity2[$group['groupid']] = 0;
                    }
                    if ($trigger['priority'] > $highest_severity2[$group['groupid']]) {
                        $highest_severity2[$group['groupid']] = $trigger['priority'];
                    }
                    if (!isset($hosts_data[$group['groupid']])) {
                        $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
                    }
                    if (!isset($hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']])) {
                        $hosts_data[$group['groupid']]['hostids_unack'][$host['hostid']] = $host['hostid'];
                        $hosts_data[$group['groupid']]['lastUnack']++;
                    }
                }
            }
            if (!isset($problematic_host_list[$host['hostid']])) {
                $problematic_host_list[$host['hostid']] = array();
                $problematic_host_list[$host['hostid']]['host'] = $host['host'];
                $problematic_host_list[$host['hostid']]['hostid'] = $host['hostid'];
                $problematic_host_list[$host['hostid']]['severities'] = array();
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_DISASTER] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_HIGH] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_AVERAGE] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_WARNING] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_INFORMATION] = 0;
                $problematic_host_list[$host['hostid']]['severities'][TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
            }
            $problematic_host_list[$host['hostid']]['severities'][$trigger['priority']]++;
            foreach ($host['groups'] as $gnum => $group) {
                if (!isset($highest_severity[$group['groupid']])) {
                    $highest_severity[$group['groupid']] = 0;
                }
                if ($trigger['priority'] > $highest_severity[$group['groupid']]) {
                    $highest_severity[$group['groupid']] = $trigger['priority'];
                }
                if (!isset($hosts_data[$group['groupid']])) {
                    $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0, 'hostids_all' => array(), 'hostids_unack' => array());
                }
                if (!isset($hosts_data[$group['groupid']]['hostids_all'][$host['hostid']])) {
                    $hosts_data[$group['groupid']]['hostids_all'][$host['hostid']] = $host['hostid'];
                    $hosts_data[$group['groupid']]['problematic']++;
                }
            }
        }
    }
    foreach ($hosts as $hnum => $host) {
        foreach ($host['groups'] as $gnum => $group) {
            if (!isset($groups[$group['groupid']]['hosts'])) {
                $groups[$group['groupid']]['hosts'] = array();
            }
            $groups[$group['groupid']]['hosts'][$host['hostid']] = array('hostid' => $host['hostid']);
            if (!isset($highest_severity[$group['groupid']])) {
                $highest_severity[$group['groupid']] = 0;
            }
            if (!isset($hosts_data[$group['groupid']])) {
                $hosts_data[$group['groupid']] = array('problematic' => 0, 'ok' => 0, 'lastUnack' => 0);
            }
            if (!isset($problematic_host_list[$host['hostid']])) {
                $hosts_data[$group['groupid']]['ok']++;
            }
        }
    }
    foreach ($groups as $gnum => $group) {
        if (!isset($hosts_data[$group['groupid']])) {
            continue;
        }
        $group_row = new CRow();
        if (is_show_all_nodes()) {
            $group_row->addItem(get_node_name_by_elid($group['groupid']));
        }
        $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=0&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
        $group_row->addItem($name);
        $group_row->addItem(new CCol($hosts_data[$group['groupid']]['ok'], 'normal'));
        if ($filter['extAck']) {
            if ($hosts_data[$group['groupid']]['lastUnack']) {
                $table_inf = new CTableInfo();
                $table_inf->setAttribute('style', 'width: 400px;');
                $table_inf->setHeader(array(S_HOST, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? S_DISASTER : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? S_HIGH : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? S_AVERAGE : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? S_WARNING : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? S_INFORMATION : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? S_NOT_CLASSIFIED : null));
                $popup_rows = 0;
                foreach ($group['hosts'] as $hnum => $host) {
                    $hostid = $host['hostid'];
                    if (!isset($lastUnack_host_list[$hostid])) {
                        continue;
                    }
                    if ($popup_rows >= ZBX_WIDGET_ROWS) {
                        break;
                    }
                    $popup_rows++;
                    $host_data = $lastUnack_host_list[$hostid];
                    $r = new CRow();
                    $r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
                    foreach ($lastUnack_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
                        if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                            continue;
                        }
                        $r->addItem(new CCol($trigger_count, get_severity_style($severity, $trigger_count)));
                    }
                    $table_inf->addRow($r);
                }
                $lastUnack_count = new CSpan($hosts_data[$group['groupid']]['lastUnack'], 'pointer red bold');
                $lastUnack_count->setHint($table_inf);
            } else {
                $lastUnack_count = 0;
            }
        }
        // if hostgroup contains problematic hosts, hint should be built
        if ($hosts_data[$group['groupid']]['problematic']) {
            $table_inf = new CTableInfo();
            $table_inf->setAttribute('style', 'width: 400px;');
            $table_inf->setHeader(array(S_HOST, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_DISASTER]) ? S_DISASTER : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_HIGH]) ? S_HIGH : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_AVERAGE]) ? S_AVERAGE : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_WARNING]) ? S_WARNING : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_INFORMATION]) ? S_INFORMATION : null, is_null($filter['severity']) || isset($filter['severity'][TRIGGER_SEVERITY_NOT_CLASSIFIED]) ? S_NOT_CLASSIFIED : null));
            $popup_rows = 0;
            foreach ($group['hosts'] as $hnum => $host) {
                $hostid = $host['hostid'];
                if (!isset($problematic_host_list[$hostid])) {
                    continue;
                }
                if ($popup_rows >= ZBX_WIDGET_ROWS) {
                    break;
                }
                $popup_rows++;
                $host_data = $problematic_host_list[$hostid];
                $r = new CRow();
                $r->addItem(new CLink($host_data['host'], 'tr_status.php?groupid=' . $group['groupid'] . '&hostid=' . $hostid . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE));
                foreach ($problematic_host_list[$host['hostid']]['severities'] as $severity => $trigger_count) {
                    if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                        continue;
                    }
                    $r->addItem(new CCol($trigger_count, get_severity_style($severity, $trigger_count)));
                }
                $table_inf->addRow($r);
            }
            $problematic_count = new CSpan($hosts_data[$group['groupid']]['problematic'], 'pointer');
            $problematic_count->setHint($table_inf);
        } else {
            $problematic_count = 0;
        }
        switch ($filter['extAck']) {
            case EXTACK_OPTION_ALL:
                $group_row->addItem(new CCol($problematic_count, get_severity_style($highest_severity[$group['groupid']], $hosts_data[$group['groupid']]['problematic'])));
                $group_row->addItem($hosts_data[$group['groupid']]['problematic'] + $hosts_data[$group['groupid']]['ok']);
                break;
            case EXTACK_OPTION_UNACK:
                $group_row->addItem(new CCol($lastUnack_count, get_severity_style(isset($highest_severity2[$group['groupid']]) ? $highest_severity2[$group['groupid']] : 0, $hosts_data[$group['groupid']]['lastUnack'])));
                $group_row->addItem($hosts_data[$group['groupid']]['lastUnack'] + $hosts_data[$group['groupid']]['ok']);
                break;
            case EXTACK_OPTION_BOTH:
                $unackspan = $lastUnack_count ? new CSpan(array($lastUnack_count, SPACE . S_OF . SPACE)) : null;
                $group_row->addItem(new CCol(array($unackspan, $problematic_count), get_severity_style($highest_severity[$group['groupid']], $hosts_data[$group['groupid']]['problematic'])));
                $group_row->addItem($hosts_data[$group['groupid']]['problematic'] + $hosts_data[$group['groupid']]['ok']);
                break;
        }
        $table->addRow($group_row);
    }
    $table->setFooter(new CCol(S_UPDATED . ': ' . zbx_date2str(S_BLOCKS_HOSTSTAT_SUMMARY_TIME_FORMAT)));
    return $table;
}
コード例 #14
0
function getPermissionsFormList($rights = array(), $user_type = USER_TYPE_ZABBIX_USER, $rightsFormList = null)
{
    // nodes
    if (ZBX_DISTRIBUTED) {
        $lists['node']['label'] = _('Nodes');
        $lists['node']['read_write'] = new CListBox('nodes_write', null, 10);
        $lists['node']['read_only'] = new CListBox('nodes_read', null, 10);
        $lists['node']['deny'] = new CListBox('nodes_deny', null, 10);
        $lists['node']['read_write']->setAttribute('style', 'background: #EBEFF2;');
        $lists['node']['read_only']->setAttribute('style', 'background: #EBEFF2;');
        $lists['node']['deny']->setAttribute('style', 'background: #EBEFF2;');
        $nodes = get_accessible_nodes_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY);
        foreach ($nodes as $node) {
            switch ($node['permission']) {
                case PERM_READ_ONLY:
                    $list_name = 'read_only';
                    break;
                case PERM_READ_WRITE:
                    $list_name = 'read_write';
                    break;
                default:
                    $list_name = 'deny';
            }
            $lists['node'][$list_name]->addItem($node['nodeid'], $node['name']);
        }
        unset($nodes);
    }
    // group
    $lists['group']['label'] = _('Host groups');
    $lists['group']['read_write'] = new CListBox('groups_write', null, 15);
    $lists['group']['read_only'] = new CListBox('groups_read', null, 15);
    $lists['group']['deny'] = new CListBox('groups_deny', null, 15);
    $lists['group']['read_write']->setAttribute('style', 'background: #EBEFF2;');
    $lists['group']['read_only']->setAttribute('style', 'background: #EBEFF2;');
    $lists['group']['deny']->setAttribute('style', 'background: #EBEFF2;');
    $groups = get_accessible_groups_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
    foreach ($groups as $group) {
        switch ($group['permission']) {
            case PERM_READ_ONLY:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
        }
        $lists['group'][$list_name]->addItem($group['groupid'], (empty($group['node_name']) ? '' : $group['node_name'] . ':') . $group['name']);
    }
    unset($groups);
    // host
    $lists['host']['label'] = _('Hosts');
    $lists['host']['read_write'] = new CListBox('hosts_write', null, 15);
    $lists['host']['read_only'] = new CListBox('hosts_read', null, 15);
    $lists['host']['deny'] = new CListBox('hosts_deny', null, 15);
    $lists['host']['read_write']->setAttribute('style', 'background: #EBEFF2;');
    $lists['host']['read_only']->setAttribute('style', 'background: #EBEFF2;');
    $lists['host']['deny']->setAttribute('style', 'background: #EBEFF2;');
    $hosts = get_accessible_hosts_by_rights($rights, $user_type, PERM_DENY, PERM_RES_DATA_ARRAY, get_current_nodeid(true));
    foreach ($hosts as $host) {
        switch ($host['permission']) {
            case PERM_READ_ONLY:
                $list_name = 'read_only';
                break;
            case PERM_READ_WRITE:
                $list_name = 'read_write';
                break;
            default:
                $list_name = 'deny';
        }
        if (HOST_STATUS_PROXY_ACTIVE == $host['status'] || HOST_STATUS_PROXY_PASSIVE == $host['status']) {
            $host['host_name'] = $host['host'];
        }
        $lists['host'][$list_name]->addItem($host['hostid'], (empty($host['node_name']) ? '' : $host['node_name'] . ':') . $host['host_name']);
    }
    unset($hosts);
    // display
    if (empty($rightsFormList)) {
        $rightsFormList = new CFormList('rightsFormList');
    }
    $isHeaderDisplayed = false;
    foreach ($lists as $list) {
        $sLabel = '';
        $row = new CRow();
        foreach ($list as $class => $item) {
            if (is_string($item)) {
                $sLabel = $item;
            } else {
                $row->addItem(new CCol($item, $class));
            }
        }
        $table = new CTable(_('No accessible resources'), 'right_table');
        if (!$isHeaderDisplayed) {
            $table->setHeader(array(_('Read-write'), _('Read only'), _('Deny')), 'header');
            $isHeaderDisplayed = true;
        }
        $table->addRow($row);
        $rightsFormList->addRow($sLabel, $table);
    }
    return $rightsFormList;
}
コード例 #15
0
ファイル: blocks.inc.php プロジェクト: phedders/zabbix
function make_system_summary($args = array())
{
    global $USER_DETAILS;
    $config = select_config();
    $available_hosts = get_accessible_hosts_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    $available_groups = get_accessible_groups_by_user($USER_DETAILS, PERM_READ_ONLY, PERM_RES_IDS_ARRAY);
    $available_triggers = get_accessible_triggers(PERM_READ_ONLY, array(), PERM_RES_IDS_ARRAY);
    if (isset($args['hosts']) && !empty($args['hosts'])) {
        $available_hosts = zbx_uint_array_intersect($args['hosts'], $available_hosts);
    }
    if (isset($args['groups']) && !empty($args['groups'])) {
        $available_groups = zbx_uint_array_intersect($args['groups'], $available_groups);
    }
    $sql_where = '';
    if (isset($args['severity']) && ctype_digit($args['severity'])) {
        $sql_where = ' AND t.priority>=' . $args['severity'];
    }
    $table = new CTableInfo();
    $table->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST_GROUP, S_DISASTER, S_HIGH, S_AVERAGE, S_WARNING, S_INFORMATION, S_NOT_CLASSIFIED));
    $sql = 'SELECT DISTINCT g.groupid,g.name ' . ' FROM groups g, hosts_groups hg, hosts h, items i, functions f, triggers t ' . ' WHERE ' . DBcondition('h.hostid', $available_hosts) . ' AND ' . DBcondition('g.groupid', $available_groups) . ' AND hg.groupid=g.groupid ' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' ORDER BY g.name';
    $gr_result = DBselect($sql);
    while ($group = DBFetch($gr_result)) {
        $group_row = new CRow();
        if (is_show_all_nodes()) {
            $group_row->addItem(get_node_name_by_elid($group['groupid']));
        }
        $name = new CLink($group['name'], 'tr_status.php?groupid=' . $group['groupid'] . '&show_triggers=' . TRIGGERS_OPTION_ONLYTRUE);
        $name->setTarget('blank');
        $group_row->addItem($name);
        $tab_priority[TRIGGER_SEVERITY_DISASTER] = 0;
        $tab_priority[TRIGGER_SEVERITY_HIGH] = 0;
        $tab_priority[TRIGGER_SEVERITY_AVERAGE] = 0;
        $tab_priority[TRIGGER_SEVERITY_WARNING] = 0;
        $tab_priority[TRIGGER_SEVERITY_INFORMATION] = 0;
        $tab_priority[TRIGGER_SEVERITY_NOT_CLASSIFIED] = 0;
        $sql = 'SELECT count(DISTINCT t.triggerid) as tr_cnt,t.priority ' . ' FROM hosts h,items i,hosts_groups hg, functions f, triggers t ' . ' WHERE h.status=' . HOST_STATUS_MONITORED . ' AND h.hostid=i.hostid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND hg.hostid=h.hostid' . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.itemid=f.itemid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND ' . DBcondition('h.hostid', $available_hosts) . ' GROUP BY t.priority';
        //SDI($sql);
        $tr_result = DBSelect($sql);
        while ($group_stat = DBFetch($tr_result)) {
            $tab_priority[$group_stat['priority']] = $group_stat['tr_cnt'];
        }
        foreach ($tab_priority as $key => $value) {
            $tr_count = 0;
            if ($value) {
                //* trigger list
                $table_inf = new CTableInfo();
                $table_inf->setAttribute('style', 'width: 400px;');
                $table_inf->setHeader(array(is_show_all_nodes() ? S_NODE : null, S_HOST, S_ISSUE, S_AGE, $config['event_ack_enable'] ? S_ACK : NULL, S_ACTIONS));
                $sql = 'SELECT DISTINCT t.triggerid,t.status,t.description,t.expression,t.priority,t.lastchange,t.value,h.host,h.hostid ' . ' FROM triggers t,hosts h,items i,functions f, hosts_groups hg ' . ' WHERE f.itemid=i.itemid ' . ' AND hg.groupid=' . $group['groupid'] . ' AND h.hostid=i.hostid ' . ' AND hg.hostid=h.hostid ' . ' AND t.triggerid=f.triggerid ' . ' AND t.status=' . TRIGGER_STATUS_ENABLED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND ' . DBcondition('t.triggerid', $available_triggers) . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND t.value=' . TRIGGER_VALUE_TRUE . ' AND t.priority=' . $key . ' ORDER BY t.lastchange DESC';
                $result = DBselect($sql);
                while ($row_inf = DBfetch($result)) {
                    // Check for dependencies
                    if (trigger_dependent($row_inf["triggerid"])) {
                        continue;
                    }
                    $tr_count++;
                    if ($tr_count > 30) {
                        continue;
                    }
                    $host = new CSpan($row_inf['host']);
                    $event_sql = 'SELECT e.eventid, e.value, e.clock, e.objectid as triggerid, e.acknowledged, t.type ' . ' FROM events e, triggers t ' . ' WHERE e.object=' . EVENT_SOURCE_TRIGGERS . ' AND e.objectid=' . $row_inf['triggerid'] . ' AND t.triggerid=e.objectid ' . ' AND e.value=' . TRIGGER_VALUE_TRUE . ' ORDER by e.object DESC, e.objectid DESC, e.eventid DESC';
                    if ($row_inf_event = DBfetch(DBselect($event_sql, 1))) {
                        if ($config['event_ack_enable']) {
                            if ($row_inf_event['acknowledged'] == 1) {
                                $ack = new CLink(S_YES, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'action');
                            } else {
                                $ack = new CLink(S_NO, 'acknow.php?eventid=' . $row_inf_event['eventid'], 'on');
                            }
                        }
                        $description = expand_trigger_description_by_data(array_merge($row_inf, array('clock' => $row_inf_event['clock'])), ZBX_FLAG_EVENT);
                        //actions
                        $actions = get_event_actions_status($row_inf_event['eventid']);
                        //--------
                    } else {
                        $description = expand_trigger_description_by_data($row_inf, ZBX_FLAG_EVENT);
                        $ack = '-';
                        $actions = S_NO_DATA_SMALL;
                        $row_inf_event['clock'] = $row_inf['clock'];
                    }
                    $table_inf->addRow(array(get_node_name_by_elid($row_inf['triggerid']), $host, new CCol($description, get_severity_style($row_inf['priority'])), zbx_date2age($row_inf_event['clock']), $config['event_ack_enable'] ? new CCol($ack, 'center') : NULL, $actions));
                    unset($row_inf, $description, $actions);
                }
                $value = new CSpan($tr_count, 'pointer');
                $value->setHint($table_inf);
                //-------------*/
            }
            $group_row->AddItem(new CCol($value, get_severity_style($key, $tr_count)));
            unset($table_inf);
        }
        $table->addRow($group_row);
    }
    $table->setFooter(new CCol(S_UPDATED . ': ' . date("H:i:s", time())));
    return $table;
}
コード例 #16
0
ファイル: CTree.php プロジェクト: omidmt/zabbix-greenplum
 private function makeSImgStr($id)
 {
     $tr = new CRow();
     $count = isset($this->tree[$id]['nodeimg']) ? strlen($this->tree[$id]['nodeimg']) : 0;
     for ($i = 0; $i < $count; $i++) {
         $td = new CCol();
         $img = null;
         switch ($this->tree[$id]['nodeimg'][$i]) {
             case 'O':
                 $img = new CImg('images/general/tree/zero.gif', 'o', '22', '14');
                 break;
             case 'I':
                 $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                 $img = new CImg('images/general/tree/zero.gif', 'i', '22', '14');
                 break;
             case 'L':
                 $td->setAttribute('valign', 'top');
                 $div = new CTag('div', 'yes');
                 $div->setAttribute('style', 'height: 10px; background-image: url(images/general/tree/pointc.gif);');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $img = new CImg('images/general/tree/plus.gif', 'y', '22', '14');
                     $img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '", this);');
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setAttribute('class', 'pointer');
                 } else {
                     $img = new CImg('images/general/tree/pointl.gif', 'y', '22', '14');
                 }
                 $div->addItem($img);
                 $img = $div;
                 break;
             case 'T':
                 $td->setAttribute('valign', 'top');
                 if ($this->tree[$id]['nodetype'] == 2) {
                     $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/plus.gif', 't', '22', '14');
                     $img->setAttribute('onclick', $this->treename . '.closeSNodeX("' . $id . '", this);');
                     $img->setAttribute('id', 'idi_' . $id);
                     $img->setAttribute('class', 'pointer');
                     $img->setAttribute('style', 'top: 1px; position: relative;');
                 } else {
                     $td->setAttribute('style', 'background-image: url(images/general/tree/pointc.gif);');
                     $img = new CImg('images/general/tree/pointl.gif', 't', '22', '14');
                 }
                 break;
         }
         $td->addItem($img);
         $tr->addItem($td);
     }
     return $tr;
 }
コード例 #17
0
$headerForm->addItem(array(SPACE, _('Type'), SPACE, $typeComboBox));
$overviewWidget->addHeader(_('Overview'), $headerForm);
$hintTable = new CTableInfo();
$hintTable->setAttribute('style', 'width: 200px');
if ($this->data['type'] == SHOW_TRIGGERS) {
    $hintTable->addRow(array(new CCol(SPACE, 'normal'), _('OK')));
}
for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
    $hintTable->addRow(array(getSeverityCell($i), _('PROBLEM')));
}
$config = select_config();
if ($this->data['type'] == SHOW_TRIGGERS) {
    // blinking preview in help popup (only if blinking is enabled)
    if ($config['blink_period'] > 0) {
        $row = new CRow(null);
        $row->addItem(new CCol(SPACE, 'normal'));
        for ($i = 0; $i < TRIGGER_SEVERITY_COUNT; $i++) {
            $row->addItem(new CCol(SPACE, getSeverityStyle($i)));
        }
        $col = new CTable('', 'blink overview-mon-severities');
        $col->addRow($row);
        // double div necassary for FireFox
        $col = new CCol(new CDiv(new CDiv($col), 'overview-mon-severities-container'));
        $hintTable->addRow(array($col, _s('Age less than %s', convertUnitsS($config['blink_period']))));
    }
    $hintTable->addRow(array(new CCol(SPACE), _('No trigger')));
} else {
    $hintTable->addRow(array(new CCol(SPACE), _('OK or no trigger')));
}
$help = new CHelp('web.view.php', 'right');
$help->setHint($hintTable, '', '', true, false);
コード例 #18
0
ファイル: blocks.inc.php プロジェクト: jbfavre/debian-zabbix
function make_system_status($filter, $backurl)
{
    $config = select_config();
    $table = new CTableInfo();
    // set trigger severities as table header starting from highest severity
    $header = [];
    for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
        $header[] = $filter['severity'] === null || isset($filter['severity'][$severity]) ? getSeverityName($severity, $config) : null;
    }
    krsort($header);
    array_unshift($header, _('Host group'));
    $table->setHeader($header);
    // get host groups
    $groups = API::HostGroup()->get(['groupids' => $filter['groupids'], 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored_hosts' => true, 'output' => ['groupid', 'name'], 'preservekeys' => true]);
    CArrayHelper::sort($groups, [['field' => 'name', 'order' => ZBX_SORT_UP]]);
    $groupIds = [];
    foreach ($groups as $group) {
        $groupIds[$group['groupid']] = $group['groupid'];
        $group['tab_priority'] = [TRIGGER_SEVERITY_DISASTER => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []], TRIGGER_SEVERITY_HIGH => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []], TRIGGER_SEVERITY_AVERAGE => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []], TRIGGER_SEVERITY_WARNING => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []], TRIGGER_SEVERITY_INFORMATION => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []], TRIGGER_SEVERITY_NOT_CLASSIFIED => ['count' => 0, 'triggers' => [], 'count_unack' => 0, 'triggers_unack' => []]];
        $groups[$group['groupid']] = $group;
    }
    // get triggers
    $triggers = API::Trigger()->get(['output' => ['triggerid', 'priority', 'state', 'description', 'error', 'value', 'lastchange', 'expression'], 'selectGroups' => ['groupid'], 'selectHosts' => ['name'], 'selectLastEvent' => ['eventid', 'acknowledged', 'objectid', 'clock', 'ns'], 'withLastEventUnacknowledged' => $filter['extAck'] == EXTACK_OPTION_UNACK ? true : null, 'skipDependent' => true, 'groupids' => $groupIds, 'hostids' => isset($filter['hostids']) ? $filter['hostids'] : null, 'monitored' => true, 'maintenance' => $filter['maintenance'], 'search' => $filter['trigger_name'] !== '' ? ['description' => $filter['trigger_name']] : null, 'filter' => ['priority' => $filter['severity'], 'value' => TRIGGER_VALUE_TRUE], 'sortfield' => 'lastchange', 'sortorder' => ZBX_SORT_DOWN, 'preservekeys' => true]);
    $eventIds = [];
    foreach ($triggers as $triggerId => $trigger) {
        if ($trigger['lastEvent']) {
            $eventIds[$trigger['lastEvent']['eventid']] = $trigger['lastEvent']['eventid'];
        }
        $triggers[$triggerId]['event'] = $trigger['lastEvent'];
        unset($triggers[$triggerId]['lastEvent']);
    }
    // get acknowledges
    if ($eventIds) {
        $eventAcknowledges = API::Event()->get(['output' => ['eventid'], 'eventids' => $eventIds, 'select_acknowledges' => ['eventid', 'clock', 'message', 'alias', 'name', 'surname'], 'preservekeys' => true]);
    }
    // actions
    $actions = makeEventsActions($eventIds);
    // triggers
    foreach ($triggers as $trigger) {
        // event
        if ($trigger['event']) {
            $trigger['event']['acknowledges'] = isset($eventAcknowledges[$trigger['event']['eventid']]) ? $eventAcknowledges[$trigger['event']['eventid']]['acknowledges'] : 0;
        } else {
            $trigger['event'] = ['acknowledged' => false, 'clock' => $trigger['lastchange'], 'ns' => '999999999', 'value' => $trigger['value']];
        }
        // groups
        foreach ($trigger['groups'] as $group) {
            if (!isset($groups[$group['groupid']])) {
                continue;
            }
            if (in_array($filter['extAck'], [EXTACK_OPTION_ALL, EXTACK_OPTION_BOTH])) {
                if ($groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count'] < ZBX_WIDGET_ROWS) {
                    $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['triggers'][] = $trigger;
                }
                $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count']++;
            }
            if (in_array($filter['extAck'], [EXTACK_OPTION_UNACK, EXTACK_OPTION_BOTH]) && isset($trigger['event']) && !$trigger['event']['acknowledged']) {
                if ($groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count_unack'] < ZBX_WIDGET_ROWS) {
                    $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['triggers_unack'][] = $trigger;
                }
                $groups[$group['groupid']]['tab_priority'][$trigger['priority']]['count_unack']++;
            }
        }
    }
    unset($triggers);
    foreach ($groups as $group) {
        $groupRow = new CRow();
        $name = new CLink($group['name'], 'tr_status.php?filter_set=1&groupid=' . $group['groupid'] . '&hostid=0' . '&show_triggers=' . TRIGGERS_OPTION_RECENT_PROBLEM);
        $groupRow->addItem($name);
        foreach ($group['tab_priority'] as $severity => $data) {
            if (!is_null($filter['severity']) && !isset($filter['severity'][$severity])) {
                continue;
            }
            $allTriggersNum = $data['count'];
            if ($allTriggersNum) {
                $allTriggersNum = (new CSpan($allTriggersNum))->addClass(ZBX_STYLE_LINK_ACTION)->setHint(makeTriggersPopup($data['triggers'], $backurl, $actions, $config));
            }
            $unackTriggersNum = $data['count_unack'];
            if ($unackTriggersNum) {
                $unackTriggersNum = (new CSpan($unackTriggersNum))->addClass(ZBX_STYLE_LINK_ACTION)->setHint(makeTriggersPopup($data['triggers_unack'], $backurl, $actions, $config));
            }
            switch ($filter['extAck']) {
                case EXTACK_OPTION_ALL:
                    $groupRow->addItem(getSeverityCell($severity, $config, $allTriggersNum, $data['count'] == 0));
                    break;
                case EXTACK_OPTION_UNACK:
                    $groupRow->addItem(getSeverityCell($severity, $config, $unackTriggersNum, $data['count_unack'] == 0));
                    break;
                case EXTACK_OPTION_BOTH:
                    if ($data['count_unack'] != 0) {
                        $groupRow->addItem(getSeverityCell($severity, $config, [$unackTriggersNum, ' ' . _('of') . ' ', $allTriggersNum]));
                    } else {
                        $groupRow->addItem(getSeverityCell($severity, $config, $allTriggersNum, $data['count'] == 0));
                    }
                    break;
            }
        }
        $table->addRow($groupRow);
    }
    return $table;
}
コード例 #19
0
ファイル: page_header.php プロジェクト: phedders/zabbix
    		$search_div->setAttribute('id','zbx_search');
    		$search_div->setAttribute('class','zbx_search');
    
    		$page_menu->addItem($search_div);
    //*/
    $page_menu->show();
}
//------------------------------------- <HISTORY> ---------------------------------------
if (isset($page['hist_arg']) && $USER_DETAILS['alias'] != ZBX_GUEST_USER && $page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
    $table = new CTable();
    $table->setClass('history');
    $table->setCellSpacing(0);
    $table->setCellPadding(0);
    $history = get_user_history();
    $tr = new CRow(new CCol('History:', 'caption'));
    $tr->addItem($history);
    $table->addRow($tr);
    $table->Show();
} else {
    if ($page['type'] == PAGE_TYPE_HTML && !defined('ZBX_PAGE_NO_MENU')) {
        echo SBR;
    }
}
//------------------------------------ </HISTORY> ---------------------------------------
unset($ZBX_MENU);
unset($table, $top_page_row, $menu_table, $node_form);
unset($main_menu_row);
unset($db_nodes, $node_data);
unset($sub_menu_table, $sub_menu_rows);
if ($denyed_page_requested) {
    access_deny();
コード例 #20
0
ファイル: config.php プロジェクト: songyuanjie/zabbix-stats
            $name = new CLink($image['name'], 'config.php?form=update' . url_param('config') . '&imageid=' . $image['imageid']);
            $action = new CLink($img, 'image.php?imageid=' . $image['imageid']);
            $img_td = new CCol();
            $img_td->setAttribute('align', 'center');
            $img_td->addItem(array($action, BR(), $name), 'center');
            $row->addItem($img_td);
            $tr++;
            if ($tr % 4 == 0) {
                $table->addRow($row);
                $row = new CRow();
            }
        }
        if ($tr > 0) {
            while ($tr % 4 != 0) {
                $tr++;
                $row->addItem(SPACE);
            }
            $table->addRow($row);
        }
        $cnf_wdgt->addItem($table);
    }
} else {
    if ($_REQUEST['config'] == 5) {
        // Other parameters
        $frmOther = new CFormTable(S_OTHER_PARAMETERS, 'config.php');
        $frmOther->setHelp('web.config.other.php');
        $frmOther->addVar('config', get_request('config', 5));
        $frmOther->addRow(S_REFRESH_UNSUPPORTED_ITEMS, new CNumericBox('refresh_unsupported', $config['refresh_unsupported'], 5));
        $cmbGrp = new CComboBox('discovery_groupid', $config['discovery_groupid']);
        $groups = CHostGroup::get(array('sortfield' => 'name', 'editable' => 1, 'extendoutput' => 1));
        foreach ($groups as $gnum => $group) {