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