stremio/node/media-node/internal/health/health.go
Jos Vooges | STH a5c6fd5fe4 Initial commit: Distributed Stremio Media Cluster V1
Master API, Admin UI, Go media-node, Docker/Dokploy deploy configs.

Co-authored-by: Cursor <cursoragent@cursor.com>
2026-08-25 00:17:04 +02:00

46 lines
806 B
Go

package health
import (
"path/filepath"
"runtime"
)
type Snapshot struct {
UptimeSeconds int64
CPUUsagePercent float64
MemoryUsagePercent float64
StorageTotalBytes uint64
StorageFreeBytes uint64
LibraryFileCount int
ActiveStreams int
CurrentBytesPerSec int64
ScanStatus string
Errors []string
}
func MemoryUsagePercent() float64 {
var m runtime.MemStats
runtime.ReadMemStats(&m)
if m.Sys == 0 {
return 0
}
return float64(m.Alloc) / float64(m.Sys) * 100
}
func DiskUsage(paths []string) (total, free uint64) {
seen := map[string]bool{}
for _, p := range paths {
if p == "" {
continue
}
key := filepath.Clean(p)
if seen[key] {
continue
}
seen[key] = true
t, f := diskStat(p)
total += t
free += f
}
return total, free
}