* Register host on ZAgent server.
This commit is contained in:
@@ -100,5 +100,6 @@ $lang->zahost->versionList['centos']['7'] = '7';
|
||||
$lang->zahost->versionList['centos']['8'] = '8';
|
||||
|
||||
$lang->zahost->notice = new stdclass();
|
||||
$lang->zahost->notice->ip = '『%s』格式不正确!';
|
||||
$lang->zahost->notice->pingError = '无法连接!请检查IP地址、服务器进程和端口状态。';
|
||||
$lang->zahost->notice->ip = '『%s』格式不正确!';
|
||||
$lang->zahost->notice->pingError = '无法连接!请检查IP地址、服务器进程和端口状态。';
|
||||
$lang->zahost->notice->registerHostError = '向ZAgenteb服务器注册宿主机失败!';
|
||||
|
||||
@@ -53,6 +53,15 @@ class zahostModel extends model
|
||||
$this->dao->update(TABLE_ASSET)->data($hostInfo)->check('name', 'unique');
|
||||
if(dao::isError()) return false;
|
||||
|
||||
$hostInfo->secret = md5(time());
|
||||
/* Register on ZAgent server. */
|
||||
$result = json_decode(commonModel::http("http://{$hostInfo->publicIP}:8086/api/v1/refreshSecret", array('Secret' => $hostInfo->secret), array(CURLOPT_CUSTOMREQUEST => 'POST'), array(), 'json'));
|
||||
if(empty($result) || $result->code != 200)
|
||||
{
|
||||
dao::$errors['publicIP'][] = $this->lang->zahost->notice->registerHostError;
|
||||
return false;
|
||||
}
|
||||
|
||||
$assetInfo['name'] = $hostInfo->name;
|
||||
$assetInfo['type'] = 'zahost';
|
||||
$assetInfo['status'] = 'normal';
|
||||
|
||||
Reference in New Issue
Block a user