Welcome to mirror list, hosted at ThFree Co, Russian Federation.

reports.toptriggers.php « views « include « php « frontends - github.com/zabbix/zabbix.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 45f3f8e662820080f6c80185e3165d5c838ebd11 (plain)
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
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
<?php
/*
** Zabbix
** Copyright (C) 2001-2017 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.
**/


require_once dirname(__FILE__).'/js/reports.toptriggers.js.php';

$filterForm = (new CFilter('web.toptriggers.filter.state'))
	->addVar('filter_from', date(TIMESTAMP_FORMAT, $this->data['filter']['filter_from']))
	->addVar('filter_till', date(TIMESTAMP_FORMAT, $this->data['filter']['filter_till']));

// severities
$severity_columns = [0 => [], 1 => []];

foreach (range(TRIGGER_SEVERITY_NOT_CLASSIFIED, TRIGGER_SEVERITY_COUNT - 1) as $severity) {
	$severity_columns[$severity % 2][] = (new CCheckBox('severities['.$severity.']'))
		->setLabel(getSeverityName($severity, $this->data['config']))
		->setChecked(in_array($severity, $this->data['filter']['severities']));
}

$filterColumn1 = (new CFormList())
	->addRow(_('Host groups'),
		(new CMultiSelect([
			'name' => 'groupids[]',
			'objectName' => 'hostGroup',
			'data' => $this->data['multiSelectHostGroupData'],
			'popup' => [
				'parameters' => [
					'srctbl' => 'host_groups',
					'dstfrm' => $filterForm->getName(),
					'dstfld1' => 'groupids_',
					'srcfld1' => 'groupid',
					'multiselect' => '1'
				]
			]
		]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)
	)
	->addRow(_('Hosts'),
		(new CMultiSelect([
			'name' => 'hostids[]',
			'objectName' => 'hosts',
			'data' => $this->data['multiSelectHostData'],
			'popup' => [
				'parameters' => [
					'srctbl' => 'hosts',
					'dstfrm' => $filterForm->getName(),
					'dstfld1' => 'hostids_',
					'srcfld1' => 'hostid',
					'real_hosts' => '1',
					'multiselect' => '1'
				]
			]
		]))->setWidth(ZBX_TEXTAREA_FILTER_STANDARD_WIDTH)
	)
	->addRow(_('Severity'),
		(new CTable())
			->addRow($severity_columns[0])
			->addRow($severity_columns[1])
	);

$filterColumn2 = (new CFormList())
	->addRow(_('From'), createDateSelector('filter_from', $this->data['filter']['filter_from']))
	->addRow(_('Till'), createDateSelector('filter_till', $this->data['filter']['filter_till']))
	->addRow(null, [
		new CHorList([
			(new CButton(null, _('Today')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_TODAY.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Yesterday')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_YESTERDAY.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Current week')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_CURRENT_WEEK.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Current month')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_CURRENT_MONTH.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Current year')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_CURRENT_YEAR.');')
				->addClass(ZBX_STYLE_BTN_LINK)
		]),
		new CHorList([
			(new CButton(null, _('Last week')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_LAST_WEEK.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Last month')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_LAST_MONTH.');')
				->addClass(ZBX_STYLE_BTN_LINK),
			(new CButton(null, _('Last year')))
				->onClick('javascript: setPeriod('.REPORT_PERIOD_LAST_YEAR.');')
				->addClass(ZBX_STYLE_BTN_LINK)
		])
	]);

$filterForm
	->addColumn($filterColumn1)
	->addColumn($filterColumn2);

// table
$table = (new CTableInfo())->setHeader([_('Host'), _('Trigger'), _('Severity'), _('Number of status changes')]);

foreach ($this->data['triggers'] as $trigger) {
	$hostId = $trigger['hosts'][0]['hostid'];

	$hostName = (new CSpan($trigger['hosts'][0]['name']))
		->setMenuPopup(CMenuPopupHelper::getHost($this->data['hosts'][$hostId], $this->data['scripts'][$hostId]))
		->addClass(ZBX_STYLE_LINK_ACTION);
	if ($this->data['hosts'][$hostId]['status'] == HOST_STATUS_NOT_MONITORED) {
		$hostName->addClass(ZBX_STYLE_RED);
	}

	$triggerDescription = (new CSpan($trigger['description']))
		->setMenuPopup(CMenuPopupHelper::getTrigger($trigger))
		->addClass(ZBX_STYLE_LINK_ACTION);

	$table->addRow([
		$hostName,
		$triggerDescription,
		getSeverityCell($trigger['priority'], $this->data['config']),
		$trigger['cnt_event']
	]);
}

return (new CWidget())
	->setTitle(_('100 busiest triggers'))
	->addItem($filterForm)
	->addItem($table);