Revert "fix: correct minor typos in disk usage statistic"

This reverts commit aebc257444.
This commit is contained in:
naiba 2021-02-27 18:56:59 +08:00
parent 8cd3612d07
commit 2133973579

View File

@ -35,13 +35,7 @@ func GetHost() *model.Host {
} }
mv, _ := mem.VirtualMemory() mv, _ := mem.VirtualMemory()
ms, _ := mem.SwapMemory() ms, _ := mem.SwapMemory()
u, _ := disk.Partitions(false) u, _ := disk.Usage("/")
var total uint64 = 0
for _, dev := range u {
usage, _ := disk.Usage(dev.Mountpoint)
total += usage.Total
}
fmt.Println(total)
var ip ipDotSbGeoIP var ip ipDotSbGeoIP
resp, err := http.Get("https://api-ipv4.ip.sb/geoip") resp, err := http.Get("https://api-ipv4.ip.sb/geoip")
if err == nil { if err == nil {
@ -60,7 +54,7 @@ func GetHost() *model.Host {
PlatformVersion: hi.PlatformVersion, PlatformVersion: hi.PlatformVersion,
CPU: cpus, CPU: cpus,
MemTotal: mv.Total, MemTotal: mv.Total,
DiskTotal: total, DiskTotal: u.Total,
SwapTotal: ms.Total, SwapTotal: ms.Total,
Arch: hi.KernelArch, Arch: hi.KernelArch,
Virtualization: hi.VirtualizationSystem, Virtualization: hi.VirtualizationSystem,
@ -83,18 +77,13 @@ func GetState(delay int64) *model.HostState {
cpuPercent = cp[0] cpuPercent = cp[0]
} }
// Disk // Disk
u, _ := disk.Partitions(false) u, _ := disk.Usage("/")
var used uint64 = 0
for _, dev := range u {
usage, _ := disk.Usage(dev.Mountpoint)
used += usage.Used
}
return &model.HostState{ return &model.HostState{
CPU: cpuPercent, CPU: cpuPercent,
MemUsed: mv.Used, MemUsed: mv.Used,
SwapUsed: ms.Used, SwapUsed: ms.Used,
DiskUsed: used, DiskUsed: u.Used,
NetInTransfer: atomic.LoadUint64(&netInTransfer), NetInTransfer: atomic.LoadUint64(&netInTransfer),
NetOutTransfer: atomic.LoadUint64(&netOutTransfer), NetOutTransfer: atomic.LoadUint64(&netOutTransfer),
NetInSpeed: atomic.LoadUint64(&netInSpeed), NetInSpeed: atomic.LoadUint64(&netInSpeed),