[agent-go] - bug fixs

This commit is contained in:
zeaslity
2024-05-08 11:13:45 +08:00
parent e56b9bd65c
commit c8e5184aaa
8 changed files with 45 additions and 15 deletions

View File

@@ -322,9 +322,18 @@ func uniformAgentServerName(agentInfo *a_status.AgentInfo, agentServerInfo *a_ag
var numS string
if agentServerInfo.ServerIPInV4 != "" {
// 使用IP最为Agent的序号代码
split := strings.Split(agentServerInfo.ServerIPInV4, ".")
numS = split[3]
// 归一化长度为 003 123 234
parseInt, err := strconv.ParseInt(numS, 10, 64)
if err != nil {
log.WarnF("parse server ip to int error ! => %v", err)
}
numS = fmt.Sprintf("%03d", parseInt)
} else {
// 没有IP信息随机生成一个
// Seed the random number generator
rand.Seed(time.Now().UnixNano())