Do not mark any network stats as 'omitempty' since the value '0' is legal for those stats.
Docker-DCO-1.1-Signed-off-by: Vishnu Kannan <vishnuk@google.com> (github: vishh)
This commit is contained in:
parent
2a81a149da
commit
469957ccd7
|
@ -9,21 +9,21 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type NetworkStats struct {
|
type NetworkStats struct {
|
||||||
RxBytes uint64 `json:"rx_bytes,omitempty"`
|
RxBytes uint64 `json:"rx_bytes"`
|
||||||
RxPackets uint64 `json:"rx_packets,omitempty"`
|
RxPackets uint64 `json:"rx_packets"`
|
||||||
RxErrors uint64 `json:"rx_errors,omitempty"`
|
RxErrors uint64 `json:"rx_errors"`
|
||||||
RxDropped uint64 `json:"rx_dropped,omitempty"`
|
RxDropped uint64 `json:"rx_dropped"`
|
||||||
TxBytes uint64 `json:"tx_bytes,omitempty"`
|
TxBytes uint64 `json:"tx_bytes"`
|
||||||
TxPackets uint64 `json:"tx_packets,omitempty"`
|
TxPackets uint64 `json:"tx_packets"`
|
||||||
TxErrors uint64 `json:"tx_errors,omitempty"`
|
TxErrors uint64 `json:"tx_errors"`
|
||||||
TxDropped uint64 `json:"tx_dropped,omitempty"`
|
TxDropped uint64 `json:"tx_dropped"`
|
||||||
}
|
}
|
||||||
|
|
||||||
// Returns the network statistics for the network interfaces represented by the NetworkRuntimeInfo.
|
// 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.
|
// 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 == "" {
|
if networkState.VethHost == "" {
|
||||||
return nil, nil
|
return &NetworkStats{}, nil
|
||||||
}
|
}
|
||||||
data, err := readSysfsNetworkStats(networkState.VethHost)
|
data, err := readSysfsNetworkStats(networkState.VethHost)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
4
types.go
4
types.go
|
@ -6,6 +6,6 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
type ContainerStats struct {
|
type ContainerStats struct {
|
||||||
NetworkStats *network.NetworkStats `json:"network_stats, omitempty"`
|
NetworkStats *network.NetworkStats `json:"network_stats,omitempty"`
|
||||||
CgroupStats *cgroups.Stats `json:"cgroup_stats, omitempty"`
|
CgroupStats *cgroups.Stats `json:"cgroup_stats,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue