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])
|
m.CPU.Porcentaje = round2(pcts[0])
|
||||||
}
|
}
|
||||||
|
|
||||||
// Discos
|
// Discos — incluir todo filesystem con espacio real (>100 MB), sin duplicar mountpoints
|
||||||
if parts, err := disk.Partitions(false); err == nil {
|
{
|
||||||
gb := 1024.0 * 1024 * 1024
|
gb := 1024.0 * 1024 * 1024
|
||||||
skipFS := map[string]bool{
|
skipFS := map[string]bool{
|
||||||
"proc": true, "sysfs": true, "tmpfs": true, "devtmpfs": true,
|
"proc": true, "sysfs": true, "devtmpfs": true, "devpts": true,
|
||||||
"devpts": true, "cgroup": true, "cgroup2": true, "overlay": true,
|
"cgroup": true, "cgroup2": true, "hugetlbfs": true, "mqueue": true,
|
||||||
"hugetlbfs": true, "mqueue": true, "pstore": true, "securityfs": true,
|
"pstore": true, "securityfs": true, "debugfs": true, "tracefs": true,
|
||||||
"debugfs": true, "tracefs": true, "autofs": true, "fusectl": true,
|
"autofs": true, "fusectl": true, "configfs": true, "efivarfs": true,
|
||||||
"configfs": true, "efivarfs": true, "bpf": true, "rpc_pipefs": true,
|
"bpf": true, "rpc_pipefs": true, "nsfs": true, "ramfs": true,
|
||||||
"squashfs": true, "ramfs": true, "nsfs": true, "none": 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 {
|
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
|
continue
|
||||||
}
|
}
|
||||||
if d, err := disk.Usage(p.Mountpoint); err == nil {
|
d, err := disk.Usage(e.mountpoint)
|
||||||
m.Discos = append(m.Discos, DiscoInfo{
|
if err != nil || d.Total == 0 {
|
||||||
TotalGB: round2(float64(d.Total) / gb),
|
continue
|
||||||
UsadoGB: round2(float64(d.Used) / gb),
|
|
||||||
LibreGB: round2(float64(d.Free) / gb),
|
|
||||||
Porcentaje: round2(d.UsedPercent),
|
|
||||||
Ruta: p.Mountpoint,
|
|
||||||
})
|
|
||||||
}
|
}
|
||||||
}
|
totalGB := float64(d.Total) / gb
|
||||||
}
|
if totalGB < 0.1 { // ignorar < 100 MB (tmpfs pequeños, etc.)
|
||||||
if len(m.Discos) == 0 {
|
continue
|
||||||
root := "/"
|
}
|
||||||
if runtime.GOOS == "windows" {
|
seen[e.mountpoint] = true
|
||||||
root = "C:\\"
|
m.Discos = append(m.Discos, DiscoInfo{
|
||||||
}
|
TotalGB: round2(totalGB),
|
||||||
if d, err := disk.Usage(root); err == nil {
|
|
||||||
gb := 1024.0 * 1024 * 1024
|
|
||||||
m.Discos = []DiscoInfo{{
|
|
||||||
TotalGB: round2(float64(d.Total) / gb),
|
|
||||||
UsadoGB: round2(float64(d.Used) / gb),
|
UsadoGB: round2(float64(d.Used) / gb),
|
||||||
LibreGB: round2(float64(d.Free) / gb),
|
LibreGB: round2(float64(d.Free) / gb),
|
||||||
Porcentaje: round2(d.UsedPercent),
|
Porcentaje: round2(d.UsedPercent),
|
||||||
Ruta: root,
|
Ruta: e.mountpoint,
|
||||||
}}
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user