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