From 245fc451608fe1b875ae82c0f465c56d54a6f3a0 Mon Sep 17 00:00:00 2001 From: Akizon77 Date: Sat, 6 Sep 2025 04:25:19 +0000 Subject: [PATCH] =?UTF-8?q?feat:=20=E6=9B=B4=E6=96=B0=E7=A3=81=E7=9B=98?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=8E=B7=E5=8F=96=E9=80=BB=E8=BE=91=EF=BC=8C?= =?UTF-8?q?=E6=94=AF=E6=8C=81=E7=89=A9=E7=90=86=E5=88=86=E5=8C=BA=E5=92=8C?= =?UTF-8?q?=E6=96=87=E4=BB=B6=E7=B3=BB=E7=BB=9F=E7=B1=BB=E5=9E=8B=E6=98=BE?= =?UTF-8?q?=E7=A4=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitoring/unit/disk.go | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/monitoring/unit/disk.go b/monitoring/unit/disk.go index c41092c..6bd01dd 100644 --- a/monitoring/unit/disk.go +++ b/monitoring/unit/disk.go @@ -1,6 +1,7 @@ package monitoring import ( + "fmt" "strings" "github.com/komari-monitor/komari-agent/cmd/flags" @@ -14,7 +15,7 @@ type DiskInfo struct { func Disk() DiskInfo { diskinfo := DiskInfo{} - usage, err := disk.Partitions(false) // 使用 false 只获取物理分区 + usage, err := disk.Partitions(true) if err != nil { diskinfo.Total = 0 diskinfo.Used = 0 @@ -69,6 +70,13 @@ func isPhysicalDisk(part disk.PartitionStat) bool { "/run/user", "/var/lib/containers", "/var/lib/docker", + "/proc", + "/dev/pts", + "/sys", + "/sys/fs/cgroup", + "/dev/mqueue", + "/etc/resolv.conf", + "/etc/host", // /etc/hosts,/etc/hostname } for _, mp := range mountpointsToExclude { if mountpoint == mp || strings.HasPrefix(mountpoint, mp) { @@ -87,6 +95,11 @@ func isPhysicalDisk(part disk.PartitionStat) bool { "9p", "fuse", "overlay", + "proc", + "devpts", + "sysfs", + "cgroup", + "mqueue", } for _, fs := range fstypeToExclude { if fstype == fs || strings.HasPrefix(fstype, fs) { @@ -119,13 +132,13 @@ func DiskList() ([]string, error) { } } } else { - usage, err := disk.Partitions(false) + usage, err := disk.Partitions(true) if err != nil { return nil, err } for _, part := range usage { if isPhysicalDisk(part) { - diskList = append(diskList, part.Mountpoint) + diskList = append(diskList, fmt.Sprintf("%s (%s)", part.Mountpoint, part.Fstype)) } } }