Initial Proxmox dashboard with host and guest metrics

This commit is contained in:
maxim
2026-07-31 19:51:22 +03:00
commit 584ff7e8ee
21 changed files with 1780 additions and 0 deletions

31
network_test.go Normal file
View File

@@ -0,0 +1,31 @@
package main
import (
"os"
"path/filepath"
"testing"
)
func TestReadNetworkSnapshot(t *testing.T) {
path := filepath.Join(t.TempDir(), "netdev")
content := `Inter-| Receive | Transmit
face |bytes packets errs drop fifo frame compressed multicast|bytes packets errs drop fifo colls carrier compressed
lo: 100 1 0 0 0 0 0 0 100 1 0 0 0 0 0 0
eth0: 1200 2 0 0 0 0 0 0 3400 3 0 0 0 0 0 0
vmbr0: 5600 4 0 0 0 0 0 0 7800 5 0 0 0 0 0 0
`
if err := os.WriteFile(path, []byte(content), 0o600); err != nil {
t.Fatal(err)
}
snapshot, interfaces, err := readNetworkSnapshot(path)
if err != nil {
t.Fatal(err)
}
if snapshot.received != 6800 || snapshot.sent != 11200 {
t.Fatalf("неожиданные сетевые счётчики: %+v", snapshot)
}
if len(interfaces) != 2 {
t.Fatalf("неожиданный список интерфейсов: %v", interfaces)
}
}