コード例 #1
0
 public function __call($method, $params)
 {
     if (!isset(CWebUser::$data['sessionid'])) {
         CWebUser::$data['sessionid'] = null;
     }
     $param = empty($params) ? null : reset($params);
     $result = czbxrpc::call($this->_name . '.' . $method, $param, CWebUser::$data['sessionid']);
     // saving API call for the debug statement
     CProfiler::getInstance()->profileApiCall($this->_name, $method, $params, isset($result['result']) ? $result['result'] : '');
     if (isset($result['result'])) {
         return $result['result'];
     } else {
         $trace = $result['data'];
         if (isset($result['debug'])) {
             $trace .= ' [';
             $chain = array();
             foreach ($result['debug'] as $bt) {
                 if ($bt['function'] == 'exception') {
                     continue;
                 }
                 if ($bt['function'] == 'call_user_func') {
                     break;
                 }
                 $chain[] = isset($bt['class']) ? $bt['class'] . '.' . $bt['function'] : $bt['function'];
                 $chain[] = ' -> ';
             }
             array_pop($chain);
             $trace .= implode('', array_reverse($chain));
             $trace .= ']';
         }
         error($trace);
         return false;
     }
 }
コード例 #2
0
 private static function transactionEnd($result)
 {
     if (self::$transactionStarted) {
         self::$transactionStarted = false;
         DBend($result);
     }
 }
コード例 #3
0
ファイル: CAPIObject.php プロジェクト: SandipSingh14/Zabbix_
 public function __call($method, $params)
 {
     if (!isset(CWebUser::$data['sessionid'])) {
         CWebUser::$data['sessionid'] = null;
     }
     $param = empty($params) ? null : reset($params);
     $result = czbxrpc::call($this->_name . '.' . $method, $param, CWebUser::$data['sessionid']);
     // saving API call for the debug statement
     CProfiler::getInstance()->profileApiCall($this->_name, $method, $params, isset($result['result']) ? $result['result'] : '');
     if (isset($result['result'])) {
         return $result['result'];
     } else {
         $trace = $result['data'];
         if (isset($result['debug'])) {
             $trace .= ' [' . CProfiler::getInstance()->formatCallStack($result['debug']) . ']';
         }
         error($trace);
         return false;
     }
 }
コード例 #4
0
 public function execute($encoded = true)
 {
     foreach ($this->_jsonDecoded as $call) {
         // notification
         if (!isset($call['id'])) {
             $call['id'] = null;
         }
         if (!$this->validate($call)) {
             continue;
         }
         $params = isset($call['params']) ? $call['params'] : null;
         $auth = isset($call['auth']) ? $call['auth'] : null;
         $result = czbxrpc::call($call['method'], $params, $auth);
         $this->processResult($call, $result);
     }
     if (!$encoded) {
         return $this->_response;
     } else {
         return $this->json->encode($this->_response);
     }
 }
コード例 #5
0
 /**
  * Import configuration data.
  *
  * @todo   for 1.8 version import old class CXmlImport18 is used
  *
  * @throws Exception
  * @throws UnexpectedValueException
  * @return bool
  */
 public function import()
 {
     if (empty($this->reader)) {
         throw new UnexpectedValueException('Reader is not set.');
     }
     try {
         // hack to make api throw exceptions
         // this made to not check all api calls results for false return
         czbxrpc::$useExceptions = true;
         DBstart();
         $this->data = $this->reader->read($this->source);
         $version = $this->getImportVersion();
         // if import version is 1.8 we use old class that support it.
         // old import class process hosts, maps and screens separately.
         if ($version == '1.8') {
             CXmlImport18::import($this->source);
             if ($this->options['maps']['updateExisting'] || $this->options['maps']['createMissing']) {
                 CXmlImport18::parseMap($this->options);
             }
             if ($this->options['screens']['updateExisting'] || $this->options['screens']['createMissing']) {
                 CXmlImport18::parseScreen($this->options);
             }
             if ($this->options['hosts']['updateExisting'] || $this->options['hosts']['createMissing'] || $this->options['templates']['updateExisting'] || $this->options['templates']['createMissing']) {
                 CXmlImport18::parseMain($this->options);
             }
         } else {
             $this->formatter = $this->getFormatter($version);
             // pass data to formatter
             // export has root key "zabbix_export" which is not passed
             $this->formatter->setData($this->data['zabbix_export']);
             $this->referencer = new CImportReferencer();
             // parse all import for references to resolve them all together with less sql count
             $this->gatherReferences();
             $this->processGroups();
             $this->processTemplates();
             $this->processHosts();
             $this->processApplications();
             $this->processItems();
             $this->processDiscoveryRules();
             $this->processTriggers();
             $this->processGraphs();
             $this->processImages();
             $this->processMaps();
             // screens should be created after all other elements
             $this->processTemplateScreens();
             $this->processScreens();
         }
         // prevent api from throwing exception
         czbxrpc::$useExceptions = false;
         return DBend(true);
     } catch (Exception $e) {
         czbxrpc::$useExceptions = false;
         DBend(false);
         throw new Exception($e->getMessage(), $e->getCode());
     }
 }
コード例 #6
0
 private function execute($call)
 {
     if (!isset($call['id'])) {
         $call['id'] = null;
     }
     // Notification
     if ($this->validate($call)) {
         $method = $call['method'];
         $params = isset($call['params']) ? $call['params'] : null;
         $auth = isset($call['auth']) ? $call['auth'] : null;
         $result = czbxrpc::call($method, $params, $auth);
         if (isset($result['result'])) {
             $this->json_success($call['id'], $result['result']);
         } else {
             $result['data'] = isset($result['data']) ? $result['data'] : null;
             $errno = $this->zbx2json_error($result['error']);
             $this->json_error($call['id'], $errno, $result['data']);
         }
     }
 }
コード例 #7
0
ファイル: class.czbxrpc.php プロジェクト: phedders/zabbix
 private static function trigger($action, $params)
 {
     CTrigger::$error = array();
     switch ($action) {
         case 'add':
             $result = CTrigger::add($params);
             break;
         case 'get':
             $result = CTrigger::get($params);
             break;
         case 'getById':
             $result = CTrigger::getById($params);
             break;
         case 'getId':
             $result = CTrigger::getId($params);
             break;
         case 'update':
             $result = CTrigger::update($params);
             break;
         case 'delete':
             $result = CTrigger::delete($params);
             break;
         default:
             self::$result = array('error' => ZBX_API_ERROR_NO_METHOD, 'data' => 'Method: "' . $action . '" doesn\'t exist.');
             return;
             //exit function
     }
     if ($result !== false) {
         self::$result = array('result' => $result);
     } else {
         self::$result = array_shift(CTrigger::$error);
     }
 }
コード例 #8
0
 private static function usermacro($action, $params)
 {
     CUserMacro::$error = array();
     switch ($action) {
         default:
             $result = call_user_func(array('CUserMacro', $action), $params);
     }
     self::$result = $result;
 }