mirror of
https://github.com/Buriburizaem0n/nezha_domains.git
synced 2026-02-04 12:40:07 +00:00
优化 agent 信息上报与 ARM 安装面板的错误提示
This commit is contained in:
@@ -267,12 +267,14 @@ func doTask(task *pb.Task) {
|
||||
func reportState() {
|
||||
var lastReportHostInfo time.Time
|
||||
var err error
|
||||
var now time.Time
|
||||
defer println("reportState exit", time.Now(), "=>", err)
|
||||
for {
|
||||
now = time.Now()
|
||||
if client != nil {
|
||||
monitor.TrackNetworkSpeed()
|
||||
timeOutCtx, cancel := context.WithTimeout(context.Background(), networkTimeOut)
|
||||
_, err = client.ReportSystemState(timeOutCtx, monitor.GetState(dao.ReportDelay).PB())
|
||||
_, err = client.ReportSystemState(timeOutCtx, monitor.GetState().PB())
|
||||
cancel()
|
||||
if err != nil {
|
||||
println("reportState error", err)
|
||||
@@ -283,6 +285,7 @@ func reportState() {
|
||||
client.ReportSystemInfo(context.Background(), monitor.GetHost().PB())
|
||||
}
|
||||
}
|
||||
time.Sleep(time.Until(now.Add(time.Second)))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -63,12 +63,12 @@ func GetHost() *model.Host {
|
||||
}
|
||||
}
|
||||
|
||||
func GetState(delay int64) *model.HostState {
|
||||
func GetState() *model.HostState {
|
||||
hi, _ := host.Info()
|
||||
mv, _ := mem.VirtualMemory()
|
||||
ms, _ := mem.SwapMemory()
|
||||
var cpuPercent float64
|
||||
cp, err := cpu.Percent(time.Second*time.Duration(delay), false)
|
||||
cp, err := cpu.Percent(0, false)
|
||||
if err == nil {
|
||||
cpuPercent = cp[0]
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user