[ Agent ] [ init ] - add debug feature

This commit is contained in:
zeaslity
2024-01-19 15:51:07 +08:00
parent 2b3dd8a4d8
commit 3d53233211
5 changed files with 32 additions and 7 deletions

View File

@@ -2,6 +2,7 @@ package executor
import (
"agent-go/status"
"encoding/json"
"strconv"
"strings"
)
@@ -33,9 +34,12 @@ func BuildAgentOsOperator(ossOfflinePrefix string) *AgentOsOperator {
}
func detectByAgentStatusInfo(os *AgentOsOperator) {
agentMetric := status.ReportAgentInfo()
agentInfo := status.ReportAgentInfo()
if strings.Contains(agentMetric.HostInfo.PlatformFamily, "centos") {
bytes, _ := json.Marshal(agentInfo)
log.DebugF("[detectByAgentStatusInfo] - agent info is => %s", string(bytes))
if strings.Contains(agentInfo.HostInfo.PlatformFamily, "centos") {
// centos
os.IsOsTypeUbuntu = false
os.IsOsTypeCentOS = true
@@ -46,7 +50,7 @@ func detectByAgentStatusInfo(os *AgentOsOperator) {
"yum", "remove",
}
} else if strings.Contains(agentMetric.HostInfo.PlatformFamily, "debian") {
} else if strings.Contains(agentInfo.HostInfo.PlatformFamily, "debian") {
// ubuntu
os.IsOsTypeUbuntu = true
os.IsOsTypeCentOS = false
@@ -56,11 +60,11 @@ func detectByAgentStatusInfo(os *AgentOsOperator) {
}
// os release code
os.AgentOSReleaseCode = judgeUbuntuReleaseFromOsVersion(agentMetric.HostInfo.PlatformVersion)
os.AgentOSReleaseCode = judgeUbuntuReleaseFromOsVersion(agentInfo.HostInfo.PlatformVersion)
}
// agent cpu arch
os.AgentArch = judgeAgentCpuArchByKernelArch(agentMetric.HostInfo.KernelArch)
os.AgentArch = judgeAgentCpuArchByKernelArch(agentInfo.HostInfo.KernelArch)
}