From 5f211961ae59f71c600b9590b9fe1a38f538916f Mon Sep 17 00:00:00 2001 From: ssongliu <73214554+ssongliu@users.noreply.github.com> Date: Tue, 18 Nov 2025 17:26:57 +0800 Subject: [PATCH] fix: Fix the issue of abnormal disk display on the overview page (#10986) Refs #10982 --- agent/app/service/dashboard.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/agent/app/service/dashboard.go b/agent/app/service/dashboard.go index 5792c59df..bf6825558 100644 --- a/agent/app/service/dashboard.go +++ b/agent/app/service/dashboard.go @@ -407,10 +407,11 @@ type diskInfo struct { func loadDiskInfo() []dto.DiskInfo { var datas []dto.DiskInfo cmdMgr := cmd.NewCommandMgr(cmd.WithTimeout(2 * time.Second)) - stdout, err := cmdMgr.RunWithStdoutBashC("timeout 2 df -hT -P | awk 'NR>1 && !/tmpfs|snap\\/core|udev/ {print}'") + format := `awk 'NR>1 && !/tmpfs|snap\/core|udev/ {printf "%s\t%s\t%s\t%s\t%s\t%s\t%s\n", $1, $2, $3, $4, $5, $6, $7}'` + stdout, err := cmdMgr.RunWithStdout("bash", "-c", `timeout 2 df -hT -P | `+format) if err != nil { cmdMgr2 := cmd.NewCommandMgr(cmd.WithTimeout(1 * time.Second)) - stdout, err = cmdMgr2.RunWithStdoutBashC("timeout 1 df -lhT -P | awk 'NR>1 && !/tmpfs|snap\\/core|udev/ {print}'") + stdout, err = cmdMgr2.RunWithStdout("bash", "-c", `timeout 1 df -lhT -P | `+format) if err != nil { return datas } @@ -420,7 +421,7 @@ func loadDiskInfo() []dto.DiskInfo { var mounts []diskInfo var excludes = []string{"/mnt/cdrom", "/boot", "/boot/efi", "/dev", "/dev/shm", "/run/lock", "/run", "/run/shm", "/run/user"} for _, line := range lines { - fields := strings.Fields(line) + fields := strings.Split(line, "\t") if len(fields) < 7 { continue }