1<?php 2/* 3** Zabbix 4** Copyright (C) 2001-2021 Zabbix SIA 5** 6** This program is free software; you can redistribute it and/or modify 7** it under the terms of the GNU General Public License as published by 8** the Free Software Foundation; either version 2 of the License, or 9** (at your option) any later version. 10** 11** This program is distributed in the hope that it will be useful, 12** but WITHOUT ANY WARRANTY; without even the implied warranty of 13** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14** GNU General Public License for more details. 15** 16** You should have received a copy of the GNU General Public License 17** along with this program; if not, write to the Free Software 18** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 19**/ 20 21 22/** 23 * @var CView $this 24 */ 25 26$filterForm = new CFilter(new CUrl('toptriggers.php')); 27 28$severities = []; 29foreach (range(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_COUNT - 1) as $severity) { 30 $severities[] = [ 31 'name' => getSeverityName($severity), 32 'value' => $severity 33 ]; 34} 35 36$filter_column = (new CFormList()) 37 ->addRow(new CLabel(_('Host groups'), 'groupids__ms'), 38 (new CMultiSelect([ 39 'name' => 'groupids[]', 40 'object_name' => 'hostGroup', 41 'data' => $data['multiSelectHostGroupData'], 42 'popup' => [ 43 'parameters' => [ 44 'srctbl' => 'host_groups', 45 'srcfld1' => 'groupid', 46 'dstfrm' => $filterForm->getName(), 47 'dstfld1' => 'groupids_', 48 'real_hosts' => true, 49 'enrich_parent_groups' => true 50 ] 51 ] 52 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 53 ) 54 ->addRow(new CLabel(_('Hosts'), 'hostids__ms'), 55 (new CMultiSelect([ 56 'name' => 'hostids[]', 57 'object_name' => 'hosts', 58 'data' => $data['multiSelectHostData'], 59 'popup' => [ 60 'filter_preselect_fields' => [ 61 'hostgroups' => 'groupids_' 62 ], 63 'parameters' => [ 64 'srctbl' => 'hosts', 65 'srcfld1' => 'hostid', 66 'dstfrm' => $filterForm->getName(), 67 'dstfld1' => 'hostids_' 68 ] 69 ] 70 ]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH) 71 ) 72 ->addRow(new CLabel(_('Severity')), 73 (new CSeverityCheckBoxList('severities'))->setChecked($data['filter']['severities']) 74 ); 75 76$filterForm 77 ->setProfile($data['filter']['timeline']['profileIdx']) 78 ->setActiveTab($data['filter']['active_tab']) 79 ->addTimeSelector($data['filter']['timeline']['from'], $data['filter']['timeline']['to'], true, ZBX_DATE_TIME) 80 ->addFilterTab(_('Filter'), [$filter_column]); 81 82// table 83$table = (new CTableInfo())->setHeader([_('Host'), _('Trigger'), _('Severity'), _('Number of status changes')]); 84 85foreach ($data['triggers'] as $trigger) { 86 $hostId = $trigger['hosts'][0]['hostid']; 87 88 $hostName = (new CLinkAction($trigger['hosts'][0]['name']))->setMenuPopup(CMenuPopupHelper::getHost($hostId)); 89 if ($data['hosts'][$hostId]['status'] == HOST_STATUS_NOT_MONITORED) { 90 $hostName->addClass(ZBX_STYLE_RED); 91 } 92 93 $triggerDescription = (new CLinkAction($trigger['description'])) 94 ->setMenuPopup(CMenuPopupHelper::getTrigger($trigger['triggerid'], 0)); 95 96 $table->addRow([ 97 $hostName, 98 $triggerDescription, 99 getSeverityCell($trigger['priority']), 100 $trigger['cnt_event'] 101 ]); 102} 103 104$obj_data = [ 105 'id' => 'timeline_1', 106 'domid' => 'toptriggers', 107 'loadSBox' => 0, 108 'loadImage' => 0, 109 'dynamic' => 0 110]; 111zbx_add_post_js('timeControl.addObject("toptriggers", '.zbx_jsvalue($data['filter']).', '.zbx_jsvalue($obj_data).');'); 112zbx_add_post_js('timeControl.processObjects();'); 113 114(new CWidget()) 115 ->setTitle(_('100 busiest triggers')) 116 ->addItem($filterForm) 117 ->addItem($table) 118 ->show(); 119