[Agent] [Status] add host info to agent status
This commit is contained in:
@@ -1,25 +1,16 @@
|
||||
package status
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"agent-go/utils"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestGetHostInfo(t *testing.T) {
|
||||
|
||||
hostInfo := HostInfo{}
|
||||
|
||||
fmt.Printf("host info is %v\n", hostInfo)
|
||||
fmt.Printf("host info type is %T\n", hostInfo)
|
||||
fmt.Printf("host info address is %p\n", &hostInfo)
|
||||
|
||||
fmt.Println()
|
||||
|
||||
info, err := GetHostInfo()
|
||||
if err != nil {
|
||||
t.Errorf("get host info error is %v", err)
|
||||
}
|
||||
|
||||
fmt.Printf("get host info is %v\n", info)
|
||||
fmt.Printf("get host info address is %p\n", &info)
|
||||
utils.BeautifulPrint(info)
|
||||
}
|
||||
|
||||
@@ -27,6 +27,7 @@ type AgentMetric struct {
|
||||
MemoryMetric *MemoryMetric
|
||||
NetworkMetric []NetworkMetric
|
||||
DiskInfo []DiskInfo
|
||||
HostInfo *HostInfo
|
||||
DockerMetric *DockerMetric
|
||||
}
|
||||
|
||||
@@ -36,7 +37,7 @@ func Ping() string {
|
||||
|
||||
func ReportAgentMetric() *AgentMetric {
|
||||
|
||||
lenOfAgentMetric := 5
|
||||
lenOfAgentMetric := 6
|
||||
waitResultChan := make(chan string, lenOfAgentMetric)
|
||||
timeout := time.After(5 * time.Second)
|
||||
var err error
|
||||
@@ -80,6 +81,19 @@ func ReportAgentMetric() *AgentMetric {
|
||||
log.ErrorF("[ReportAgentMetric] - GetDiskInfo exec error => %v", err)
|
||||
}
|
||||
|
||||
var hostInfo *HostInfo
|
||||
err = pool.Submit(func() {
|
||||
hostInfo, err = GetHostInfo()
|
||||
if err != nil {
|
||||
log.ErrorF("获取Agent的状态出现错误! 请检查 => %v", err)
|
||||
waitResultChan <- "GetHostInfo error !"
|
||||
}
|
||||
waitResultChan <- "hostInfo success !"
|
||||
})
|
||||
if err != nil {
|
||||
log.ErrorF("[ReportAgentMetric] - hostInfo exec error => %v", err)
|
||||
}
|
||||
|
||||
var networkMetric []NetworkMetric
|
||||
err = pool.Submit(func() {
|
||||
networkMetric, err = GetNetworkMetric()
|
||||
@@ -120,6 +134,7 @@ func ReportAgentMetric() *AgentMetric {
|
||||
MemoryMetric: memoryMetric,
|
||||
NetworkMetric: networkMetric,
|
||||
DiskInfo: diskInfoList,
|
||||
HostInfo: hostInfo,
|
||||
DockerMetric: dockerMetric,
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user