From c3693d00db13e32840dfa9906fcf6ebe4a8ceaea Mon Sep 17 00:00:00 2001 From: Lizandro Guarnizo <77708265+lizandrogd@users.noreply.github.com> Date: Thu, 25 Jun 2026 10:05:58 -0500 Subject: [PATCH] fix: mostrar todos los discos con espacio real incluyendo overlay y tmpfs grandes Co-Authored-By: Claude Sonnet 4.6 --- agent/main.go | 61 ++++++++++++++++++++++++++------------------------- 1 file changed, 31 insertions(+), 30 deletions(-) diff --git a/agent/main.go b/agent/main.go index a3d9f1b..c4309c7 100644 --- a/agent/main.go +++ b/agent/main.go @@ -174,46 +174,47 @@ func collectMetrics() (*Metricas, error) { m.CPU.Porcentaje = round2(pcts[0]) } - // Discos - if parts, err := disk.Partitions(false); err == nil { + // Discos — incluir todo filesystem con espacio real (>100 MB), sin duplicar mountpoints + { gb := 1024.0 * 1024 * 1024 skipFS := map[string]bool{ - "proc": true, "sysfs": true, "tmpfs": true, "devtmpfs": true, - "devpts": true, "cgroup": true, "cgroup2": true, "overlay": true, - "hugetlbfs": true, "mqueue": true, "pstore": true, "securityfs": true, - "debugfs": true, "tracefs": true, "autofs": true, "fusectl": true, - "configfs": true, "efivarfs": true, "bpf": true, "rpc_pipefs": true, - "squashfs": true, "ramfs": true, "nsfs": true, "none": true, + "proc": true, "sysfs": true, "devtmpfs": true, "devpts": true, + "cgroup": true, "cgroup2": true, "hugetlbfs": true, "mqueue": true, + "pstore": true, "securityfs": true, "debugfs": true, "tracefs": true, + "autofs": true, "fusectl": true, "configfs": true, "efivarfs": true, + "bpf": true, "rpc_pipefs": true, "nsfs": true, "ramfs": true, + } + seen := map[string]bool{} + parts, _ := disk.Partitions(true) + // Asegurar que siempre se incluye la raíz + type partEntry struct{ mountpoint, fstype string } + entries := []partEntry{{"/", ""}} + if runtime.GOOS == "windows" { + entries = []partEntry{{"C:\\", ""}} } for _, p := range parts { - if skipFS[p.Fstype] { + entries = append(entries, partEntry{p.Mountpoint, p.Fstype}) + } + for _, e := range entries { + if seen[e.mountpoint] || skipFS[e.fstype] { continue } - if d, err := disk.Usage(p.Mountpoint); err == nil { - m.Discos = append(m.Discos, DiscoInfo{ - TotalGB: round2(float64(d.Total) / gb), - UsadoGB: round2(float64(d.Used) / gb), - LibreGB: round2(float64(d.Free) / gb), - Porcentaje: round2(d.UsedPercent), - Ruta: p.Mountpoint, - }) + d, err := disk.Usage(e.mountpoint) + if err != nil || d.Total == 0 { + continue } - } - } - if len(m.Discos) == 0 { - root := "/" - if runtime.GOOS == "windows" { - root = "C:\\" - } - if d, err := disk.Usage(root); err == nil { - gb := 1024.0 * 1024 * 1024 - m.Discos = []DiscoInfo{{ - TotalGB: round2(float64(d.Total) / gb), + totalGB := float64(d.Total) / gb + if totalGB < 0.1 { // ignorar < 100 MB (tmpfs pequeños, etc.) + continue + } + seen[e.mountpoint] = true + m.Discos = append(m.Discos, DiscoInfo{ + TotalGB: round2(totalGB), UsadoGB: round2(float64(d.Used) / gb), LibreGB: round2(float64(d.Free) / gb), Porcentaje: round2(d.UsedPercent), - Ruta: root, - }} + Ruta: e.mountpoint, + }) } }