* Register host on ZAgent server.

This commit is contained in:
wangjianhua
2022-09-14 23:06:12 +08:00
parent 6cefa23025
commit 52dd5894a0
2 changed files with 12 additions and 2 deletions
+3 -2
View File
@@ -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服务器注册宿主机失败!';
+9
View File
@@ -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';