func setIfaceStatsFromMap(stats *wrapper.NetworkInterface, values map[string]uint64) { stats.RxBytes = values["rx_bytes"] stats.RxErrors = values["rx_errors"] stats.RxPackets = values["rx_packets"] stats.RxDropped = values["rx_dropped"] stats.TxBytes = values["tx_bytes"] stats.TxErrors = values["tx_errors"] stats.TxPackets = values["tx_packets"] stats.TxDropped = values["tx_dropped"] }
// totalNetworkStats calculates summary of network stats (sum over all net interfaces) and returns func totalNetworkStats(ifaceStats []wrapper.NetworkInterface) (ifaceStatsInTotal []wrapper.NetworkInterface) { total := wrapper.NetworkInterface{ Name: "total", } for _, iface := range ifaceStats { total.RxBytes += iface.RxBytes total.RxPackets += iface.RxPackets total.RxDropped += iface.RxDropped total.RxErrors += iface.RxErrors total.TxBytes += iface.TxBytes total.TxPackets += iface.TxPackets total.TxDropped += iface.TxDropped total.TxErrors += iface.TxErrors } return append(ifaceStats, total) }