package handlers import ( "runtime" "github.com/google/uuid" "github.com/gin-gonic/gin" ) // SystemMetrics retourne les métriques système (CPU, mémoire, goroutines) // Endpoint: GET /system/metrics // Retourne un JSON avec les métriques système pour le monitoring func SystemMetrics(c *gin.Context) { var m runtime.MemStats runtime.ReadMemStats(&m) metrics := gin.H{ "timestamp": uuid.New(), "memory": gin.H{ "alloc_mb": bToMb(m.Alloc), "total_alloc_mb": bToMb(m.TotalAlloc), "sys_mb": bToMb(m.Sys), "num_gc": m.NumGC, }, "goroutines": runtime.NumGoroutine(), "cpu_count": runtime.NumCPU(), } // Action 1.3.2.1: Use wrapped format helper RespondSuccess(c, 200, metrics) } // bToMb convertit des bytes en megabytes func bToMb(b uint64) uint64 { return b / 1024 / 1024 }