Merge pull request #119 from vishh/fix_network_stats
Minor fixes to network stats
This commit is contained in:
commit
7d3cd408c4
|
@ -9,28 +9,28 @@ import (
|
|||
)
|
||||
|
||||
type NetworkStats struct {
|
||||
RxBytes uint64 `json:"rx_bytes,omitempty"`
|
||||
RxPackets uint64 `json:"rx_packets,omitempty"`
|
||||
RxErrors uint64 `json:"rx_errors,omitempty"`
|
||||
RxDropped uint64 `json:"rx_dropped,omitempty"`
|
||||
TxBytes uint64 `json:"tx_bytes,omitempty"`
|
||||
TxPackets uint64 `json:"tx_packets,omitempty"`
|
||||
TxErrors uint64 `json:"tx_errors,omitempty"`
|
||||
TxDropped uint64 `json:"tx_dropped,omitempty"`
|
||||
RxBytes uint64 `json:"rx_bytes"`
|
||||
RxPackets uint64 `json:"rx_packets"`
|
||||
RxErrors uint64 `json:"rx_errors"`
|
||||
RxDropped uint64 `json:"rx_dropped"`
|
||||
TxBytes uint64 `json:"tx_bytes"`
|
||||
TxPackets uint64 `json:"tx_packets"`
|
||||
TxErrors uint64 `json:"tx_errors"`
|
||||
TxDropped uint64 `json:"tx_dropped"`
|
||||
}
|
||||
|
||||
// Returns the network statistics for the network interfaces represented by the NetworkRuntimeInfo.
|
||||
func GetStats(networkState *NetworkState) (NetworkStats, error) {
|
||||
func GetStats(networkState *NetworkState) (*NetworkStats, error) {
|
||||
// This can happen if the network runtime information is missing - possible if the container was created by an old version of libcontainer.
|
||||
if networkState.VethHost == "" {
|
||||
return NetworkStats{}, nil
|
||||
return &NetworkStats{}, nil
|
||||
}
|
||||
data, err := readSysfsNetworkStats(networkState.VethHost)
|
||||
if err != nil {
|
||||
return NetworkStats{}, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return NetworkStats{
|
||||
return &NetworkStats{
|
||||
RxBytes: data["rx_bytes"],
|
||||
RxPackets: data["rx_packets"],
|
||||
RxErrors: data["rx_errors"],
|
||||
|
|
4
types.go
4
types.go
|
@ -6,6 +6,6 @@ import (
|
|||
)
|
||||
|
||||
type ContainerStats struct {
|
||||
NetworkStats network.NetworkStats `json:"network_stats, omitempty"`
|
||||
CgroupStats *cgroups.Stats `json:"cgroup_stats, omitempty"`
|
||||
NetworkStats *network.NetworkStats `json:"network_stats,omitempty"`
|
||||
CgroupStats *cgroups.Stats `json:"cgroup_stats,omitempty"`
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue