MCPcopy Create free account
hub / github.com/PasarGuard/node / GetInterfaceStats

Method GetInterfaceStats

backend/wireguard/manager.go:301–317  ·  view source on GitHub ↗

GetInterfaceStats returns RX/TX statistics for the interface

()

Source from the content-addressed store, hash-verified

299
300// GetInterfaceStats returns RX/TX statistics for the interface
301func (m *Manager) GetInterfaceStats() (rxBytes, txBytes int64, err error) {
302 m.mu.RLock()
303 defer m.mu.RUnlock()
304
305 nl := m.getNetlinkOps()
306 link, err := nl.LinkByName(m.iFaceName)
307 if err != nil {
308 return 0, 0, fmt.Errorf("failed to get link: %w", err)
309 }
310
311 stats := link.Attrs().Statistics
312 if stats == nil {
313 return 0, 0, nil
314 }
315
316 return int64(stats.RxBytes), int64(stats.TxBytes), nil
317}

Callers 2

getInterfaceCountersMethod · 0.80
GetSysStatsMethod · 0.80

Calls 2

getNetlinkOpsMethod · 0.95
LinkByNameMethod · 0.65

Tested by

no test coverage detected