From e4262b91b17cc132a35a023865f9ef97a048aa21 Mon Sep 17 00:00:00 2001 From: Florian Koch Date: Fri, 25 Sep 2015 09:04:53 +0200 Subject: [PATCH] move TCP and TCP6 stats to NetworkStats --- container/libcontainer/helpers.go | 4 ++-- info/v1/container.go | 12 ++++-------- info/v2/container.go | 15 ++++++--------- 3 files changed, 12 insertions(+), 19 deletions(-) diff --git a/container/libcontainer/helpers.go b/container/libcontainer/helpers.go index 850ab80d..c5dd244f 100644 --- a/container/libcontainer/helpers.go +++ b/container/libcontainer/helpers.go @@ -102,14 +102,14 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int) (*info.Cont if err != nil { glog.V(2).Infof("Unable to get tcp stats from pid %d: %v", pid, err) } else { - stats.TcpStat.Tcp = t + stats.Network.Tcp = t } t6, err := tcpStatsFromProc(rootFs, pid, "net/tcp6") if err != nil { glog.V(2).Infof("Unable to get tcp6 stats from pid %d: %v", pid, err) } else { - stats.TcpStat.Tcp6 = t6 + stats.Network.Tcp6 = t6 } } diff --git a/info/v1/container.go b/info/v1/container.go index e90e3b92..b4f81388 100644 --- a/info/v1/container.go +++ b/info/v1/container.go @@ -345,6 +345,10 @@ type InterfaceStats struct { type NetworkStats struct { InterfaceStats `json:",inline"` Interfaces []InterfaceStats `json:"interfaces,omitempty"` + // TCP connection stats (Established, Listen...) + Tcp TcpStat `json:"tcp"` + // TCP6 connection stats (Established, Listen...) + Tcp6 TcpStat `json:"tcp6"` } type TcpStat struct { @@ -372,11 +376,6 @@ type TcpStat struct { Closing uint64 } -type TcpStats struct { - Tcp TcpStat `json:"tcp"` - Tcp6 TcpStat `json:"tcp6"` -} - type FsStats struct { // The block device name associated with the filesystem. Device string `json:"device,omitempty"` @@ -459,9 +458,6 @@ type ContainerStats struct { // Task load stats TaskStats LoadStats `json:"task_stats,omitempty"` - //TCP statistics - TcpStat TcpStats `json:"tcpstat,omitempty"` - //Custom metrics from all collectors CustomMetrics map[string][]MetricVal `json:"custom_metrics,omitempty"` } diff --git a/info/v2/container.go b/info/v2/container.go index 9f38e137..3c854260 100644 --- a/info/v2/container.go +++ b/info/v2/container.go @@ -109,8 +109,6 @@ type ContainerStats struct { // Task load statistics HasLoad bool `json:"has_load"` Load v1.LoadStats `json:"load_stats,omitempty"` - //TCP statistics - TcpStat TcpStats `json:"tcpstat,omitempty"` // Custom Metrics HasCustomMetrics bool `json:"has_custom_metrics"` CustomMetrics map[string][]v1.MetricVal `json:"custom_metrics,omitempty"` @@ -208,11 +206,6 @@ type ProcessInfo struct { Cmd string `json:"cmd"` } -type NetworkStats struct { - // Network stats by interface. - Interfaces []v1.InterfaceStats `json:"interfaces,omitempty"` -} - type TcpStat struct { Established uint64 SynSent uint64 @@ -227,8 +220,12 @@ type TcpStat struct { Closing uint64 } -type TcpStats struct { - Tcp TcpStat `json:"tcp"` +type NetworkStats struct { + // Network stats by interface. + Interfaces []v1.InterfaceStats `json:"interfaces,omitempty"` + // TCP connection stats (Established, Listen...) + Tcp TcpStat `json:"tcp"` + // TCP6 connection stats (Established, Listen...) Tcp6 TcpStat `json:"tcp6"` }