/** * Execute script. * * @param string $data['scriptid'] * @param string $data['hostid'] * * @return array */ public function execute(array $data) { global $ZBX_SERVER, $ZBX_SERVER_PORT; $scriptId = $data['scriptid']; $hostId = $data['hostid']; $scripts = $this->get(array('hostids' => $hostId, 'scriptids' => $scriptId, 'output' => array('scriptid'), 'preservekeys' => true)); if (!isset($scripts[$scriptId])) { self::exception(ZBX_API_ERROR_PERMISSIONS, _('You do not have permission to perform this operation.')); } // execute script $zabbixServer = new CZabbixServer($ZBX_SERVER, $ZBX_SERVER_PORT, ZBX_SCRIPT_TIMEOUT, ZBX_SOCKET_BYTES_LIMIT); $result = $zabbixServer->executeScript($scriptId, $hostId); if ($result !== false) { // return the result in a backwards-compatible format return array('response' => 'success', 'value' => $result); } else { self::exception(ZBX_API_ERROR_INTERNAL, $zabbixServer->getError()); } }
$page['title'] = _('Queue'); $page['file'] = 'queue.php'; define('ZBX_PAGE_DO_REFRESH', 1); require_once dirname(__FILE__) . '/include/page_header.php'; $queueModes = [QUEUE_OVERVIEW, QUEUE_OVERVIEW_BY_PROXY, QUEUE_DETAILS]; // VAR TYPE OPTIONAL FLAGS VALIDATION EXCEPTION $fields = ['config' => [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 = [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'; } $widget = (new CWidget())->setTitle(_('Queue of items to be updated'))->setControls((new CForm('get'))->cleanItems()->addItem((new CList())->addItem((new CComboBox('config', $config, 'submit();'))->addItem(QUEUE_OVERVIEW, _('Overview'))->addItem(QUEUE_OVERVIEW_BY_PROXY, _('Overview by proxy'))->addItem(QUEUE_DETAILS, _('Details'))))); $table = new CTableInfo(); $severityConfig = select_config(); // overview if ($config == QUEUE_OVERVIEW) { $itemTypes = [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([_('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];