[ Agent ] [ init ] - ifx init process to use status module
This commit is contained in:
@@ -227,14 +227,14 @@ func UniformAgentServerInfo(agentServerInfo *register.AgentServerInfo) {
|
|||||||
|
|
||||||
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
|
func BuildAgentOsOperator(agentServerInfo *register.AgentServerInfo) {
|
||||||
|
|
||||||
// 2023年8月4日 passthrough some key information
|
// 2023年8月4日 pass through some key information
|
||||||
ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix")
|
ossOfflinePrefix := g.G.AgentConfig.GetString("octopus.agent.executor.ossOfflinePrefix")
|
||||||
if !strings.HasSuffix(ossOfflinePrefix, "/") {
|
if !strings.HasSuffix(ossOfflinePrefix, "/") {
|
||||||
ossOfflinePrefix += "/"
|
ossOfflinePrefix += "/"
|
||||||
}
|
}
|
||||||
|
|
||||||
// call the init exec function
|
// call the init exec function
|
||||||
agentOsOperator := executor.BuildAgentOsOperator(agentServerInfo.OSInfo, ossOfflinePrefix)
|
agentOsOperator := executor.BuildAgentOsOperator(ossOfflinePrefix)
|
||||||
|
|
||||||
// assign the agentServerInfo
|
// assign the agentServerInfo
|
||||||
agentOsOperator.AgentServerInfo = agentServerInfo
|
agentOsOperator.AgentServerInfo = agentServerInfo
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import (
|
|||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
func BuildAgentOsOperator(osInfo string, ossOfflinePrefix string) *AgentOsOperator {
|
func BuildAgentOsOperator(ossOfflinePrefix string) *AgentOsOperator {
|
||||||
|
|
||||||
AgentOsOperatorCache = &AgentOsOperator{
|
AgentOsOperatorCache = &AgentOsOperator{
|
||||||
InstallCommandPrefix: []string{
|
InstallCommandPrefix: []string{
|
||||||
@@ -15,6 +15,7 @@ func BuildAgentOsOperator(osInfo string, ossOfflinePrefix string) *AgentOsOperat
|
|||||||
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
|
RemoveCommandPrefix: []string{"apt", "remove", "-y"},
|
||||||
CanAccessInternet: true,
|
CanAccessInternet: true,
|
||||||
IsOsTypeUbuntu: true,
|
IsOsTypeUbuntu: true,
|
||||||
|
IsOsTypeCentOS: false,
|
||||||
IsAgentInnerWall: false,
|
IsAgentInnerWall: false,
|
||||||
AgentArch: "amd64",
|
AgentArch: "amd64",
|
||||||
AgentOSReleaseCode: "focal",
|
AgentOSReleaseCode: "focal",
|
||||||
@@ -32,7 +33,7 @@ func BuildAgentOsOperator(osInfo string, ossOfflinePrefix string) *AgentOsOperat
|
|||||||
}
|
}
|
||||||
|
|
||||||
func detectByAgentStatusInfo(os *AgentOsOperator) {
|
func detectByAgentStatusInfo(os *AgentOsOperator) {
|
||||||
agentMetric := status.ReportAgentMetric()
|
agentMetric := status.ReportAgentInfo()
|
||||||
|
|
||||||
if strings.Contains(agentMetric.HostInfo.PlatformFamily, "centos") {
|
if strings.Contains(agentMetric.HostInfo.PlatformFamily, "centos") {
|
||||||
// centos
|
// centos
|
||||||
@@ -48,6 +49,7 @@ func detectByAgentStatusInfo(os *AgentOsOperator) {
|
|||||||
} else if strings.Contains(agentMetric.HostInfo.PlatformFamily, "debian") {
|
} else if strings.Contains(agentMetric.HostInfo.PlatformFamily, "debian") {
|
||||||
// ubuntu
|
// ubuntu
|
||||||
os.IsOsTypeUbuntu = true
|
os.IsOsTypeUbuntu = true
|
||||||
|
os.IsOsTypeCentOS = false
|
||||||
os.RemoveCommandPrefix = []string{"apt", "remove", "-y"}
|
os.RemoveCommandPrefix = []string{"apt", "remove", "-y"}
|
||||||
os.InstallCommandPrefix = []string{
|
os.InstallCommandPrefix = []string{
|
||||||
"apt-get", "install", "--allow-downgrades", "-y",
|
"apt-get", "install", "--allow-downgrades", "-y",
|
||||||
@@ -99,6 +101,35 @@ func judgeAgentCpuArchByKernelArch(kernelArch string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func detectByInternet(os *AgentOsOperator) {
|
||||||
|
|
||||||
|
outsideTestUrl := "www.google.com"
|
||||||
|
innerTestUrl := "www.baidu.com"
|
||||||
|
|
||||||
|
testInternetCommand := []string{
|
||||||
|
"curl",
|
||||||
|
"-o",
|
||||||
|
"/dev/null",
|
||||||
|
"-m",
|
||||||
|
"5",
|
||||||
|
"-s",
|
||||||
|
}
|
||||||
|
|
||||||
|
if PureResultSingleExecute(append(testInternetCommand, outsideTestUrl)) {
|
||||||
|
os.CanAccessInternet = true
|
||||||
|
os.IsAgentInnerWall = false
|
||||||
|
} else if PureResultSingleExecute(append(testInternetCommand, innerTestUrl)) {
|
||||||
|
os.CanAccessInternet = true
|
||||||
|
os.IsAgentInnerWall = true
|
||||||
|
} else {
|
||||||
|
os.CanAccessInternet = false
|
||||||
|
os.IsAgentInnerWall = true
|
||||||
|
}
|
||||||
|
|
||||||
|
log.InfoF("[Agent Network Status] - Can Access Internet => %s Inner CN => %s", strconv.FormatBool(os.CanAccessInternet), strconv.FormatBool(os.IsAgentInnerWall))
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
func detectByOsType(os *AgentOsOperator, osInfo string) {
|
func detectByOsType(os *AgentOsOperator, osInfo string) {
|
||||||
|
|
||||||
ubuntuOsReleaseCode := [][]string{
|
ubuntuOsReleaseCode := [][]string{
|
||||||
@@ -152,32 +183,3 @@ func detectByOsType(os *AgentOsOperator, osInfo string) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func detectByInternet(os *AgentOsOperator) {
|
|
||||||
|
|
||||||
outsideTestUrl := "www.google.com"
|
|
||||||
innerTestUrl := "www.baidu.com"
|
|
||||||
|
|
||||||
testInternetCommand := []string{
|
|
||||||
"curl",
|
|
||||||
"-o",
|
|
||||||
"/dev/null",
|
|
||||||
"-m",
|
|
||||||
"5",
|
|
||||||
"-s",
|
|
||||||
}
|
|
||||||
|
|
||||||
if PureResultSingleExecute(append(testInternetCommand, outsideTestUrl)) {
|
|
||||||
os.CanAccessInternet = true
|
|
||||||
os.IsAgentInnerWall = false
|
|
||||||
} else if PureResultSingleExecute(append(testInternetCommand, innerTestUrl)) {
|
|
||||||
os.CanAccessInternet = true
|
|
||||||
os.IsAgentInnerWall = true
|
|
||||||
} else {
|
|
||||||
os.CanAccessInternet = false
|
|
||||||
os.IsAgentInnerWall = true
|
|
||||||
}
|
|
||||||
|
|
||||||
log.InfoF("[Agent Network Status] - Can Access Internet => %s Inner CN => %s", strconv.FormatBool(os.CanAccessInternet), strconv.FormatBool(os.IsAgentInnerWall))
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|||||||
1283
agent-go/status/tmp/AgentInfo.json
Normal file
1283
agent-go/status/tmp/AgentInfo.json
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user