|
|
@ -16,6 +16,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
namespace DtApp\ThinkLibrary\service\bt;
|
|
|
|
namespace DtApp\ThinkLibrary\service\bt;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
use DtApp\ThinkLibrary\exception\BtException;
|
|
|
|
use DtApp\ThinkLibrary\exception\CurlException;
|
|
|
|
use DtApp\ThinkLibrary\exception\CurlException;
|
|
|
|
use DtApp\ThinkLibrary\Service;
|
|
|
|
use DtApp\ThinkLibrary\Service;
|
|
|
|
use DtApp\ThinkLibrary\service\Curl\BtService;
|
|
|
|
use DtApp\ThinkLibrary\service\Curl\BtService;
|
|
|
@ -49,6 +50,17 @@ class ApiService extends Service
|
|
|
|
return $this;
|
|
|
|
return $this;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* 获取配置信息
|
|
|
|
|
|
|
|
* @return $this
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
private function getConfig()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
$this->key = config('dtapp.bt.key');
|
|
|
|
|
|
|
|
$this->panel = config('dtapp.bt.panel');
|
|
|
|
|
|
|
|
return $this;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 获取监控信息
|
|
|
|
* 获取监控信息
|
|
|
|
* @param string $type 类型 GetCpuIo = CPU信息/内存 GetDiskIo = 磁盘IO GetNetWorkIo = 网络IO
|
|
|
|
* @param string $type 类型 GetCpuIo = CPU信息/内存 GetDiskIo = 磁盘IO GetNetWorkIo = 网络IO
|
|
|
@ -317,7 +329,7 @@ class ApiService extends Service
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* 发起网络请求
|
|
|
|
* 发起网络请求
|
|
|
|
* @return $this
|
|
|
|
* @return $this
|
|
|
|
* @throws CurlException
|
|
|
|
* @throws CurlException|BtException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private function getHttp()
|
|
|
|
private function getHttp()
|
|
|
|
{
|
|
|
|
{
|
|
|
@ -365,10 +377,12 @@ class ApiService extends Service
|
|
|
|
* @param array $data 数据
|
|
|
|
* @param array $data 数据
|
|
|
|
* @param bool $is_json 是否返回Json格式
|
|
|
|
* @param bool $is_json 是否返回Json格式
|
|
|
|
* @return bool|mixed|string
|
|
|
|
* @return bool|mixed|string
|
|
|
|
* @throws CurlException
|
|
|
|
* @throws CurlException|BtException
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
protected function HttpPostCookie(string $url, array $data = [], bool $is_json = true)
|
|
|
|
protected function HttpPostCookie(string $url, array $data = [], bool $is_json = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
if (empty($this->panel)) $this->getConfig();
|
|
|
|
|
|
|
|
if (empty($this->panel)) throw new BtException('请检查panel参数');
|
|
|
|
//定义cookie保存位置
|
|
|
|
//定义cookie保存位置
|
|
|
|
$file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/';
|
|
|
|
$file = app()->getRootPath() . 'runtime/dtapp/bt/cookie/';
|
|
|
|
$cookie_file = $file . md5($this->panel) . '.cookie';
|
|
|
|
$cookie_file = $file . md5($this->panel) . '.cookie';
|
|
|
@ -377,6 +391,8 @@ class ApiService extends Service
|
|
|
|
$fp = fopen($cookie_file, 'w+');
|
|
|
|
$fp = fopen($cookie_file, 'w+');
|
|
|
|
fclose($fp);
|
|
|
|
fclose($fp);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (empty($this->key)) $this->getConfig();
|
|
|
|
|
|
|
|
if (empty($this->key)) throw new BtException('请检查key参数');
|
|
|
|
return BtService::instance()
|
|
|
|
return BtService::instance()
|
|
|
|
->panel($this->panel)
|
|
|
|
->panel($this->panel)
|
|
|
|
->key($this->key)
|
|
|
|
->key($this->key)
|
|
|
|