/**
  * 调用接口 
  * 
  * @param string $module 
  * @param string $action 
  * @static
  * @access public
  * @return array
  */
 public static function call($module, $action, $params = array())
 {
     $config = \swan\config\sw_config::get_config('data_host');
     if (!isset($config['host']) || !isset($config['port'])) {
         throw new sw_exception('data center host or port empty.');
     }
     $url = 'http://%s:%s/%s/?/%s';
     $url = sprintf($url, $config['host'], $config['port'], $module, $action);
     $curl = new \swan\curl\sw_curl($url);
     $curl->set_params($params);
     $return_content = $curl->call();
     if (!$return_content) {
         throw new sw_exception('get data from data center.');
     }
     $data = json_decode($return_content, true);
     if (isset($data['code'])) {
         return $data;
     }
     throw new sw_exception('get data from data center.');
 }
Beispiel #2
0
define('RRD_NL', "\\\n");
define('SWAN_EXEC_UID', 'swan');
define('SWAN_EXEC_GID', 'swan');
// }}}
// {{{ 系统初始化
//初始化时区
date_default_timezone_set(SWAN_TIMEZONE_DEFAULT);
// }}}
// }}}
// {{{  框架初始化
// 引入 sf 框架
require_once PATH_SWAN_SF . 'swanphp.php';
$autoloader = \swan\loader\sw_auto::get_instance(array('namespaces' => array('lib' => PATH_SWAN_BASE)));
$autoloader->register();
// 初始化配置
\swan\config\sw_config::set_config(PATH_SWAN_CONF . '/config.php');
// }}}
// {{{ 数据库常量
define('SWAN_TBN_SEQUENCE_GLOBAL', 'sequence_global');
define('SWAN_TBN_SEQUENCE_DEVICE', 'sequence_device');
define('SWAN_TBN_SEQUENCE_MADAPTER', 'sequence_madapter');
define('SWAN_TBN_SEQUENCE_GRAPH', 'sequence_graph');
define('SWAN_TBN_DEVICE_KEY', 'device_key');
define('SWAN_TBN_DEVICE_BASIC', 'device_basic');
define('SWAN_TBN_DEVICE_MONITOR', 'device_monitor');
define('SWAN_TBN_MADAPTER_BASIC', 'madapter_basic');
define('SWAN_TBN_MONITOR_PARAM', 'device_monitor_params');
define('SWAN_TBN_MADAPTER_ATTRIBUTE', 'madapter_attribute');
define('SWAN_TBN_MADAPTER_METRIC', 'madapter_metric');
define('SWAN_TBN_MADAPTER_ARCHIVE', 'madapter_archive');
// }}}
Beispiel #3
0
 /**
  * 获取 logsvr 的配置 
  * 
  * @static
  * @access public
  * @return array
  */
 public static function get_logsvr_config()
 {
     return array('host' => \swan\config\sw_config::get_config('log:host'), 'port' => \swan\config\sw_config::get_config('log:port'), 'self' => \swan\config\sw_config::get_config('log:self'));
 }