MCPcopy Index your code
hub / github.com/PasarGuard/node / SystemStats

Method SystemStats

controller/controller.go:200–232  ·  view source on GitHub ↗
(ctx context.Context)

Source from the content-addressed store, hash-verified

198}
199
200func (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
234func (c *Controller) BaseInfoResponse() *common.BaseInfoResponse {
235 c.mu.Lock()

Callers 2

GetSystemStatsMethod · 0.80
GetSystemStatsMethod · 0.80

Calls 8

GetMemTotalMethod · 0.80
GetMemUsedMethod · 0.80
GetCpuCoresMethod · 0.80
GetCpuUsageMethod · 0.80
GetSysStatsMethod · 0.65
GetUptimeMethod · 0.45

Tested by

no test coverage detected