[ Agent ] [ Base ] - add support for centos/openeuler ; todo chronyToMasterExec centos

This commit is contained in:
zeaslity
2024-01-19 18:34:36 +08:00
parent 7b57a2a422
commit 42dee262cf
7 changed files with 290 additions and 128 deletions

View File

@@ -5,6 +5,7 @@ import (
"agent-go/g"
"agent-go/rabbitmq"
"agent-go/register"
"agent-go/status"
"encoding/json"
"fmt"
"gopkg.in/yaml.v3"
@@ -24,6 +25,13 @@ func INIT(agentServerInfoConf string) chan bool {
// 获取系统的环境变量
agentServerInfo := parseAgentServerInfo(agentServerInfoConf)
// re-get agentInfo from status module
agentInfo := status.ReportAgentInfo()
refreshAgentInfoByStatusInfo(agentInfo, agentServerInfo)
// build operator cache
BuildAgentOsOperator(agentInfo, agentServerInfo)
// 缓存此内容
//AgentServerInfoCache = agentServerInfo
@@ -95,6 +103,17 @@ func INIT(agentServerInfoConf string) chan bool {
return businessForeverChan
}
func refreshAgentInfoByStatusInfo(agentInfo *status.AgentInfo, agentServerInfo *register.AgentServerInfo) {
agentServerInfo.Platform = agentInfo.HostInfo.Platform
agentServerInfo.PlatformFamily = agentInfo.HostInfo.PlatformFamily
agentServerInfo.PlatformVersion = agentInfo.HostInfo.PlatformVersion
agentServerInfo.KernelVersion = agentInfo.HostInfo.KernelVersion
agentServerInfo.KernelArch = agentInfo.HostInfo.KernelArch
log.DebugF("[refreshAgentInfoByStatusInfo] - ok !")
}
// handleInitMsgFromServer 处理从Server接收的 注册信息
func handleInitMsgFromServer(initFromServerQueue *rabbitmq.RabbitQueue, initToServerQueue *rabbitmq.RabbitQueue, agentServerInfo *register.AgentServerInfo) chan bool {
@@ -187,9 +206,6 @@ func parseAgentServerInfo(agentServerInfoConf string) *register.AgentServerInfo
// uniform agent server info
UniformAgentServerInfo(agentServerInfo)
// build operator cache
BuildAgentOsOperator(agentServerInfo)
jsonFormat, err := json.Marshal(&agentServerInfo)
if err != nil {
log.Error(fmt.Sprintf("agent server info convert error ! agentserverinfo is %v", agentServerInfo))
@@ -225,7 +241,7 @@ func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) {
}
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
func BuildAgentOsOperator(agentInfo *status.AgentInfo, agentServerInfo *register.AgentServerInfo) {
// 2023年8月4日 pass through some key information
ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix")
@@ -234,7 +250,7 @@ func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
}
// call the init exec function
agentOsOperator := executor.BuildAgentOsOperator(ossOfflinePrefix)
agentOsOperator := executor.BuildAgentOsOperator(agentInfo, ossOfflinePrefix)
// assign the agentServerInfo
agentOsOperator.AgentServerInfo = agentServerInfo