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 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162
|
<?php
/*
** Zabbix
** Copyright (C) 2001-2016 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';
$topTriggers = (new CWidget())->setTitle(_('100 busiest triggers'));
$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']));
$filterColumn1 = new CFormList();
$filterColumn2 = new CFormList();
$filterColumn2->addRow(_('From'), createDateSelector('filter_from', $this->data['filter']['filter_from']));
$filterColumn2->addRow(_('Till'), createDateSelector('filter_till', $this->data['filter']['filter_till']));
$filterColumn2->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)
])
]);
$filterColumn1->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)
);
$filterColumn1->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)
);
// severities
$severity_columns = [0 => [], 1 => []];
for ($severity = TRIGGER_SEVERITY_NOT_CLASSIFIED; $severity < TRIGGER_SEVERITY_COUNT; $severity++) {
$severity_columns[$severity % 2][] = new CLabel([
(new CCheckBox('severities['.$severity.']'))
->setChecked(in_array($severity, $this->data['filter']['severities'])),
getSeverityName($severity, $this->data['config'])
], 'severities['.$severity.']');
}
$filterColumn1->addRow(_('Severity'),
(new CTable())
->addRow($severity_columns[0])
->addRow($severity_columns[1])
);
$filterForm
->addColumn($filterColumn1)
->addColumn($filterColumn2);
$topTriggers->addItem($filterForm);
// table
$table = (new CTableInfo())
->setHeader([
_('Host'),
_('Trigger'),
_('Severity'),
_('Number of status changes')
]);
foreach ($this->data['triggers'] as $trigger) {
foreach ($trigger['hosts'] as $host) {
if ($host['status'] == HOST_STATUS_MONITORED) {
// Pass a monitored 'hostid' and corresponding first 'groupid' to menu pop-up "Events" link.
$trigger['hostid'] = $host['hostid'];
$trigger['groupid'] = $data['monitored_hosts'][$trigger['hostid']]['groups'][0]['groupid'];
break;
}
else {
// Unmonitored will have disabled "Events" link and there is no 'groupid' or 'hostid'.
$trigger['hostid'] = 0;
$trigger['groupid'] = 0;
}
}
$hostId = $trigger['hosts'][0]['hostid'];
$hostName = (new CSpan($trigger['hosts'][0]['name']))
->addClass(ZBX_STYLE_LINK_ACTION);
if ($this->data['hosts'][$hostId]['status'] == HOST_STATUS_NOT_MONITORED) {
$hostName->addClass(ZBX_STYLE_RED);
}
$hostName->setMenuPopup(CMenuPopupHelper::getHost($this->data['hosts'][$hostId], $this->data['scripts'][$hostId]));
$triggerDescription = (new CSpan($trigger['description']))
->addClass(ZBX_STYLE_LINK_ACTION)
->setMenuPopup(CMenuPopupHelper::getTrigger($trigger));
$table->addRow([
$hostName,
$triggerDescription,
getSeverityCell($trigger['priority'], $this->data['config']),
$trigger['cnt_event']
]);
}
$topTriggers->addItem($table);
return $topTriggers;
|