include influxdb

This commit is contained in:
dongwei 2019-01-30 14:48:41 +08:00
parent 4b07567d63
commit 38f034aa34
2 changed files with 19 additions and 9 deletions

View File

@ -42,7 +42,7 @@ class TunnelMiddleware
$content = $response->getOriginalContent();
$status = isset($content['error']) ? $content['error']['code'] : 200;
$client = new \InfluxDB\Client('http://localhost', '8086');
$client = new \InfluxDB\Client('127.0.0.1', '8086');
$database = $client->selectDB('rpc_monitor');
$points = array(
new Point(

View File

@ -28,14 +28,24 @@ class JsonRpcMethod extends JsonRpcBase
public function error($code, $msg)
{
return [
'jsonrpc' => '2.0',
'error' => [
'code' => $code,
'message' => is_array($msg) ? json_encode($msg) : $msg,
],
'id' => $this->id
];
return is_string($msg)
? [
'jsonrpc' => '2.0',
'error' => [
'code' => $code,
'message' => $msg,
],
'id' => $this->id
]
: [
'jsonrpc' => '2.0',
'error' => [
'code' => $code,
'message' => self::ErrorMsg[$code],
'data' => $msg
],
'id' => $this->id
];
}
}