fix: mostrar todos los discos con espacio real incluyendo overlay y tmpfs grandes
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
00d1e6121b
commit
c3693d00db
+31
-30
@@ -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,
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user