/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { // fetch hosts $hosts = API::Host()->get(['output' => ['hostid', 'status'], 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true]); $hostids = array_keys($hosts); $options = ['output' => ['triggerid', 'expression', 'description', 'url', 'value', 'priority', 'lastchange', 'flags'], 'selectHosts' => ['hostid', 'name', 'status'], 'selectItems' => ['itemid', 'hostid', 'name', 'key_', 'value_type'], 'hostids' => $hostids, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description', 'preservekeys' => true]; // application filter if ($this->screenitem['application'] !== '') { $applications = API::Application()->get(['output' => [], 'hostids' => $hostids, 'search' => ['name' => $this->screenitem['application']], 'preservekeys' => true]); $options['applicationids'] = array_keys($applications); } $triggers = API::Trigger()->get($options); $triggers = CMacrosResolverHelper::resolveTriggerUrls($triggers); /* * Each screen cell with "Triggers overview" depends on one specific group which in this case is 'resourceid'. * Pass it as 'groupid' to menu pop-up "Events" link. */ foreach ($triggers as &$trigger) { $trigger['groupid'] = $this->screenitem['resourceid']; } unset($trigger); $groups = API::HostGroup()->get(['output' => ['name'], 'groupids' => [$this->screenitem['resourceid']]]); $header = (new CDiv([new CTag('h4', true, _('Triggers overview')), (new CList())->addItem([_('Group'), ':', SPACE, $groups[0]['name']])]))->addClass(ZBX_STYLE_DASHBRD_WIDGET_HEAD); $table = getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid); $footer = (new CList())->addItem(_s('Updated: %s', zbx_date2str(TIME_FORMAT_SECONDS)))->addClass(ZBX_STYLE_DASHBRD_WIDGET_FOOT); return $this->getOutput(new CUiWidget(uniqid(), [$header, $table, $footer])); }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { $hostids = array(); $dbHostGroups = DBselect('SELECT DISTINCT hg.hostid' . ' FROM hosts_groups hg' . ' WHERE hg.groupid=' . zbx_dbstr($this->screenitem['resourceid'])); while ($dbHostGroup = DBfetch($dbHostGroups)) { $hostids[$dbHostGroup['hostid']] = $dbHostGroup['hostid']; } return $this->getOutput(getTriggersOverview($hostids, $this->screenitem['application'], $this->pageFile, $this->screenitem['style'], $this->screenid)); }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { // fetch hosts $hosts = API::Host()->get(array('output' => array('hostid', 'status'), 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true)); $hostIds = array_keys($hosts); $options = array('output' => array('description', 'expression', 'priority', 'url', 'value', 'triggerid', 'lastchange', 'flags'), 'selectHosts' => array('hostid', 'name', 'status'), 'hostids' => $hostIds, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description'); // application filter if ($this->screenitem['application'] !== '') { $applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostIds, 'search' => array('name' => $this->screenitem['application']))); $options['applicationids'] = zbx_objectValues($applications, 'applicationid'); } $triggers = API::Trigger()->get($options); return $this->getOutput(getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid)); }
/** * Process screen. * * @return CDiv (screen inside container) */ public function get() { // fetch hosts $hosts = API::Host()->get(array('output' => array('hostid', 'status'), 'selectGraphs' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'selectScreens' => $this->screenitem['style'] == STYLE_LEFT ? API_OUTPUT_COUNT : null, 'groupids' => $this->screenitem['resourceid'], 'preservekeys' => true)); $hostIds = array_keys($hosts); $options = array('output' => array('description', 'expression', 'priority', 'url', 'value', 'triggerid', 'lastchange', 'flags'), 'selectHosts' => array('hostid', 'name', 'status'), 'selectItems' => array('itemid', 'hostid', 'name', 'key_', 'value_type'), 'hostids' => $hostIds, 'monitored' => true, 'skipDependent' => true, 'sortfield' => 'description'); // application filter if ($this->screenitem['application'] !== '') { $applications = API::Application()->get(array('output' => array('applicationid'), 'hostids' => $hostIds, 'search' => array('name' => $this->screenitem['application']))); $options['applicationids'] = zbx_objectValues($applications, 'applicationid'); } $triggers = API::Trigger()->get($options); /* * Each screen cell with "Triggers overview" depends on one specific group which in this case is 'resourceid'. * Pass it as 'groupid' to menu pop-up "Events" link. */ foreach ($triggers as &$trigger) { $trigger['groupid'] = $this->screenitem['resourceid']; } unset($trigger); return $this->getOutput(getTriggersOverview($hosts, $triggers, $this->pageFile, $this->screenitem['style'], $this->screenid)); }
$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); // header right $overviewWidget->addPageHeader(_('OVERVIEW'), array(get_icon('fullscreen', array('fullscreen' => $this->data['fullscreen'])), SPACE, $help)); // header left $styleComboBox = new CComboBox('view_style', $this->data['view_style'], 'submit()'); $styleComboBox->addItem(STYLE_TOP, _('Top')); $styleComboBox->addItem(STYLE_LEFT, _('Left')); $hostLocationForm = new CForm('get'); $hostLocationForm->addVar('groupid', $this->data['groupid']); $hostLocationForm->additem(array(_('Hosts location'), SPACE, $styleComboBox)); $overviewWidget->addHeader($hostLocationForm); if ($config['dropdown_first_entry'] || $this->data['pageFilter']->applicationsSelected || $this->data['pageFilter']->groupsSelected) { if ($this->data['type'] == SHOW_DATA) { $dataTable = getItemsDataOverview(array_keys($this->data['pageFilter']->hosts), $this->data['pageFilter']->application, $this->data['view_style']); } elseif ($this->data['type'] == SHOW_TRIGGERS) { global $page; $dataTable = getTriggersOverview(array_keys($this->data['pageFilter']->hosts), $this->data['pageFilter']->application, $page['file'], $this->data['view_style']); } } else { $dataTable = new CTableInfo(_('No items found.')); } $overviewWidget->addItem($dataTable); return $overviewWidget;
$help_hint = (new CList())->addClass(ZBX_STYLE_NOTIF_BODY)->addStyle('min-width: ' . ZBX_OVERVIEW_HELP_MIN_WIDTH . 'px')->addItem([(new CDiv())->addClass(ZBX_STYLE_NOTIF_INDIC)->addClass(getSeverityStyle(null, false)), new CTag('h4', true, _('OK')), (new CTag('p', true, ''))->addClass(ZBX_STYLE_GREY)]); for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) { $help_hint->addItem([(new CDiv())->addClass(ZBX_STYLE_NOTIF_INDIC)->addClass(getSeverityStyle($severity)), new CTag('h4', true, getSeverityName($severity, $data['config'])), (new CTag('p', true, _('PROBLEM')))->addClass(ZBX_STYLE_GREY)]); } // blinking preview in help popup (only if blinking is enabled) if ($data['config']['blink_period'] > 0) { $indic_container = (new CDiv())->addClass(ZBX_STYLE_NOTIF_INDIC_CONTAINER)->addItem((new CDiv())->addClass(ZBX_STYLE_NOTIF_INDIC)->addClass(getSeverityStyle(null, false))->addClass('blink')); for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) { $indic_container->addItem((new CDiv())->addClass(ZBX_STYLE_NOTIF_INDIC)->addClass(getSeverityStyle($severity))->addClass('blink')); } $indic_container->addItem((new CTag('p', true, _s('Age less than %s', convertUnitsS($data['config']['blink_period']))))->addClass(ZBX_STYLE_GREY)); $help_hint->addItem($indic_container); } // header right $help = get_icon('overviewhelp'); $help->setHint($help_hint); $widget = (new CWidget())->setTitle(_('Overview'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem([_('Group'), SPACE, $this->data['pageFilter']->getGroupsCB()])->addItem([_('Type'), SPACE, new CComboBox('type', $this->data['type'], 'submit()', [SHOW_TRIGGERS => _('Triggers'), SHOW_DATA => _('Data')])])->addItem([_('Hosts location'), SPACE, new CComboBox('view_style', $this->data['view_style'], 'submit()', [STYLE_TOP => _('Top'), STYLE_LEFT => _('Left')])])->addItem(get_icon('fullscreen', ['fullscreen' => $this->data['fullscreen']]))->addItem($help))); // filter $filter = $this->data['filter']; $filterFormView = new CView('common.filter.trigger', ['overview' => true, 'filter' => ['filterid' => 'web.overview.filter.state', 'showTriggers' => $filter['showTriggers'], 'ackStatus' => $filter['ackStatus'], 'showSeverity' => $filter['showSeverity'], 'statusChange' => $filter['statusChange'], 'statusChangeDays' => $filter['statusChangeDays'], 'txtSelect' => $filter['txtSelect'], 'application' => $filter['application'], 'inventory' => $filter['inventory'], 'showMaintenance' => $filter['showMaintenance'], 'hostId' => $this->data['hostid'], 'groupId' => $this->data['groupid'], 'fullScreen' => $this->data['fullscreen']], 'config' => $data['config']]); $filterForm = $filterFormView->render(); $widget->addItem($filterForm); // data table if ($data['pageFilter']->groupsSelected) { global $page; $dataTable = getTriggersOverview($this->data['hosts'], $this->data['triggers'], $page['file'], $this->data['view_style']); } else { $dataTable = new CTableInfo(); } $widget->addItem($dataTable); return $widget;