• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

PHP zbx_toArray函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了PHP中zbx_toArray函数的典型用法代码示例。如果您正苦于以下问题:PHP zbx_toArray函数的具体用法?PHP zbx_toArray怎么用?PHP zbx_toArray使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



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

示例1: execute

 /**
  * Executes API requests.
  *
  * @return string JSON encoded value
  */
 public function execute()
 {
     if ($this->json->hasError()) {
         $this->jsonError(null, '-32700', null, null, true);
         return $this->json->encode($this->_response[0]);
     }
     if ($this->_jsonDecoded === null || $this->_jsonDecoded == []) {
         $this->jsonError(null, '-32600', null, null, true);
         return $this->json->encode($this->_response[0]);
     }
     foreach (zbx_toArray($this->_jsonDecoded) as $call) {
         $call = is_array($call) ? $call : [$call];
         // notification
         if (!array_key_exists('id', $call)) {
             $call['id'] = null;
         }
         if (!$this->validate($call)) {
             continue;
         }
         list($api, $method) = array_merge(explode('.', $call['method']), [null, null]);
         $result = $this->apiClient->callMethod($api, $method, $call['params'], $call['auth']);
         $this->processResult($call, $result);
     }
     if (is_array($this->_jsonDecoded) && array_keys($this->_jsonDecoded) === range(0, count($this->_jsonDecoded) - 1)) {
         // Return response as encoded batch if $this->_jsonDecoded is associative array.
         return $this->json->encode($this->_response);
     }
     return $this->json->encode($this->_response[0]);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:34,代码来源:CJsonRpc.php


示例2: delete

 /**
  * Delete web scenario.
  *
  * @param $httpTestIds
  *
  * @return array|bool
  */
 public function delete($httpTestIds, $nopermissions = false)
 {
     if (empty($httpTestIds)) {
         return true;
     }
     $httpTestIds = zbx_toArray($httpTestIds);
     $delHttpTests = $this->get(array('httptestids' => $httpTestIds, 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     if (!$nopermissions) {
         foreach ($httpTestIds as $httpTestId) {
             if (!empty($delHttpTests[$httpTestId]['templateid'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot delete templated web scenario "%1$s".', $delHttpTests[$httpTestId]['name']));
             }
             if (!isset($delHttpTests[$httpTestId])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
             }
         }
     }
     $parentHttpTestIds = $httpTestIds;
     $childHttpTestIds = array();
     do {
         $dbTests = DBselect('SELECT ht.httptestid FROM httptest ht WHERE ' . dbConditionInt('ht.templateid', $parentHttpTestIds));
         $parentHttpTestIds = array();
         while ($dbTest = DBfetch($dbTests)) {
             $parentHttpTestIds[] = $dbTest['httptestid'];
             $childHttpTestIds[$dbTest['httptestid']] = $dbTest['httptestid'];
         }
     } while (!empty($parentHttpTestIds));
     $options = array('httptestids' => $childHttpTestIds, 'output' => API_OUTPUT_EXTEND, 'nopermissions' => true, 'preservekeys' => true, 'selectHosts' => API_OUTPUT_EXTEND);
     $delHttpTestChilds = $this->get($options);
     $delHttpTests = zbx_array_merge($delHttpTests, $delHttpTestChilds);
     $httpTestIds = array_merge($httpTestIds, $childHttpTestIds);
     $itemidsDel = array();
     $dbTestItems = DBselect('SELECT hsi.itemid' . ' FROM httptestitem hsi' . ' WHERE ' . dbConditionInt('hsi.httptestid', $httpTestIds));
     while ($testitem = DBfetch($dbTestItems)) {
         $itemidsDel[] = $testitem['itemid'];
     }
     $dbStepItems = DBselect('SELECT DISTINCT hsi.itemid' . ' FROM httpstepitem hsi,httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', $httpTestIds) . ' AND hs.httpstepid=hsi.httpstepid');
     while ($stepitem = DBfetch($dbStepItems)) {
         $itemidsDel[] = $stepitem['itemid'];
     }
     if (!empty($itemidsDel)) {
         API::Item()->delete($itemidsDel, true);
     }
     DB::delete('httptest', array('httptestid' => $httpTestIds));
     // TODO: REMOVE
     foreach ($delHttpTests as $httpTest) {
         $host = reset($httpTest['hosts']);
         info(_s('Deleted: Web scenario "%1$s" on "%2$s".', $httpTest['name'], $host['host']));
         add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCENARIO, 'Web scenario "' . $httpTest['name'] . '" "' . $httpTest['httptestid'] . '" host "' . $host['host'] . '".');
     }
     return array('httptestids' => $httpTestIds);
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:59,代码来源:CHttpTest.php


示例3: update

 /**
  * Update scripts.
  *
  * @param array $scripts
  * @param array $scripts['name']
  * @param array $scripts['hostid']
  *
  * @return array
  */
 public function update(array $scripts)
 {
     $scripts = zbx_toArray($scripts);
     $this->validateUpdate($scripts);
     $scripts = $this->trimMenuPath($scripts);
     $this->validateMenuPath($scripts, __FUNCTION__);
     $scripts = $this->unsetExecutionType($scripts);
     $update = array();
     foreach ($scripts as $script) {
         $scriptId = $script['scriptid'];
         unset($script['scriptid']);
         $update[] = array('values' => $script, 'where' => array('scriptid' => $scriptId));
     }
     DB::update('scripts', $update);
     return array('scriptids' => zbx_objectValues($scripts, 'scriptid'));
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:25,代码来源:CScript.php


示例4: delete

 /**
  * Delete Host
  *
  * @param array $hosts
  * @param array $hosts[0, ...]['hostid'] Host ID to delete
  * @return array|boolean
  */
 public static function delete($hosts)
 {
     $hosts = zbx_toArray($hosts);
     $hostids = zbx_objectValues($hosts, 'hostid');
     if (empty($hostids)) {
         return true;
     }
     try {
         self::BeginTransaction(__METHOD__);
         $options = array('hostids' => $hostids, 'editable' => 1, 'output' => API_OUTPUT_SHORTEN, 'preservekeys' => 1);
         $del_hosts = self::get($options);
         foreach ($hostids as $hnum => $hostid) {
             if (!isset($del_hosts[$hostid])) {
                 self::exception(ZBX_API_ERROR_PERMISSIONS, S_NO_PERMISSION);
             }
         }
         $result = delete_host($hostids, false);
         if (!$result) {
             self::exception(ZBX_API_ERROR_PARAMETERS, 'Cannot delete host');
         }
         self::EndTransaction(true, __METHOD__);
         return array('hostids' => $hostids);
     } catch (APIException $e) {
         self::EndTransaction(false, __METHOD__);
         $error = $e->getErrors();
         $error = reset($error);
         self::setError(__METHOD__, $e->getCode(), $error);
         return false;
     }
 }
开发者ID:songyuanjie,项目名称:zabbix-stats,代码行数:37,代码来源:class.chost.php


示例5: syncTemplates

 /**
  * Inherit template graphs from template to host.
  *
  * @param array $data
  *
  * @return bool
  */
 public function syncTemplates($data)
 {
     $data['templateids'] = zbx_toArray($data['templateids']);
     $data['hostids'] = zbx_toArray($data['hostids']);
     $dbLinks = DBSelect('SELECT ht.hostid,ht.templateid' . ' FROM hosts_templates ht' . ' WHERE ' . dbConditionInt('ht.hostid', $data['hostids']) . ' AND ' . dbConditionInt('ht.templateid', $data['templateids']));
     $linkage = array();
     while ($link = DBfetch($dbLinks)) {
         if (!isset($linkage[$link['templateid']])) {
             $linkage[$link['templateid']] = array();
         }
         $linkage[$link['templateid']][$link['hostid']] = 1;
     }
     $graphs = $this->get(array('hostids' => $data['templateids'], 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND, 'selectGraphItems' => API_OUTPUT_EXTEND, 'selectHosts' => array('hostid'), 'filter' => array('flags' => null)));
     foreach ($graphs as $graph) {
         foreach ($data['hostids'] as $hostid) {
             if (isset($linkage[$graph['hosts'][0]['hostid']][$hostid])) {
                 $this->inherit($graph, $hostid);
             }
         }
     }
     return true;
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:29,代码来源:CGraphPrototype.php


示例6: syncTemplates

 public function syncTemplates($data)
 {
     $data['templateids'] = zbx_toArray($data['templateids']);
     $data['hostids'] = zbx_toArray($data['hostids']);
     $applications = $this->get(array('hostids' => $data['templateids'], 'preservekeys' => true, 'output' => API_OUTPUT_EXTEND));
     $this->inherit($applications, $data['hostids']);
     return true;
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:8,代码来源:CApplication.php


示例7: delete

 /**
  * Delete proxy.
  *
  * @param string|array $proxyIds
  *
  * @return array
  */
 public function delete($proxyIds)
 {
     $proxyIds = zbx_toArray($proxyIds);
     // deprecated input support
     if ($proxyIds && is_array($proxyIds[0])) {
         $this->deprecated('Passing objects is deprecated, use an array of IDs instead.');
         foreach ($proxyIds as $proxyId) {
             if (!check_db_fields(array('proxyid' => null), $proxyId)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No proxy ID given.'));
             }
         }
         $proxyIds = zbx_objectValues($proxyIds, 'proxyid');
     }
     $this->validateDelete($proxyIds);
     $dbProxies = DBselect('SELECT h.hostid,h.host' . ' FROM hosts h' . ' WHERE ' . dbConditionInt('h.hostid', $proxyIds));
     $dbProxies = DBfetchArrayAssoc($dbProxies, 'hostid');
     $actionIds = array();
     // get conditions
     $dbActions = DBselect('SELECT DISTINCT c.actionid' . ' FROM conditions c' . ' WHERE c.conditiontype=' . CONDITION_TYPE_PROXY . ' AND ' . dbConditionString('c.value', $proxyIds));
     while ($dbAction = DBfetch($dbActions)) {
         $actionIds[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if ($actionIds) {
         DB::update('actions', array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionIds)));
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_PROXY, 'value' => $proxyIds));
     // delete interface
     DB::delete('interface', array('hostid' => $proxyIds));
     // delete host
     DB::delete('hosts', array('hostid' => $proxyIds));
     // TODO: remove info from API
     foreach ($dbProxies as $proxy) {
         info(_s('Deleted: Proxy "%1$s".', $proxy['host']));
         add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_PROXY, '[' . $proxy['host'] . '] [' . $proxy['hostid'] . ']');
     }
     return array('proxyids' => $proxyIds);
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:45,代码来源:CProxy.php


示例8: massRemove

 /**
  * Additionally allows to remove interfaces from hosts.
  *
  * Checks write permissions for hosts.
  *
  * Additional supported $data parameters are:
  * - interfaces  - an array of interfaces to delete from the hosts
  *
  * @param array $data
  *
  * @return array
  */
 public function massRemove(array $data)
 {
     $hostids = zbx_toArray($data['hostids']);
     $this->checkPermissions($hostids);
     if (isset($data['interfaces'])) {
         $options = ['hostids' => $hostids, 'interfaces' => zbx_toArray($data['interfaces'])];
         API::HostInterface()->massRemove($options);
     }
     // rename the "templates" parameter to the common "templates_link"
     if (isset($data['templateids'])) {
         $data['templateids_link'] = $data['templateids'];
         unset($data['templateids']);
     }
     $data['templateids'] = [];
     return parent::massRemove($data);
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:28,代码来源:CHost.php


示例9: update

 /**
  * Update IconMap.
  * @param array $iconMaps
  * @return array
  */
 public function update(array $iconMaps)
 {
     if (USER_TYPE_SUPER_ADMIN != self::$userData['type']) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _('Only Super Admins can update icon maps.'));
     }
     $iconMaps = zbx_toArray($iconMaps);
     $iconMapids = zbx_objectValues($iconMaps, 'iconmapid');
     $updates = [];
     $duplicates = [];
     foreach ($iconMaps as $iconMap) {
         if (!check_db_fields(['iconmapid' => null], $iconMap)) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Incorrect parameters for icon map update method "%s".', $iconMap['name']));
         }
         if (isset($iconMap['name'])) {
             if (zbx_empty($iconMap['name'])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map name cannot be empty.'));
             } elseif (isset($duplicates[$iconMap['name']])) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Cannot create icon maps with identical name "%s".', $iconMap['name']));
             } else {
                 $duplicates[$iconMap['name']] = $iconMap['name'];
             }
         }
     }
     $this->validateMappings($iconMaps, false);
     $iconMapsUpd = API::IconMap()->get(['iconmapids' => $iconMapids, 'output' => API_OUTPUT_EXTEND, 'preservekeys' => true, 'selectMappings' => API_OUTPUT_EXTEND]);
     $oldIconMappings = [];
     $newIconMappings = [];
     foreach ($iconMaps as $iconMap) {
         if (!isset($iconMapsUpd[$iconMap['iconmapid']])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map with iconmapid "%s" does not exist.', $iconMap['iconmapid']));
         }
         // Existence
         if (isset($iconMap['name'])) {
             $iconMapExists = $this->get(['filter' => ['name' => $iconMap['name']], 'output' => ['iconmapid'], 'editable' => true, 'nopermissions' => true, 'preservekeys' => true]);
             if (($iconMapExists = reset($iconMapExists)) && bccomp($iconMapExists['iconmapid'], $iconMap['iconmapid']) != 0) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map "%s" already exists.', $iconMap['name']));
             }
         }
         if (isset($iconMap['mappings'])) {
             $mappingsDb = $iconMapsUpd[$iconMap['iconmapid']]['mappings'];
             foreach ($mappingsDb as $mapping) {
                 $oldIconMappings[] = $mapping;
             }
             foreach ($iconMap['mappings'] as $mapping) {
                 $mapping['iconmapid'] = $iconMap['iconmapid'];
                 $newIconMappings[] = $mapping;
             }
         }
         $iconMapid = $iconMap['iconmapid'];
         unset($iconMap['iconmapid']);
         if (!empty($iconMap)) {
             $updates[] = ['values' => $iconMap, 'where' => ['iconmapid' => $iconMapid]];
         }
     }
     DB::save('icon_map', $iconMaps);
     DB::replace('icon_mapping', $oldIconMappings, $newIconMappings);
     return ['iconmapids' => $iconMapids];
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:63,代码来源:CIconMap.php


示例10: syncTemplates

 public function syncTemplates(array $data)
 {
     $data['templateids'] = zbx_toArray($data['templateids']);
     $data['hostids'] = zbx_toArray($data['hostids']);
     $triggers = $this->get(array('hostids' => $data['templateids'], 'preservekeys' => true, 'output' => array('triggerid', 'expression', 'description', 'url', 'status', 'priority', 'comments', 'type')));
     foreach ($triggers as $trigger) {
         $trigger['expression'] = explode_exp($trigger['expression']);
         $this->inherit($trigger, $data['hostids']);
     }
     return true;
 }
开发者ID:itnihao,项目名称:Zabbix_,代码行数:11,代码来源:CTriggerPrototype.php


示例11: delete

 /**
  * Deletes screen items.
  *
  * @param array $screenItemIds
  *
  * @return array
  */
 public function delete($screenItemIds)
 {
     $screenItemIds = zbx_toArray($screenItemIds);
     // check permissions
     $dbScreenItems = $this->get(array('screenitemids' => $screenItemIds, 'preservekeys' => true));
     foreach ($screenItemIds as $screenItemId) {
         if (!isset($dbScreenItems[$screenItemId])) {
             self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
         }
     }
     // delete screen items
     DB::delete($this->tableName(), array('screenitemid' => $screenItemIds));
     return array('screenitemids' => $screenItemIds);
 }
开发者ID:itnihao,项目名称:zatree-2.2,代码行数:21,代码来源:CScreenItem.php


示例12: delete

 /**
  * Delete web scenario.
  *
  * @param $httpTestIds
  *
  * @return array|bool
  */
 public function delete($httpTestIds)
 {
     if (empty($httpTestIds)) {
         return true;
     }
     $httpTestIds = zbx_toArray($httpTestIds);
     $delHttpTests = $this->get(array('httptestids' => $httpTestIds, 'output' => API_OUTPUT_EXTEND, 'editable' => true, 'selectHosts' => API_OUTPUT_EXTEND, 'preservekeys' => true));
     foreach ($httpTestIds as $httpTestId) {
         if (!isset($delHttpTests[$httpTestId])) {
             self::exception(ZBX_API_ERROR_PARAMETERS, _('No permissions to referred object or it does not exist!'));
         }
     }
     $itemidsDel = array();
     $dbTestItems = DBselect('SELECT hsi.itemid' . ' FROM httptestitem hsi' . ' WHERE ' . dbConditionInt('hsi.httptestid', $httpTestIds));
     while ($testitem = DBfetch($dbTestItems)) {
         $itemidsDel[] = $testitem['itemid'];
     }
     $dbStepItems = DBselect('SELECT DISTINCT hsi.itemid' . ' FROM httpstepitem hsi,httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', $httpTestIds) . ' AND hs.httpstepid=hsi.httpstepid');
     while ($stepitem = DBfetch($dbStepItems)) {
         $itemidsDel[] = $stepitem['itemid'];
     }
     if (!empty($itemidsDel)) {
         API::Item()->delete($itemidsDel, true);
     }
     DB::delete('httptest', array('httptestid' => $httpTestIds));
     // TODO: REMOVE info
     foreach ($delHttpTests as $httpTest) {
         info(_s('Scenario "%s" deleted.', $httpTest['name']));
     }
     // TODO: REMOVE audit
     foreach ($delHttpTests as $httpTest) {
         $host = reset($httpTest['hosts']);
         add_audit(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_SCENARIO, _s('Scenario "%1$s" "%2$s" host "%3$s".', $httpTest['name'], $httpTest['httptestid'], $host['host']));
     }
     return array('httptestids' => $httpTestIds);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:43,代码来源:CWebCheck.php


示例13: delete

 /**
  * Delete Host
  *
  * @param string|array 	$hostIds
  * @param bool			$nopermissions
  *
  * @return array|boolean
  */
 public function delete($hostIds, $nopermissions = false)
 {
     $hostIds = zbx_toArray($hostIds);
     // deprecated input support
     if ($hostIds && is_array($hostIds[0])) {
         $this->deprecated('Passing objects is deprecated, use an array of IDs instead.');
         foreach ($hostIds as $host) {
             if (!check_db_fields(array('hostid' => null), $host)) {
                 self::exception(ZBX_API_ERROR_PARAMETERS, _('No host ID given.'));
             }
         }
         $hostIds = zbx_objectValues($hostIds, 'hostid');
     }
     $this->validateDelete($hostIds, $nopermissions);
     // delete the discovery rules first
     $delRules = API::DiscoveryRule()->get(array('hostids' => $hostIds, 'nopermissions' => true, 'preservekeys' => true));
     if ($delRules) {
         API::DiscoveryRule()->delete(array_keys($delRules), true);
     }
     // delete the items
     $delItems = API::Item()->get(array('templateids' => $hostIds, 'output' => array('itemid'), 'nopermissions' => true, 'preservekeys' => true));
     if ($delItems) {
         API::Item()->delete(array_keys($delItems), true);
     }
     // delete web tests
     $delHttptests = array();
     $dbHttptests = get_httptests_by_hostid($hostIds);
     while ($dbHttptest = DBfetch($dbHttptests)) {
         $delHttptests[$dbHttptest['httptestid']] = $dbHttptest['httptestid'];
     }
     if (!empty($delHttptests)) {
         API::HttpTest()->delete($delHttptests, true);
     }
     // delete screen items
     DB::delete('screens_items', array('resourceid' => $hostIds, 'resourcetype' => SCREEN_RESOURCE_HOST_TRIGGERS));
     // delete host from maps
     if (!empty($hostIds)) {
         DB::delete('sysmaps_elements', array('elementtype' => SYSMAP_ELEMENT_TYPE_HOST, 'elementid' => $hostIds));
     }
     // disable actions
     // actions from conditions
     $actionids = array();
     $sql = 'SELECT DISTINCT actionid' . ' FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . dbConditionString('value', $hostIds);
     $dbActions = DBselect($sql);
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     // actions from operations
     $sql = 'SELECT DISTINCT o.actionid' . ' FROM operations o, opcommand_hst oh' . ' WHERE o.operationid=oh.operationid' . ' AND ' . dbConditionInt('oh.hostid', $hostIds);
     $dbActions = DBselect($sql);
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if (!empty($actionids)) {
         $update = array();
         $update[] = array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionids));
         DB::update('actions', $update);
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_HOST, 'value' => $hostIds));
     // delete action operation commands
     $operationids = array();
     $sql = 'SELECT DISTINCT oh.operationid' . ' FROM opcommand_hst oh' . ' WHERE ' . dbConditionInt('oh.hostid', $hostIds);
     $dbOperations = DBselect($sql);
     while ($dbOperation = DBfetch($dbOperations)) {
         $operationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('opcommand_hst', array('hostid' => $hostIds));
     // delete empty operations
     $delOperationids = array();
     $sql = 'SELECT DISTINCT o.operationid' . ' FROM operations o' . ' WHERE ' . dbConditionInt('o.operationid', $operationids) . ' AND NOT EXISTS(SELECT oh.opcommand_hstid FROM opcommand_hst oh WHERE oh.operationid=o.operationid)';
     $dbOperations = DBselect($sql);
     while ($dbOperation = DBfetch($dbOperations)) {
         $delOperationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('operations', array('operationid' => $delOperationids));
     $hosts = API::Host()->get(array('output' => array('hostid', 'name'), 'hostids' => $hostIds, 'nopermissions' => true));
     // delete host inventory
     DB::delete('host_inventory', array('hostid' => $hostIds));
     // delete host applications
     DB::delete('applications', array('hostid' => $hostIds));
     // delete host
     DB::delete('hosts', array('hostid' => $hostIds));
     // TODO: remove info from API
     foreach ($hosts as $host) {
         info(_s('Deleted: Host "%1$s".', $host['name']));
         add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST, $host['hostid'], $host['name'], 'hosts', NULL, NULL);
     }
     // remove Monitoring > Latest data toggle profile values related to given hosts
     CProfile::delete('web.latest.toggle_other', $hostIds);
     return array('hostids' => $hostIds);
 }
开发者ID:hujingguang,项目名称:work,代码行数:100,代码来源:CHost.php


示例14: delete

 /**
  * Delete IconMap.
  * @param array $iconmapids
  * @return array
  */
 public function delete($iconmapids)
 {
     $iconmapids = zbx_toArray($iconmapids);
     if (empty($iconmapids)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     if (!$this->isWritable($iconmapids)) {
         self::exception(ZBX_API_ERROR_PERMISSIONS, _('No permissions to referred object or it does not exist!'));
     }
     $sql = 'SELECT m.name as mapname, im.name as iconmapname' . ' FROM sysmaps m, icon_map im' . ' WHERE m.iconmapid=im.iconmapid' . ' AND ' . dbConditionInt('m.iconmapid', $iconmapids);
     if ($names = DBfetch(DBselect($sql))) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _s('Icon map "%1$s" cannot be deleted. Used in map "%2$s".', $names['iconmapname'], $names['mapname']));
     }
     DB::delete('icon_map', array('iconmapid' => $iconmapids));
     return array('iconmapids' => $iconmapids);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:21,代码来源:CIconMap.php


示例15: delete

 /**
  * Delete Host
  *
  * @param array $hosts
  * @param array $hosts[0, ...]['hostid'] Host ID to delete
  *
  * @return array|boolean
  */
 public function delete($hosts)
 {
     if (empty($hosts)) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameter.'));
     }
     $hosts = zbx_toArray($hosts);
     $hostids = zbx_objectValues($hosts, 'hostid');
     $this->checkInput($hosts, __FUNCTION__);
     // delete the discovery rules first
     $delRules = API::DiscoveryRule()->get(array('hostids' => $hostids, 'nopermissions' => true, 'preservekeys' => true));
     if ($delRules) {
         API::DiscoveryRule()->delete(array_keys($delRules), true);
     }
     // delete the items
     $delItems = API::Item()->get(array('templateids' => $hostids, 'output' => API_OUTPUT_SHORTEN, 'nopermissions' => true, 'preservekeys' => true));
     if ($delItems) {
         API::Item()->delete(array_keys($delItems), true);
     }
     // delete web tests
     $delHttptests = array();
     $dbHttptests = get_httptests_by_hostid($hostids);
     while ($dbHttptest = DBfetch($dbHttptests)) {
         $delHttptests[$dbHttptest['httptestid']] = $dbHttptest['httptestid'];
     }
     if (!empty($delHttptests)) {
         API::WebCheck()->delete($delHttptests);
     }
     // delete screen items
     DB::delete('screens_items', array('resourceid' => $hostids, 'resourcetype' => SCREEN_RESOURCE_HOST_TRIGGERS));
     // delete host from maps
     if (!empty($hostids)) {
         DB::delete('sysmaps_elements', array('elementtype' => SYSMAP_ELEMENT_TYPE_HOST, 'elementid' => $hostids));
     }
     // disable actions
     // actions from conditions
     $actionids = array();
     $sql = 'SELECT DISTINCT actionid' . ' FROM conditions' . ' WHERE conditiontype=' . CONDITION_TYPE_HOST . ' AND ' . dbConditionString('value', $hostids);
     $dbActions = DBselect($sql);
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     // actions from operations
     $sql = 'SELECT DISTINCT o.actionid' . ' FROM operations o, opcommand_hst oh' . ' WHERE o.operationid=oh.operationid' . ' AND ' . dbConditionInt('oh.hostid', $hostids);
     $dbActions = DBselect($sql);
     while ($dbAction = DBfetch($dbActions)) {
         $actionids[$dbAction['actionid']] = $dbAction['actionid'];
     }
     if (!empty($actionids)) {
         $update = array();
         $update[] = array('values' => array('status' => ACTION_STATUS_DISABLED), 'where' => array('actionid' => $actionids));
         DB::update('actions', $update);
     }
     // delete action conditions
     DB::delete('conditions', array('conditiontype' => CONDITION_TYPE_HOST, 'value' => $hostids));
     // delete action operation commands
     $operationids = array();
     $sql = 'SELECT DISTINCT oh.operationid' . ' FROM opcommand_hst oh' . ' WHERE ' . dbConditionInt('oh.hostid', $hostids);
     $dbOperations = DBselect($sql);
     while ($dbOperation = DBfetch($dbOperations)) {
         $operationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('opcommand_hst', array('hostid' => $hostids));
     // delete empty operations
     $delOperationids = array();
     $sql = 'SELECT DISTINCT o.operationid' . ' FROM operations o' . ' WHERE ' . dbConditionInt('o.operationid', $operationids) . ' AND NOT EXISTS(SELECT oh.opcommand_hstid FROM opcommand_hst oh WHERE oh.operationid=o.operationid)';
     $dbOperations = DBselect($sql);
     while ($dbOperation = DBfetch($dbOperations)) {
         $delOperationids[$dbOperation['operationid']] = $dbOperation['operationid'];
     }
     DB::delete('operations', array('operationid' => $delOperationids));
     $hosts = API::Host()->get(array('output' => array('hostid', 'name'), 'hostids' => $hostids, 'nopermissions' => true));
     // delete host inventory
     DB::delete('host_inventory', array('hostid' => $hostids));
     // delete host applications
     DB::delete('applications', array('hostid' => $hostids));
     // delete host
     DB::delete('hosts', array('hostid' => $hostids));
     // TODO: remove info from API
     foreach ($hosts as $host) {
         info(_s('Deleted: Host "%1$s".', $host['name']));
         add_audit_ext(AUDIT_ACTION_DELETE, AUDIT_RESOURCE_HOST, $host['hostid'], $host['name'], 'hosts', NULL, NULL);
     }
     return array('hostids' => $hostids);
 }
开发者ID:quanta-computing,项目名称:debian-packages,代码行数:92,代码来源:CHost.php


示例16: update

 /**
  * Update host macros
  *
  * @param array $hostMacros an array of host macros
  *
  * @return boolean
  */
 public function update($hostMacros)
 {
     $hostMacros = zbx_toArray($hostMacros);
     $this->validateUpdate($hostMacros);
     $data = array();
     foreach ($hostMacros as $macro) {
         $hostMacroId = $macro['hostmacroid'];
         unset($macro['hostmacroid']);
         $data[] = array('values' => $macro, 'where' => array('hostmacroid' => $hostMacroId));
     }
     DB::update('hostmacro', $data);
     return array('hostmacroids' => zbx_objectValues($hostMacros, 'hostmacroid'));
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:20,代码来源:CUserMacro.php


示例17: acknowledge

 /**
  * Acknowledges the given events.
  *
  * Supported parameters:
  * - eventids   - an event ID or an array of event IDs to acknowledge
  * - message    - acknowledgment message
  *
  * @param array $data
  *
  * @return array
  */
 public function acknowledge(array $data)
 {
     $data['eventids'] = zbx_toArray($data['eventids']);
     $this->validateAcknowledge($data);
     $eventIds = zbx_toHash($data['eventids']);
     if (!DBexecute('UPDATE events SET acknowledged=1 WHERE ' . dbConditionInt('eventid', $eventIds))) {
         self::exception(ZBX_API_ERROR_PARAMETERS, 'DBerror');
     }
     $time = time();
     $dataInsert = array();
     foreach ($eventIds as $eventId) {
         $dataInsert[] = array('userid' => self::$userData['userid'], 'eventid' => $eventId, 'clock' => $time, 'message' => $data['message']);
     }
     DB::insert('acknowledges', $dataInsert);
     return array('eventids' => array_values($eventIds));
 }
开发者ID:TonywalkerCN,项目名称:Zabbix,代码行数:27,代码来源:CEvent.php


示例18: syncTemplateDependencies

 /**
  * Synchronizes the templated trigger dependencies on the given hosts inherited from the given
  * templates.
  * Update dependencies, do it after all triggers that can be dependent were created/updated on
  * all child hosts/templates. Starting from highest level template triggers select triggers from
  * one level lower, then for each lower trigger look if it's parent has dependencies, if so
  * find this dependency trigger child on dependent trigger host and add new dependency.
  *
  * @param array $data
  *
  * @return void
  */
 public function syncTemplateDependencies(array $data)
 {
     $templateIds = zbx_toArray($data['templateids']);
     $hostIds = zbx_toArray($data['hostids']);
     $parentTriggers = $this->get(['output' => ['triggerid'], 'hostids' => $templateIds, 'preservekeys' => true, 'selectDependencies' => ['triggerid']]);
     if ($parentTriggers) {
         $childTriggers = $this->get(['output' => ['triggerid', 'templateid'], 'hostids' => $hostIds ? $hostIds : null, 'filter' => ['templateid' => array_keys($parentTriggers)], 'nopermissions' => true, 'preservekeys' => true, 'selectHosts' => ['hostid']]);
         if ($childTriggers) {
             $newDependencies = [];
             foreach ($childTriggers as $childTrigger) {
                 $parentDependencies = $parentTriggers[$childTrigger['templateid']]['dependencies'];
                 if ($parentDependencies) {
                     $dependencies = [];
                     foreach ($parentDependencies as $depTrigger) {
                         $dependencies[] = $depTrigger['triggerid'];
                     }
                     $host = reset($childTrigger['hosts']);
                     $dependencies = replace_template_dependencies($dependencies, $host['hostid']);
                     foreach ($dependencies as $depTriggerId) {
                         $newDependencies[] = ['triggerid' => $childTrigger['triggerid'], 'dependsOnTriggerid' => $depTriggerId];
                     }
                 }
             }
             $this->deleteDependencies($childTriggers);
             if ($newDependencies) {
                 $this->addDependencies($newDependencies);
             }
         }
     }
 }
开发者ID:jbfavre,项目名称:debian-zabbix,代码行数:42,代码来源:CTrigger.php


示例19: update

 /**
  * Update web scenario.
  *
  * @param $httpTests
  *
  * @return array
  */
 public function update($httpTests)
 {
     $httpTests = zbx_toArray($httpTests);
     if (!$httpTests) {
         self::exception(ZBX_API_ERROR_PARAMETERS, _('Empty input parameters.'));
     }
     $this->checkObjectIds($httpTests, 'httptestid', _('No "%1$s" given for web scenario.'), _('Empty web scenario ID.'), _('Incorrect web scenario ID.'));
     $httpTests = zbx_toHash($httpTests, 'httptestid');
     $dbHttpTests = array();
     $dbCursor = DBselect('SELECT ht.httptestid,ht.hostid,ht.templateid,ht.name,' . 'ht.ssl_cert_file,ht.ssl_key_file,ht.ssl_key_password,ht.verify_peer,ht.verify_host' . ' FROM httptest ht' . ' WHERE ' . dbConditionInt('ht.httptestid', array_keys($httpTests)));
     while ($dbHttpTest = DBfetch($dbCursor)) {
         $dbHttpTests[$dbHttpTest['httptestid']] = $dbHttpTest;
     }
     $dbCursor = DBselect('SELECT hs.httpstepid,hs.httptestid,hs.name' . ' FROM httpstep hs' . ' WHERE ' . dbConditionInt('hs.httptestid', array_keys($dbHttpTests)));
     while ($dbHttpStep = DBfetch($dbCursor)) {
         $dbHttpTests[$dbHttpStep['httptestid']]['steps'][$dbHttpStep['httpstepid']] = $dbHttpStep;
     }
     $httpTests = $this->validateUpdate($httpTests, $dbHttpTests);
     Manager::HttpTest()->persist($httpTests);
     return array('httptestids' => array_keys($httpTests));
 }
开发者ID:omidmt,项目名称:zabbix-greenplum,代码行数:28,代码来源:CHttpTest.php


示例20: update

 /**
  * Update value maps.
  *
  * @param array		$valuemaps								An array of value maps.
  * @param string	$valuemaps[]['valuemapid']				ID of the value map.
  * @param string	$valuemaps[]['name']					Name of the value map (optional).
  * @param array		$valuemaps[]['mappings']				Value mappings for value map (optional).
  * @param string	$valuemaps[]['mappings'][]['value']		Value mapping original value (optional).
  * @param string	$valuemaps[]['mappings'][]['newvalue']	Value to which the original value is mapped to (optional).
  *
  * @return array
  */
 public function update($valuemaps)
 {
     $valuemaps = zbx_toArray($valuemaps);
     $this->validateUpdate($valuemaps);
     $upd_valuemaps = [];
     $upd_mappings = [];
     foreach ($valuemaps as $valuemap) {
         $valuemapid = $valuemap['valuemapid'];
         if (array_key_exists('mappings', $valuemap)) {
             $upd_mappings[$valuemapid] = [];
             foreach ($valuemap['mappings'] as $mapping) {
                 $upd_mappings[$valuemapid][$mapping['value']] = $mapping['newvalue'];
             }
         }
         unset($valuemap['valuemapid'], $valuemap['mappings']);
         // Skip updating value maps, if name is not given.
         if (array_key_exists('name', $valuemap)) {
             $upd_valuemaps[$valuemapid] = $valuemap;
         }
     }
     if ($upd_valuemaps) {
         $db_valuemaps = API::getApiService()->select('valuemaps', ['output' => ['valuemapid', 'name'], 'valuemapids' => array_keys($upd_valuemaps)]);
         $update = [];
         foreach ($db_valuemaps as $db_valuemap) {
             $upd_valuemap = $upd_valuemaps[$db_valuemap['valuemapid']];
             // Skip updating value maps, if name was not changed.
             if ($upd_valuemap['name'] !== $db_valuemap['name']) {
                 $update[] = ['values' => $upd_valuemap, 'where' => ['valuemapid' => $db_valuemap['valuemapid']]];
                 add_audit_ext(AUDIT_ACTION_UPDATE, AUDIT_RESOURCE_VALUE_MAP, $db_valuemap['valuemapid'], $upd_valuemap['name'], 'valuemaps', $db_valuemap, $upd_valuemap);
             }
         }
         if ($update) {
             DB::update('valuemaps', $update);
         }
     }
     if ($upd_mappings) {
         $db_mappings = API::getApiService()->select('mappings', ['output' => ['mappingid', 'valuemapid', 'value', 'newvalue'], 'filter' => ['valuemapid' => array_keys($upd_mappings)]]);
         $insert_mapings = [];
         $update_mapings = [];
         $delete_mapingids = [];
         foreach ($db_mappings as $db_mapping) {
             if (array_key_exists($db_mapping['valuemapid'], $upd_mappings)) {
                 $upd_mapping =& $upd_mappings[$db_mapping['valuemapid']];
                 if (array_key_exists($db_mapping['value'], $upd_mapping)) {
                     if ($upd_mapping[$db_mapping['value']] !== $db_mapping['newvalue']) {
                         $update_mapings[] = ['values' => ['newvalue' => $upd_mapping[$db_mapping['value']]], 'where' => ['mappingid' => $db_mapping['mappingid']]];
                     }
                     unset($upd_mapping[$db_mapping['value']]);
                 } else {
                     $delete_mapingids[] = $db_mapping['mappingid'];
                 }
                 unset($upd_mapping);
             } else {
                 $delete_mapingids[] = $db_mapping['mappingid'];
             }
         }
         foreach ($upd_mappings as $valuemapid => $upd_mapping) {
             foreach ($upd_mapping as $value => $newvalue) {
                 $insert_mapings[] = [ 

鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
PHP zbx_toHash函数代码示例发布时间:2022-05-23
下一篇:
PHP zbx_strtolower函数代码示例发布时间:2022-05-23
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap