From 2133973579223a76df302b61d169851b23ec2798 Mon Sep 17 00:00:00 2001 From: naiba Date: Sat, 27 Feb 2021 18:56:59 +0800 Subject: [PATCH] Revert "fix: correct minor typos in disk usage statistic" This reverts commit aebc257444a1acaf8929096a326d3fdb0ce1c5cc. --- service/monitor/monitor.go | 19 ++++--------------- 1 file changed, 4 insertions(+), 15 deletions(-) diff --git a/service/monitor/monitor.go b/service/monitor/monitor.go index 4453318..16ad4d0 100644 --- a/service/monitor/monitor.go +++ b/service/monitor/monitor.go @@ -35,13 +35,7 @@ func GetHost() *model.Host { } mv, _ := mem.VirtualMemory() ms, _ := mem.SwapMemory() - u, _ := disk.Partitions(false) - var total uint64 = 0 - for _, dev := range u { - usage, _ := disk.Usage(dev.Mountpoint) - total += usage.Total - } - fmt.Println(total) + u, _ := disk.Usage("/") var ip ipDotSbGeoIP resp, err := http.Get("https://api-ipv4.ip.sb/geoip") if err == nil { @@ -60,7 +54,7 @@ func GetHost() *model.Host { PlatformVersion: hi.PlatformVersion, CPU: cpus, MemTotal: mv.Total, - DiskTotal: total, + DiskTotal: u.Total, SwapTotal: ms.Total, Arch: hi.KernelArch, Virtualization: hi.VirtualizationSystem, @@ -83,18 +77,13 @@ func GetState(delay int64) *model.HostState { cpuPercent = cp[0] } // Disk - u, _ := disk.Partitions(false) - var used uint64 = 0 - for _, dev := range u { - usage, _ := disk.Usage(dev.Mountpoint) - used += usage.Used - } + u, _ := disk.Usage("/") return &model.HostState{ CPU: cpuPercent, MemUsed: mv.Used, SwapUsed: ms.Used, - DiskUsed: used, + DiskUsed: u.Used, NetInTransfer: atomic.LoadUint64(&netInTransfer), NetOutTransfer: atomic.LoadUint64(&netOutTransfer), NetInSpeed: atomic.LoadUint64(&netInSpeed),