From 774529de6dd614757f201e2a5cebaa6acb9db72b Mon Sep 17 00:00:00 2001 From: GoEdgeLab Date: Sat, 8 Jul 2023 18:59:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- internal/nodes/node_status_executor.go | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/internal/nodes/node_status_executor.go b/internal/nodes/node_status_executor.go index 768395d..1cf0593 100644 --- a/internal/nodes/node_status_executor.go +++ b/internal/nodes/node_status_executor.go @@ -13,12 +13,12 @@ import ( "github.com/TeaOSLab/EdgeNode/internal/rpc" "github.com/TeaOSLab/EdgeNode/internal/trackers" "github.com/TeaOSLab/EdgeNode/internal/utils" + fsutils "github.com/TeaOSLab/EdgeNode/internal/utils/fs" "github.com/iwind/TeaGo/lists" "github.com/iwind/TeaGo/maps" "github.com/shirou/gopsutil/v3/cpu" "github.com/shirou/gopsutil/v3/disk" "github.com/shirou/gopsutil/v3/net" - "golang.org/x/sys/unix" "math" "os" "runtime" @@ -279,16 +279,15 @@ func (this *NodeStatusExecutor) updateCacheSpace(status *nodeconfigs.NodeStatus) var result = []maps.Map{} var cachePaths = caches.SharedManager.FindAllCachePaths() for _, path := range cachePaths { - var stat unix.Statfs_t - err := unix.Statfs(path, &stat) + stat, err := fsutils.Stat(path) if err != nil { return } result = append(result, maps.Map{ "path": path, - "total": stat.Blocks * uint64(stat.Bsize), - "avail": stat.Bavail * uint64(stat.Bsize), - "used": (stat.Blocks - stat.Bavail) * uint64(stat.Bsize), + "total": stat.TotalSize(), + "avail": stat.AvailableSize(), + "used": stat.UsedSize(), }) } monitor.SharedValueQueue.Add(nodeconfigs.NodeValueItemCacheDir, maps.Map{