/usr/share/zabbix/queue.php is in zabbix-frontend-php 1:2.4.7+dfsg-2ubuntu2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 | <?php
/*
** Zabbix
** Copyright (C) 2001-2015 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__).'/include/config.inc.php';
require_once dirname(__FILE__).'/include/items.inc.php';
$page['title'] = _('Queue');
$page['file'] = 'queue.php';
$page['hist_arg'] = array('config');
define('ZBX_PAGE_DO_REFRESH', 1);
require_once dirname(__FILE__).'/include/page_header.php';
$queueModes = array(
QUEUE_OVERVIEW,
QUEUE_OVERVIEW_BY_PROXY,
QUEUE_DETAILS
);
// VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION
$fields = array(
'config' => array(T_ZBX_INT, O_OPT, P_SYS, IN($queueModes), null)
);
check_fields($fields);
$config = getRequest('config', CProfile::get('web.queue.config', 0));
CProfile::update('web.queue.config', $config, PROFILE_TYPE_INT);
// fetch data
$zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SOCKET_TIMEOUT, ZBX_SOCKET_BYTES_LIMIT);
$queueRequests = array(
QUEUE_OVERVIEW => CZabbixServer::QUEUE_OVERVIEW,
QUEUE_OVERVIEW_BY_PROXY => CZabbixServer::QUEUE_OVERVIEW_BY_PROXY,
QUEUE_DETAILS => CZabbixServer::QUEUE_DETAILS
);
$queueData = $zabbixServer->getQueue($queueRequests[$config], get_cookie('zbx_sessionid'));
// check for errors error
if ($zabbixServer->getError()) {
error($zabbixServer->getError());
show_error_message(_('Cannot display item queue.'));
require_once dirname(__FILE__).'/include/page_footer.php';
}
// create filter form
$form = new CForm('get');
$cmbMode = new CComboBox('config', $config, 'submit();');
$cmbMode->addItem(QUEUE_OVERVIEW, _('Overview'));
$cmbMode->addItem(QUEUE_OVERVIEW_BY_PROXY, _('Overview by proxy'));
$cmbMode->addItem(QUEUE_DETAILS, _('Details'));
$form->addItem($cmbMode);
// display table
$queueWidget = new CWidget();
$queueWidget->addPageHeader(_('QUEUE OF ITEMS TO BE UPDATED'), $form);
$table = new CTableInfo(_('The queue is empty.'));
// overview
if ($config == QUEUE_OVERVIEW) {
$itemTypes = array(
ITEM_TYPE_ZABBIX,
ITEM_TYPE_ZABBIX_ACTIVE,
ITEM_TYPE_SIMPLE,
ITEM_TYPE_SNMPV1,
ITEM_TYPE_SNMPV2C,
ITEM_TYPE_SNMPV3,
ITEM_TYPE_INTERNAL,
ITEM_TYPE_AGGREGATE,
ITEM_TYPE_EXTERNAL,
ITEM_TYPE_DB_MONITOR,
ITEM_TYPE_IPMI,
ITEM_TYPE_SSH,
ITEM_TYPE_TELNET,
ITEM_TYPE_JMX,
ITEM_TYPE_CALCULATED
);
$table->setHeader(array(
_('Items'),
_('5 seconds'),
_('10 seconds'),
_('30 seconds'),
_('1 minute'),
_('5 minutes'),
_('More than 10 minutes')
));
$queueData = zbx_toHash($queueData, 'itemtype');
foreach($itemTypes as $type) {
if (isset($queueData[$type])) {
$itemTypeData = $queueData[$type];
}
else {
$itemTypeData = array(
'delay5' => 0,
'delay10' => 0,
'delay30' => 0,
'delay60' => 0,
'delay300' => 0,
'delay600' => 0
);
}
$table->addRow(array(
item_type2str($type),
getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $itemTypeData['delay5'], !$itemTypeData['delay5']),
getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $itemTypeData['delay10'], !$itemTypeData['delay10']),
getSeverityCell(TRIGGER_SEVERITY_WARNING, $itemTypeData['delay30'], !$itemTypeData['delay30']),
getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $itemTypeData['delay60'], !$itemTypeData['delay60']),
getSeverityCell(TRIGGER_SEVERITY_HIGH, $itemTypeData['delay300'], !$itemTypeData['delay300']),
getSeverityCell(TRIGGER_SEVERITY_DISASTER, $itemTypeData['delay600'], !$itemTypeData['delay600'])
));
}
}
// overview by proxy
elseif ($config == QUEUE_OVERVIEW_BY_PROXY) {
$proxies = API::proxy()->get(array(
'output' => array('hostid', 'host'),
'preservekeys' => true
));
order_result($proxies, 'host');
$proxies[0] = array('host' => _('Server'));
$table->setHeader(array(
_('Proxy'),
_('5 seconds'),
_('10 seconds'),
_('30 seconds'),
_('1 minute'),
_('5 minutes'),
_('More than 10 minutes')
));
$queueData = zbx_toHash($queueData, 'proxyid');
foreach ($proxies as $proxyId => $proxy) {
if (isset($queueData[$proxyId])) {
$proxyData = $queueData[$proxyId];
}
else {
$proxyData = array(
'delay5' => 0,
'delay10' => 0,
'delay30' => 0,
'delay60' => 0,
'delay300' => 0,
'delay600' => 0
);
}
$table->addRow(array(
$proxy['host'],
getSeverityCell(TRIGGER_SEVERITY_NOT_CLASSIFIED, $proxyData['delay5'], !$proxyData['delay5']),
getSeverityCell(TRIGGER_SEVERITY_INFORMATION, $proxyData['delay10'], !$proxyData['delay10']),
getSeverityCell(TRIGGER_SEVERITY_WARNING, $proxyData['delay30'], !$proxyData['delay30']),
getSeverityCell(TRIGGER_SEVERITY_AVERAGE, $proxyData['delay60'], !$proxyData['delay60']),
getSeverityCell(TRIGGER_SEVERITY_HIGH, $proxyData['delay300'], !$proxyData['delay300']),
getSeverityCell(TRIGGER_SEVERITY_DISASTER, $proxyData['delay600'], !$proxyData['delay600'])
));
}
}
// details
elseif ($config == QUEUE_DETAILS) {
$queueData = zbx_toHash($queueData, 'itemid');
$items = API::Item()->get(array(
'output' => array('itemid', 'hostid', 'name', 'key_'),
'selectHosts' => array('name'),
'itemids' => array_keys($queueData),
'webitems' => true,
'preservekeys' => true
));
$items = CMacrosResolverHelper::resolveItemNames($items);
// get hosts for queue items
$hostIds = zbx_objectValues($items, 'hostid');
$hostIds = array_keys(array_flip($hostIds));
$hosts = API::Host()->get(array(
'output' => array('hostid', 'proxy_hostid'),
'hostids' => $hostIds,
'preservekeys' => true
));
// get proxies for those hosts
$proxyHostIds = array();
foreach ($hosts as $host) {
if ($host['proxy_hostid']) {
$proxyHostIds[$host['proxy_hostid']] = $host['proxy_hostid'];
}
}
if ($proxyHostIds) {
$proxies = API::Proxy()->get(array(
'proxyids' => $proxyHostIds,
'output' => array('proxyid', 'host'),
'preservekeys' => true
));
}
$table->setHeader(array(
_('Scheduled check'),
_('Delayed by'),
_('Host'),
_('Name')
));
$i = 0;
foreach ($queueData as $itemData) {
if (!isset($items[$itemData['itemid']])) {
continue;
}
// display only the first 500 items
$i++;
if ($i > QUEUE_DETAIL_ITEM_COUNT) {
break;
}
$item = $items[$itemData['itemid']];
$host = reset($item['hosts']);
$table->addRow(array(
zbx_date2str(DATE_TIME_FORMAT_SECONDS, $itemData['nextcheck']),
zbx_date2age($itemData['nextcheck']),
(isset($proxies[$hosts[$item['hostid']]['proxy_hostid']]))
? $proxies[$hosts[$item['hostid']]['proxy_hostid']]['host'].NAME_DELIMITER.$host['name']
: $host['name'],
$item['name_expanded']
));
}
}
$queueWidget->addItem($table);
$queueWidget->show();
// display the table footer
if ($config == QUEUE_OVERVIEW_BY_PROXY) {
show_table_header(_('Total').': '.$table->getNumRows());
}
elseif ($config == QUEUE_DETAILS) {
show_table_header(
_('Total').': '.$table->getNumRows().
((count($queueData) > QUEUE_DETAIL_ITEM_COUNT) ? ' ('._('Truncated').')' : '')
);
}
require_once dirname(__FILE__).'/include/page_footer.php';
|