当前位置: 首页>>代码示例>>PHP>>正文


PHP API::Proxy方法代码示例

本文整理汇总了PHP中API::Proxy方法的典型用法代码示例。如果您正苦于以下问题:PHP API::Proxy方法的具体用法?PHP API::Proxy怎么用?PHP API::Proxy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在API的用法示例。


在下文中一共展示了API::Proxy方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: doAction

 protected function doAction()
 {
     $sortField = $this->getInput('sort', CProfile::get('web.proxies.php.sort', 'host'));
     $sortOrder = $this->getInput('sortorder', CProfile::get('web.proxies.php.sortorder', ZBX_SORT_UP));
     CProfile::update('web.proxies.php.sort', $sortField, PROFILE_TYPE_STR);
     CProfile::update('web.proxies.php.sortorder', $sortOrder, PROFILE_TYPE_STR);
     $config = select_config();
     $data = ['uncheck' => $this->hasInput('uncheck'), 'sort' => $sortField, 'sortorder' => $sortOrder, 'config' => ['max_in_table' => $config['max_in_table']]];
     $data['proxies'] = API::Proxy()->get(['output' => ['proxyid', 'host', 'status', 'lastaccess', 'tls_connect', 'tls_accept'], 'selectHosts' => ['hostid', 'name', 'status'], 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1, 'editable' => true, 'preservekeys' => true]);
     // sorting & paging
     order_result($data['proxies'], $sortField, $sortOrder);
     $url = (new CUrl('zabbix.php'))->setArgument('action', 'proxy.list');
     $data['paging'] = getPagingLine($data['proxies'], $sortOrder, $url);
     foreach ($data['proxies'] as &$proxy) {
         order_result($proxy['hosts'], 'name');
     }
     unset($proxy);
     // get proxy IDs for a *selected* page
     $proxyIds = array_keys($data['proxies']);
     if ($proxyIds) {
         // calculate performance
         $dbPerformance = DBselect('SELECT h.proxy_hostid,SUM(1.0/i.delay) AS qps' . ' FROM hosts h,items i' . ' WHERE h.hostid=i.hostid' . ' AND h.status=' . HOST_STATUS_MONITORED . ' AND i.status=' . ITEM_STATUS_ACTIVE . ' AND i.delay<>0' . ' AND i.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE . ' AND ' . dbConditionInt('h.proxy_hostid', $proxyIds) . ' GROUP BY h.proxy_hostid');
         while ($performance = DBfetch($dbPerformance)) {
             $data['proxies'][$performance['proxy_hostid']]['perf'] = round($performance['qps'], 2);
         }
         // get items
         $items = API::Item()->get(['proxyids' => $proxyIds, 'groupCount' => true, 'countOutput' => true, 'webitems' => true, 'monitored' => true]);
         foreach ($items as $item) {
             $data['proxies'][$item['proxy_hostid']]['item_count'] = $item['rowscount'];
         }
     }
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of proxies'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:35,代码来源:CControllerProxyList.php

示例2: doAction

 protected function doAction()
 {
     $proxy = [];
     $this->getInputs($proxy, ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk']);
     if ($this->getInput('status', HOST_STATUS_PROXY_ACTIVE) == HOST_STATUS_PROXY_PASSIVE) {
         $proxy['interface'] = [];
         $this->getInputs($proxy['interface'], ['dns', 'ip', 'useip', 'port']);
     }
     DBstart();
     if ($this->hasInput('proxy_hostids')) {
         // skip discovered hosts
         $proxy['hosts'] = API::Host()->get(['output' => ['hostid'], 'hostids' => $this->getInput('proxy_hostids'), 'filter' => ['flags' => ZBX_FLAG_DISCOVERY_NORMAL]]);
     }
     $result = API::Proxy()->create([$proxy]);
     if ($result) {
         add_audit(AUDIT_ACTION_ADD, AUDIT_RESOURCE_PROXY, '[' . $this->getInput('host', '') . '] [' . reset($result['proxyids']) . ']');
     }
     $result = DBend($result);
     if ($result) {
         $response = new CControllerResponseRedirect('zabbix.php?action=proxy.list&uncheck=1');
         $response->setMessageOk(_('Proxy added'));
     } else {
         $response = new CControllerResponseRedirect('zabbix.php?action=proxy.edit');
         $response->setFormData($this->getInputAll());
         $response->setMessageError(_('Cannot add proxy'));
     }
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:28,代码来源:CControllerProxyCreate.php

示例3: checkPermissions

 protected function checkPermissions()
 {
     if ($this->getUserType() != USER_TYPE_SUPER_ADMIN) {
         return false;
     }
     $proxies = API::Proxy()->get(['proxyids' => $this->getInput('proxyids'), 'countOutput' => true, 'editable' => true]);
     return $proxies == count($this->getInput('proxyids'));
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:8,代码来源:CControllerProxyHostEnable.php

示例4: doAction

 protected function doAction()
 {
     // default values
     $data = ['sid' => $this->getUserSID(), 'proxyid' => 0, 'host' => '', 'status' => HOST_STATUS_PROXY_ACTIVE, 'dns' => 'localhost', 'ip' => '127.0.0.1', 'useip' => '1', 'port' => '10051', 'proxy_hostids' => [], 'description' => '', 'tls_accept' => HOST_ENCRYPTION_NONE, 'tls_connect' => HOST_ENCRYPTION_NONE, 'tls_issuer' => '', 'tls_psk' => '', 'tls_psk_identity' => '', 'tls_subject' => '', 'form_refresh' => 0];
     // get values from the dabatase
     if ($this->hasInput('proxyid')) {
         $data['proxyid'] = $this->getInput('proxyid');
         $proxies = API::Proxy()->get(['output' => ['host', 'status', 'description', 'tls_connect', 'tls_accept', 'tls_issuer', 'tls_subject', 'tls_psk_identity', 'tls_psk'], 'selectHosts' => ['hostid'], 'selectInterface' => ['interfaceid', 'dns', 'ip', 'useip', 'port'], 'proxyids' => $data['proxyid']]);
         $proxy = $proxies[0];
         $data['host'] = $proxy['host'];
         $data['status'] = $proxy['status'];
         $data['tls_accept'] = $proxy['tls_accept'];
         $data['tls_connect'] = $proxy['tls_connect'];
         $data['tls_issuer'] = $proxy['tls_issuer'];
         $data['tls_psk'] = $proxy['tls_psk'];
         $data['tls_psk_identity'] = $proxy['tls_psk_identity'];
         $data['tls_subject'] = $proxy['tls_subject'];
         if ($data['status'] == HOST_STATUS_PROXY_PASSIVE) {
             $data['interfaceid'] = $proxy['interface']['interfaceid'];
             $data['dns'] = $proxy['interface']['dns'];
             $data['ip'] = $proxy['interface']['ip'];
             $data['useip'] = $proxy['interface']['useip'];
             $data['port'] = $proxy['interface']['port'];
         }
         $data['proxy_hostids'] = zbx_objectValues($proxy['hosts'], 'hostid');
         $data['description'] = $proxy['description'];
     }
     // overwrite with input variables
     $data['host'] = $this->getInput('host', $data['host']);
     $data['status'] = $this->getInput('status', $data['status']);
     $data['dns'] = $this->getInput('dns', $data['dns']);
     $data['ip'] = $this->getInput('ip', $data['ip']);
     $data['useip'] = $this->getInput('useip', $data['useip']);
     $data['port'] = $this->getInput('port', $data['port']);
     $data['proxy_hostids'] = $this->getInput('proxy_hostids', $data['proxy_hostids']);
     $data['description'] = $this->getInput('description', $data['description']);
     $data['tls_accept'] = $this->getInput('tls_accept', $data['tls_accept']);
     $data['tls_connect'] = $this->getInput('tls_connect', $data['tls_connect']);
     $data['tls_issuer'] = $this->getInput('tls_issuer', $data['tls_issuer']);
     $data['tls_psk'] = $this->getInput('tls_psk', $data['tls_psk']);
     $data['tls_psk_identity'] = $this->getInput('tls_psk_identity', $data['tls_psk_identity']);
     $data['tls_subject'] = $this->getInput('tls_subject', $data['tls_subject']);
     $data['form_refresh'] = $this->getInput('form_refresh', $data['form_refresh']);
     if ($data['status'] == HOST_STATUS_PROXY_PASSIVE && $this->hasInput('interfaceid')) {
         $data['interfaceid'] = $this->getInput('interfaceid');
     }
     // fetch available hosts, skip host prototypes
     $data['all_hosts'] = DBfetchArray(DBselect('SELECT h.hostid,h.proxy_hostid,h.name,h.flags' . ' FROM hosts h' . ' WHERE h.status IN (' . HOST_STATUS_MONITORED . ',' . HOST_STATUS_NOT_MONITORED . ')' . ' AND h.flags<>' . ZBX_FLAG_DISCOVERY_PROTOTYPE));
     order_result($data['all_hosts'], 'name');
     $response = new CControllerResponseData($data);
     $response->setTitle(_('Configuration of proxies'));
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:53,代码来源:CControllerProxyEdit.php

示例5: doAction

 protected function doAction()
 {
     $proxyids = $this->getInput('proxyids');
     $result = API::Proxy()->delete($proxyids);
     $deleted = count($proxyids);
     $response = new CControllerResponseRedirect('zabbix.php?action=proxy.list&uncheck=1');
     if ($result) {
         $response->setMessageOk(_n('Proxy deleted', 'Proxies deleted', $deleted));
     } else {
         $response->setMessageError(_n('Cannot delete proxy', 'Cannot delete proxies', $deleted));
     }
     $this->setResponse($response);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:13,代码来源:CControllerProxyDelete.php

示例6: parseMain


//.........这里部分代码省略.........
                 foreach ($macros as $macro) {
                     $host_db['macros'][] = self::mapXML2arr($macro, XML_TAG_MACRO);
                 }
             }
             // }}} MACROS
             // host inventory
             if ($old_version_input) {
                 if (!isset($host_db['inventory'])) {
                     $host_db['inventory'] = array();
                 }
                 $inventoryNode = $xpath->query('host_profile/*', $host);
                 if ($inventoryNode->length > 0) {
                     foreach ($inventoryNode as $field) {
                         $newInventoryName = self::mapInventoryName($field->nodeName);
                         $host_db['inventory'][$newInventoryName] = $field->nodeValue;
                     }
                 }
                 $inventoryNodeExt = $xpath->query('host_profiles_ext/*', $host);
                 if ($inventoryNodeExt->length > 0) {
                     foreach ($inventoryNodeExt as $field) {
                         $newInventoryName = self::mapInventoryName($field->nodeName);
                         if (isset($host_db['inventory'][$newInventoryName]) && $field->nodeValue !== '') {
                             $host_db['inventory'][$newInventoryName] .= "\r\n\r\n";
                             $host_db['inventory'][$newInventoryName] .= $field->nodeValue;
                         } else {
                             $host_db['inventory'][$newInventoryName] = $field->nodeValue;
                         }
                     }
                 }
                 $host_db['inventory_mode'] = isset($host_db['inventory']) ? HOST_INVENTORY_MANUAL : HOST_INVENTORY_DISABLED;
             }
             // HOSTS
             if (isset($host_db['proxy_hostid'])) {
                 $proxy_exists = API::Proxy()->get(array('proxyids' => $host_db['proxy_hostid']));
                 if (empty($proxy_exists)) {
                     $host_db['proxy_hostid'] = 0;
                 }
             }
             if ($current_host && (!empty($rules['hosts']['updateExisting']) || !empty($rules['templates']['updateExisting']))) {
                 if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                     $host_db['templateid'] = $current_host['templateid'];
                     $result = API::Template()->update($host_db);
                     $current_hostid = $current_host['templateid'];
                 } else {
                     $host_db['hostid'] = $current_host['hostid'];
                     $result = API::Host()->update($host_db);
                     $current_hostid = $current_host['hostid'];
                 }
                 if (!$result) {
                     throw new Exception();
                 }
             }
             if (!$current_host && (!empty($rules['hosts']['createMissing']) || !empty($rules['templates']['createMissing']))) {
                 if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                     $result = API::Template()->create($host_db);
                     if (!$result) {
                         throw new Exception();
                     }
                     $current_hostid = reset($result['templateids']);
                 } else {
                     $result = API::Host()->create($host_db);
                     if (!$result) {
                         throw new Exception();
                     }
                     $current_hostid = reset($result['hostids']);
                 }
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:67,代码来源:CXmlImport18.php

示例7: selectProxyes

 /**
  * Select proxy ids for previously added proxy names.
  */
 protected function selectProxyes()
 {
     if (!empty($this->proxies)) {
         $this->proxiesRefs = array();
         $dbProxy = API::Proxy()->get(array('filter' => array('host' => $this->proxies), 'output' => array('hostid', 'host'), 'preservekeys' => true, 'editable' => true));
         foreach ($dbProxy as $proxy) {
             $this->proxiesRefs[$proxy['host']] = $proxy['proxyid'];
         }
         $this->proxies = array();
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:14,代码来源:CImportReferencer.php

示例8: checkInput

 /**
  * Check interfaces input.
  *
  * @param array  $interfaces
  * @param string $method
  */
 public function checkInput(array &$interfaces, $method)
 {
     $update = $method == 'update';
     // permissions
     if ($update) {
         $interfaceDBfields = array('interfaceid' => null);
         $dbInterfaces = $this->get(array('output' => API_OUTPUT_EXTEND, 'interfaceids' => zbx_objectValues($interfaces, 'interfaceid'), 'editable' => true, 'preservekeys' => true));
     } else {
         $interfaceDBfields = array('hostid' => null, 'ip' => null, 'dns' => null, 'useip' => null, 'port' => null, 'main' => null);
     }
     $dbHosts = API::Host()->get(array('output' => array('host'), 'hostids' => zbx_objectValues($interfaces, 'hostid'), 'editable' => true, 'preservekeys' => true));
     $dbProxies = API::Proxy()->get(array('output' => array('host'), 'proxyids' => zbx_objectValues($interfaces, 'hostid'), 'editable' => true, 'preservekeys' => true));
     foreach ($interfaces as &$interface) {
         if (!check_db_fields($interfaceDBfields, $interface)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to function.'));
         }
         if ($update) {
             if (!isset($dbInterfaces[$interface['interfaceid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             $dbInterface = $dbInterfaces[$interface['interfaceid']];
             if (isset($interface['hostid']) && bccomp($dbInterface['hostid'], $interface['hostid']) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot switch host for interface.'));
             }
             $interface['hostid'] = $dbInterface['hostid'];
             // we check all fields on "updated" interface
             $updInterface = $interface;
             $interface = zbx_array_merge($dbInterface, $interface);
         } else {
             if (!isset($dbHosts[$interface['hostid']]) && !isset($dbProxies[$interface['hostid']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
             if (isset($dbProxies[$interface['hostid']])) {
                 $interface['type'] = INTERFACE_TYPE_UNKNOWN;
             } elseif (!isset($interface['type'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect arguments passed to method.'));
             }
         }
         if (zbx_empty($interface['ip']) && zbx_empty($interface['dns'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('IP and DNS cannot be empty for host interface.'));
         }
         if ($interface['useip'] == INTERFACE_USE_IP && zbx_empty($interface['ip'])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Interface with DNS "%1$s" cannot have empty IP address.', $interface['dns']));
         }
         if ($interface['useip'] == INTERFACE_USE_DNS && zbx_empty($interface['dns'])) {
             if ($dbHosts && !empty($dbHosts[$interface['hostid']]['host'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Interface with IP "%1$s" cannot have empty DNS name while having "Use DNS" property on "%2$s".', $interface['ip'], $dbHosts[$interface['hostid']]['host']));
             } elseif ($dbProxies && !empty($dbProxies[$interface['hostid']]['host'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Interface with IP "%1$s" cannot have empty DNS name while having "Use DNS" property on "%2$s".', $interface['ip'], $dbProxies[$interface['hostid']]['host']));
             } else {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Interface with IP "%1$s" cannot have empty DNS name.', $interface['ip']));
             }
         }
         if (isset($interface['dns'])) {
             $this->checkDns($interface);
         }
         if (isset($interface['ip'])) {
             $this->checkIp($interface);
         }
         if (isset($interface['port']) || $method == 'create') {
             $this->checkPort($interface);
         }
         if ($update) {
             $interface = $updInterface;
         }
     }
     unset($interface);
     // check if any of the affected hosts are discovered
     if ($update) {
         $interfaces = $this->extendObjects('interface', $interfaces, array('hostid'));
     }
     $this->checkValidator(zbx_objectValues($interfaces, 'hostid'), new CHostNormalValidator(array('message' => _('Cannot update interface for discovered host "%1$s".'))));
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:79,代码来源:CHostInterface.php

示例9: parseMain


//.........这里部分代码省略.........
                 $host_db['macros'] = array();
                 foreach ($macros as $macro) {
                     $host_db['macros'][] = self::mapXML2arr($macro, XML_TAG_MACRO);
                 }
             }
             // }}} MACROS
             // host inventory
             if ($oldVersionInput) {
                 if (!isset($host_db['inventory'])) {
                     $host_db['inventory'] = array();
                 }
                 $inventoryNode = $xpath->query('host_profile/*', $host);
                 if ($inventoryNode->length > 0) {
                     foreach ($inventoryNode as $field) {
                         $newInventoryName = self::mapInventoryName($field->nodeName);
                         $host_db['inventory'][$newInventoryName] = $field->nodeValue;
                     }
                 }
                 $inventoryNodeExt = $xpath->query('host_profiles_ext/*', $host);
                 if ($inventoryNodeExt->length > 0) {
                     foreach ($inventoryNodeExt as $field) {
                         $newInventoryName = self::mapInventoryName($field->nodeName);
                         if (isset($host_db['inventory'][$newInventoryName]) && $field->nodeValue !== '') {
                             $host_db['inventory'][$newInventoryName] .= "\r\n\r\n";
                             $host_db['inventory'][$newInventoryName] .= $field->nodeValue;
                         } else {
                             $host_db['inventory'][$newInventoryName] = $field->nodeValue;
                         }
                     }
                 }
                 $host_db['inventory_mode'] = isset($host_db['inventory']) ? HOST_INVENTORY_MANUAL : HOST_INVENTORY_DISABLED;
             }
             if (isset($host_db['proxy_hostid'])) {
                 $proxy_exists = API::Proxy()->get(array('output' => array('proxyid'), 'proxyids' => $host_db['proxy_hostid']));
                 if (empty($proxy_exists)) {
                     $host_db['proxy_hostid'] = 0;
                 }
             }
             if ($current_host && ($rules['hosts']['updateExisting'] || $rules['templates']['updateExisting'])) {
                 if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                     $host_db['templateid'] = $current_host['templateid'];
                     $result = API::Template()->update($host_db);
                     $current_hostid = $current_host['templateid'];
                 } else {
                     $host_db['hostid'] = $current_host['hostid'];
                     $result = API::Host()->update($host_db);
                     $current_hostid = $current_host['hostid'];
                 }
             }
             if (!$current_host && ($rules['hosts']['createMissing'] || $rules['templates']['createMissing'])) {
                 if ($host_db['status'] == HOST_STATUS_TEMPLATE) {
                     $result = API::Template()->create($host_db);
                     $current_hostid = reset($result['templateids']);
                 } else {
                     $result = API::Host()->create($host_db);
                     $current_hostid = reset($result['hostids']);
                 }
             }
             // store parsed host IDs
             $processedHostIds[$host_db['host']] = $current_hostid;
         }
         // gather triggers and convert old expressions
         $triggersXML = array();
         // cycle each host and gather trigger descriptions and expressions
         foreach ($hosts as $host) {
             $host_db = self::mapXML2arr($host, XML_TAG_HOST);
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:67,代码来源:CXmlImport18.php

示例10: validateConditions


//.........这里部分代码省略.........
                     if (!$timePeriodValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, $timePeriodValidator->getError());
                     }
                     break;
                 case CONDITION_TYPE_DHOST_IP:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } else {
                         if (!validate_ip_range($condition['value'])) {
                             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition ip "%1$s".', $condition['value']));
                         }
                     }
                     break;
                 case CONDITION_TYPE_DSERVICE_TYPE:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!$discoveryCheckTypeValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery check.'));
                     }
                     break;
                 case CONDITION_TYPE_DSERVICE_PORT:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!validate_port_list($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect action condition port "%1$s".', $condition['value']));
                     }
                     break;
                 case CONDITION_TYPE_DSTATUS:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!$discoveryObjectStatusValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery status.'));
                     }
                     break;
                 case CONDITION_TYPE_MAINTENANCE:
                     if (!zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Maintenance action condition value must be empty.'));
                     }
                     break;
                 case CONDITION_TYPE_TRIGGER_SEVERITY:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!$triggerSeverityValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition trigger severity.'));
                     }
                     break;
                 case CONDITION_TYPE_TRIGGER_VALUE:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!$triggerValueValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition trigger value.'));
                     }
                     break;
                 case CONDITION_TYPE_EVENT_TYPE:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     } elseif (!$eventTypeValidator->validate($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition event type.'));
                     }
                     break;
                 case CONDITION_TYPE_TRIGGER_NAME:
                 case CONDITION_TYPE_NODE:
                 case CONDITION_TYPE_DUPTIME:
                 case CONDITION_TYPE_DVALUE:
                 case CONDITION_TYPE_APPLICATION:
                 case CONDITION_TYPE_HOST_NAME:
                 case CONDITION_TYPE_HOST_METADATA:
                     if (zbx_empty($condition['value'])) {
                         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty action condition.'));
                     }
                     break;
                 default:
                     self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition type.'));
                     break;
             }
         }
     }
     if (!API::HostGroup()->isWritable($hostGroupIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host group. Host group does not exist or you have no access to it.'));
     }
     if (!API::Host()->isWritable($hostIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host. Host does not exist or you have no access to it.'));
     }
     if (!API::Template()->isWritable($templateIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition template. Template does not exist or you have no access to it.'));
     }
     if (!API::Trigger()->isWritable($triggerIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition trigger. Trigger does not exist or you have no access to it.'));
     }
     if (!API::DRule()->isWritable($discoveryRuleIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery rule. Discovery rule does not exist or you have no access to it.'));
     }
     if (!API::DCheck()->isWritable($proxyIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery check. Discovery check does not exist or you have no access to it.'));
     }
     if (!API::Proxy()->isWritable($proxyidsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition proxy. Proxy does not exist or you have no access to it.'));
     }
     return true;
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:101,代码来源:CAction.php

示例11: getRequest

        $data['drule']['name'] = getRequest('name', '');
        $data['drule']['iprange'] = getRequest('iprange', '192.168.0.1-254');
        $data['drule']['delay'] = getRequest('delay', SEC_PER_HOUR);
        $data['drule']['status'] = getRequest('status', DRULE_STATUS_ACTIVE);
        $data['drule']['dchecks'] = getRequest('dchecks', []);
        $data['drule']['nextcheck'] = getRequest('nextcheck', 0);
        $data['drule']['uniqueness_criteria'] = getRequest('uniqueness_criteria', -1);
    }
    if (!empty($data['drule']['dchecks'])) {
        foreach ($data['drule']['dchecks'] as $id => $dcheck) {
            $data['drule']['dchecks'][$id]['name'] = discovery_check2str($dcheck['type'], isset($dcheck['key_']) ? $dcheck['key_'] : '', isset($dcheck['ports']) ? $dcheck['ports'] : '');
        }
        order_result($data['drule']['dchecks'], 'name');
    }
    // get proxies
    $data['proxies'] = API::Proxy()->get(['output' => API_OUTPUT_EXTEND]);
    order_result($data['proxies'], 'host');
    // render view
    $discoveryView = new CView('configuration.discovery.edit', $data);
    $discoveryView->render();
    $discoveryView->show();
} else {
    $sortField = getRequest('sort', CProfile::get('web.' . $page['file'] . '.sort', 'name'));
    $sortOrder = getRequest('sortorder', CProfile::get('web.' . $page['file'] . '.sortorder', ZBX_SORT_UP));
    CProfile::update('web.' . $page['file'] . '.sort', $sortField, PROFILE_TYPE_STR);
    CProfile::update('web.' . $page['file'] . '.sortorder', $sortOrder, PROFILE_TYPE_STR);
    $config = select_config();
    $data = ['sort' => $sortField, 'sortorder' => $sortOrder];
    // get drules
    $data['drules'] = API::DRule()->get(['output' => ['proxy_hostid', 'name', 'status', 'iprange', 'delay'], 'selectDChecks' => ['type'], 'editable' => true, 'sortfield' => $sortField, 'limit' => $config['search_limit'] + 1]);
    if ($data['drules']) {
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:31,代码来源:discoveryconf.php

示例12: get_header_host_table

/**
 * Create CDiv with host/template information and references to it's elements
 *
 * @param string $currentElement
 * @param int $hostid
 * @param int $lld_ruleid
 *
 * @return object
 */
function get_header_host_table($current_element, $hostid, $lld_ruleid = 0)
{
    $options = ['output' => ['hostid', 'status', 'proxy_hostid', 'name', 'maintenance_status', 'flags', 'available', 'snmp_available', 'jmx_available', 'ipmi_available', 'error', 'snmp_error', 'jmx_error', 'ipmi_error'], 'selectHostDiscovery' => ['ts_delete'], 'hostids' => [$hostid], 'editable' => true];
    if ($lld_ruleid == 0) {
        $options['selectApplications'] = API_OUTPUT_COUNT;
        $options['selectItems'] = API_OUTPUT_COUNT;
        $options['selectTriggers'] = API_OUTPUT_COUNT;
        $options['selectGraphs'] = API_OUTPUT_COUNT;
        $options['selectDiscoveries'] = API_OUTPUT_COUNT;
        $options['selectHttpTests'] = API_OUTPUT_COUNT;
    }
    // get hosts
    $db_host = API::Host()->get($options);
    if (!$db_host) {
        $options = ['output' => ['templateid', 'name', 'flags'], 'templateids' => [$hostid], 'editable' => true];
        if ($lld_ruleid == 0) {
            $options['selectApplications'] = API_OUTPUT_COUNT;
            $options['selectItems'] = API_OUTPUT_COUNT;
            $options['selectTriggers'] = API_OUTPUT_COUNT;
            $options['selectGraphs'] = API_OUTPUT_COUNT;
            $options['selectScreens'] = API_OUTPUT_COUNT;
            $options['selectDiscoveries'] = API_OUTPUT_COUNT;
            $options['selectHttpTests'] = API_OUTPUT_COUNT;
        }
        // get templates
        $db_host = API::Template()->get($options);
        $is_template = true;
    } else {
        $is_template = false;
    }
    if (!$db_host) {
        return null;
    }
    $db_host = reset($db_host);
    // get lld-rules
    if ($lld_ruleid != 0) {
        $db_discovery_rule = API::DiscoveryRule()->get(['output' => ['name'], 'selectItems' => API_OUTPUT_COUNT, 'selectTriggers' => API_OUTPUT_COUNT, 'selectGraphs' => API_OUTPUT_COUNT, 'selectHostPrototypes' => API_OUTPUT_COUNT, 'itemids' => [$lld_ruleid], 'editable' => true]);
        $db_discovery_rule = reset($db_discovery_rule);
    }
    /*
     * list and host (template) name
     */
    $list = (new CList())->addClass(ZBX_STYLE_OBJECT_GROUP);
    if ($is_template) {
        $template = new CSpan(new CLink($db_host['name'], 'templates.php?form=update&templateid=' . $db_host['templateid']));
        if ($current_element === '') {
            $template->addClass(ZBX_STYLE_SELECTED);
        }
        $list->addItem([new CSpan(new CLink(_('All templates'), 'templates.php?templateid=' . $db_host['templateid'] . url_param('groupid'))), '/', $template]);
        $db_host['hostid'] = $db_host['templateid'];
    } else {
        $proxy_name = '';
        if ($db_host['proxy_hostid'] != 0) {
            $db_proxies = API::Proxy()->get(['output' => ['host'], 'proxyids' => [$db_host['proxy_hostid']]]);
            $proxy_name = CHtml::encode($db_proxies[0]['host']) . NAME_DELIMITER;
        }
        $name = $proxy_name . CHtml::encode($db_host['name']);
        switch ($db_host['status']) {
            case HOST_STATUS_MONITORED:
                if ($db_host['maintenance_status'] == HOST_MAINTENANCE_STATUS_ON) {
                    $status = (new CSpan(_('In maintenance')))->addClass(ZBX_STYLE_ORANGE);
                } else {
                    $status = (new CSpan(_('Enabled')))->addClass(ZBX_STYLE_GREEN);
                }
                break;
            case HOST_STATUS_NOT_MONITORED:
                $status = (new CSpan(_('Disabled')))->addClass(ZBX_STYLE_RED);
                break;
            default:
                $status = _('Unknown');
                break;
        }
        $host = new CSpan(new CLink($name, 'hosts.php?form=update&hostid=' . $db_host['hostid']));
        if ($current_element === '') {
            $host->addClass(ZBX_STYLE_SELECTED);
        }
        $list->addItem([new CSpan(new CLink(_('All hosts'), 'hosts.php?hostid=' . $db_host['hostid'] . url_param('groupid'))), '/', $host]);
        $list->addItem($status);
        $list->addItem(getHostAvailabilityTable($db_host));
        if ($db_host['flags'] == ZBX_FLAG_DISCOVERY_CREATED && $db_host['hostDiscovery']['ts_delete'] != 0) {
            $lifetime_indicator = getHostLifetimeIndicator(time(), $db_host['hostDiscovery']['ts_delete']);
            $list->addItem((new CDiv($lifetime_indicator))->addClass(ZBX_STYLE_STATUS_CONTAINER));
        }
    }
    /*
     * the count of rows
     */
    if ($lld_ruleid == 0) {
        // applications
        $applications = new CSpan([new CLink(_('Applications'), 'applications.php?hostid=' . $db_host['hostid']), CViewHelper::showNum($db_host['applications'])]);
        if ($current_element == 'applications') {
//.........这里部分代码省略.........
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:101,代码来源:html.inc.php

示例13: get_request

        $data['drule']['name'] = get_request('name', '');
        $data['drule']['iprange'] = get_request('iprange', '192.168.0.1-255');
        $data['drule']['delay'] = get_request('delay', SEC_PER_HOUR);
        $data['drule']['status'] = get_request('status', DRULE_STATUS_ACTIVE);
        $data['drule']['dchecks'] = get_request('dchecks', array());
        $data['drule']['nextcheck'] = get_request('nextcheck', 0);
        $data['drule']['uniqueness_criteria'] = get_request('uniqueness_criteria', -1);
    }
    if (!empty($data['drule']['dchecks'])) {
        foreach ($data['drule']['dchecks'] as $id => $dcheck) {
            $data['drule']['dchecks'][$id]['name'] = discovery_check2str($dcheck['type'], isset($dcheck['key_']) ? $dcheck['key_'] : '', isset($dcheck['ports']) ? $dcheck['ports'] : '');
        }
        order_result($data['drule']['dchecks'], 'name');
    }
    // get proxies
    $data['proxies'] = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND));
    order_result($data['proxies'], 'host');
    // render view
    $discoveryView = new CView('configuration.discovery.edit', $data);
    $discoveryView->render();
    $discoveryView->show();
} else {
    $data = array();
    // get drules
    $data['drules'] = API::DRule()->get(array('output' => API_OUTPUT_EXTEND, 'sortfield' => getPageSortField('name'), 'selectDChecks' => API_OUTPUT_EXTEND, 'editable' => true));
    if (!empty($data['drules'])) {
        foreach ($data['drules'] as $druleid => $drule) {
            // checks
            $checks = array();
            foreach ($drule['dchecks'] as $check) {
                $checks[$check['type']] = discovery_check_type2str($check['type']);
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:discoveryconf.php

示例14: CDiv

    }
    $ifTab->addRow($row);
    $hostList->addRow(_('IPMI interfaces'), new CDiv($ifTab, 'border_dotted objectgroup interface-group'), false, null, 'interface-row interface-row-last');
}
// Proxy
if (!$isDiscovered) {
    $proxyControl = new CComboBox('proxy_hostid', $proxy_hostid);
    $proxyControl->addItem(0, _('(no proxy)'));
    $db_proxies = API::Proxy()->get(array('output' => API_OUTPUT_EXTEND));
    order_result($db_proxies, 'host');
    foreach ($db_proxies as $proxy) {
        $proxyControl->addItem($proxy['proxyid'], $proxy['host']);
    }
} else {
    if ($dbHost['proxy_hostid']) {
        $proxy = API::Proxy()->get(array('output' => array('host', 'proxyid'), 'proxyids' => $dbHost['proxy_hostid'], 'limit' => 1));
        $proxy = reset($proxy);
        $proxyControl = new CTextBox('proxy_host', $proxy['host'], null, true);
    } else {
        $proxyControl = new CTextBox('proxy_host', _('(no proxy)'), null, true);
    }
}
$hostList->addRow(_('Monitored by proxy'), $proxyControl);
$cmbStatus = new CComboBox('status', $status);
$cmbStatus->addItem(HOST_STATUS_MONITORED, _('Monitored'));
$cmbStatus->addItem(HOST_STATUS_NOT_MONITORED, _('Not monitored'));
$hostList->addRow(_('Status'), $cmbStatus);
if ($_REQUEST['form'] == 'full_clone') {
    // host applications
    $hostApps = API::Application()->get(array('hostids' => $_REQUEST['hostid'], 'inherited' => false, 'output' => array('name'), 'preservekeys' => true));
    if (!empty($hostApps)) {
开发者ID:SandipSingh14,项目名称:Zabbix_,代码行数:31,代码来源:configuration.host.edit.php

示例15: validateConditionsPermissions

 /**
  * Check permissions to DB entities referenced by action conditions.
  *
  * @param array $conditions   conditions for which permissions to referenced DB entities will be checked
  */
 protected function validateConditionsPermissions(array $conditions)
 {
     $hostGroupIdsAll = array();
     $templateIdsAll = array();
     $triggerIdsAll = array();
     $hostIdsAll = array();
     $discoveryRuleIdsAll = array();
     $discoveryCheckIdsAll = array();
     $proxyIdsAll = array();
     foreach ($conditions as $condition) {
         $conditionValue = $condition['value'];
         // validate condition values depending on condition type
         switch ($condition['conditiontype']) {
             case CONDITION_TYPE_HOST_GROUP:
                 $hostGroupIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_TEMPLATE:
                 $templateIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_TRIGGER:
                 $triggerIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_HOST:
                 $hostIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_DRULE:
                 $discoveryRuleIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_DCHECK:
                 $discoveryCheckIdsAll[$conditionValue] = $conditionValue;
                 break;
             case CONDITION_TYPE_PROXY:
                 $proxyIdsAll[$conditionValue] = $conditionValue;
                 break;
         }
     }
     if (!API::HostGroup()->isWritable($hostGroupIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host group. Host group does not exist or you have no access to it.'));
     }
     if (!API::Host()->isWritable($hostIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition host. Host does not exist or you have no access to it.'));
     }
     if (!API::Template()->isWritable($templateIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition template. Template does not exist or you have no access to it.'));
     }
     if (!API::Trigger()->isWritable($triggerIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition trigger. Trigger does not exist or you have no access to it.'));
     }
     if (!API::DRule()->isWritable($discoveryRuleIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery rule. Discovery rule does not exist or you have no access to it.'));
     }
     if (!API::DCheck()->isWritable($discoveryCheckIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition discovery check. Discovery check does not exist or you have no access to it.'));
     }
     if (!API::Proxy()->isWritable($proxyIdsAll)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Incorrect action condition proxy. Proxy does not exist or you have no access to it.'));
     }
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:63,代码来源:CAction.php


注:本文中的API::Proxy方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。