Expose network interfaces via runc events
The libcontainer network statistics are unreachable without manually creating a libcontainer instance. To retrieve them via the CLI interface of runc, we now expose them as well. Signed-off-by: Sascha Grunert <sgrunert@suse.com>
This commit is contained in:
parent
c35c2c9cec
commit
41a20b5852
|
@ -163,6 +163,7 @@ func convertLibcontainerStats(ls *libcontainer.Stats) *types.Stats {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
s.NetworkInterfaces = ls.Interfaces
|
||||||
return &s
|
return &s
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -10,6 +10,7 @@ import (
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"github.com/opencontainers/runc/libcontainer/configs"
|
"github.com/opencontainers/runc/libcontainer/configs"
|
||||||
|
"github.com/opencontainers/runc/types"
|
||||||
"github.com/vishvananda/netlink"
|
"github.com/vishvananda/netlink"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -37,8 +38,8 @@ func getStrategy(tpe string) (networkStrategy, error) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// 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 getNetworkInterfaceStats(interfaceName string) (*NetworkInterface, error) {
|
func getNetworkInterfaceStats(interfaceName string) (*types.NetworkInterface, error) {
|
||||||
out := &NetworkInterface{Name: interfaceName}
|
out := &types.NetworkInterface{Name: interfaceName}
|
||||||
// This can happen if the network runtime information is missing - possible if the
|
// This can happen if the network runtime information is missing - possible if the
|
||||||
// container was created by an old version of libcontainer.
|
// container was created by an old version of libcontainer.
|
||||||
if interfaceName == "" {
|
if interfaceName == "" {
|
||||||
|
|
|
@ -1,15 +0,0 @@
|
||||||
package libcontainer
|
|
||||||
|
|
||||||
type NetworkInterface struct {
|
|
||||||
// Name is the name of the network interface.
|
|
||||||
Name string
|
|
||||||
|
|
||||||
RxBytes uint64
|
|
||||||
RxPackets uint64
|
|
||||||
RxErrors uint64
|
|
||||||
RxDropped uint64
|
|
||||||
TxBytes uint64
|
|
||||||
TxPackets uint64
|
|
||||||
TxErrors uint64
|
|
||||||
TxDropped uint64
|
|
||||||
}
|
|
|
@ -1,10 +1,13 @@
|
||||||
package libcontainer
|
package libcontainer
|
||||||
|
|
||||||
import "github.com/opencontainers/runc/libcontainer/cgroups"
|
import (
|
||||||
import "github.com/opencontainers/runc/libcontainer/intelrdt"
|
"github.com/opencontainers/runc/libcontainer/cgroups"
|
||||||
|
"github.com/opencontainers/runc/libcontainer/intelrdt"
|
||||||
|
"github.com/opencontainers/runc/types"
|
||||||
|
)
|
||||||
|
|
||||||
type Stats struct {
|
type Stats struct {
|
||||||
Interfaces []*NetworkInterface
|
Interfaces []*types.NetworkInterface
|
||||||
CgroupStats *cgroups.Stats
|
CgroupStats *cgroups.Stats
|
||||||
IntelRdtStats *intelrdt.Stats
|
IntelRdtStats *intelrdt.Stats
|
||||||
}
|
}
|
||||||
|
|
|
@ -15,6 +15,7 @@ type Stats struct {
|
||||||
Blkio Blkio `json:"blkio"`
|
Blkio Blkio `json:"blkio"`
|
||||||
Hugetlb map[string]Hugetlb `json:"hugetlb"`
|
Hugetlb map[string]Hugetlb `json:"hugetlb"`
|
||||||
IntelRdt IntelRdt `json:"intel_rdt"`
|
IntelRdt IntelRdt `json:"intel_rdt"`
|
||||||
|
NetworkInterfaces []*NetworkInterface `json:"network_interfaces"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type Hugetlb struct {
|
type Hugetlb struct {
|
||||||
|
@ -113,3 +114,17 @@ type IntelRdt struct {
|
||||||
// The memory bandwidth schema in 'container_id' group
|
// The memory bandwidth schema in 'container_id' group
|
||||||
MemBwSchema string `json:"mem_bw_schema,omitempty"`
|
MemBwSchema string `json:"mem_bw_schema,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type NetworkInterface struct {
|
||||||
|
// Name is the name of the network interface.
|
||||||
|
Name string
|
||||||
|
|
||||||
|
RxBytes uint64
|
||||||
|
RxPackets uint64
|
||||||
|
RxErrors uint64
|
||||||
|
RxDropped uint64
|
||||||
|
TxBytes uint64
|
||||||
|
TxPackets uint64
|
||||||
|
TxErrors uint64
|
||||||
|
TxDropped uint64
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue