(ctx context.Context)
| 198 | } |
| 199 | |
| 200 | func (c *Controller) SystemStats(ctx context.Context) *common.SystemStatsResponse { |
| 201 | c.mu.RLock() |
| 202 | statsSnapshot := c.stats |
| 203 | backendSnapshot := c.backend |
| 204 | c.mu.RUnlock() |
| 205 | |
| 206 | response := &common.SystemStatsResponse{} |
| 207 | if statsSnapshot != nil { |
| 208 | response = &common.SystemStatsResponse{ |
| 209 | MemTotal: statsSnapshot.GetMemTotal(), |
| 210 | MemUsed: statsSnapshot.GetMemUsed(), |
| 211 | CpuCores: statsSnapshot.GetCpuCores(), |
| 212 | CpuUsage: statsSnapshot.GetCpuUsage(), |
| 213 | IncomingBandwidthSpeed: statsSnapshot.GetIncomingBandwidthSpeed(), |
| 214 | OutgoingBandwidthSpeed: statsSnapshot.GetOutgoingBandwidthSpeed(), |
| 215 | Uptime: statsSnapshot.GetUptime(), |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | if backendSnapshot == nil { |
| 220 | return response |
| 221 | } |
| 222 | |
| 223 | // Backend uptime is owned by each backend implementation; controller only forwards it here. |
| 224 | backendStats, err := backendSnapshot.GetSysStats(ctx) |
| 225 | if err != nil { |
| 226 | log.Printf("Failed to get backend uptime for system stats: %v", err) |
| 227 | return response |
| 228 | } |
| 229 | |
| 230 | response.Uptime = uint64(backendStats.GetUptime()) |
| 231 | return response |
| 232 | } |
| 233 | |
| 234 | func (c *Controller) BaseInfoResponse() *common.BaseInfoResponse { |
| 235 | c.mu.Lock() |
no test coverage detected