mirror of https://github.com/k3s-io/k3s
commit
57bd9d4289
|
@ -578,93 +578,93 @@
|
|||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/api",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/cache/memory",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/collector",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/container",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/events",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/fs",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/healthz",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/http",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/info/v1",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/info/v2",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/manager",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/metrics",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/pages",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/storage",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/summary",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/utils",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/validate",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/cadvisor/version",
|
||||
"Comment": "v0.22.1",
|
||||
"Rev": "b344feb952c13e0730fa52eb5e5cf1cf7130ee9c"
|
||||
"Comment": "v0.22.2",
|
||||
"Rev": "546a3771589bdb356777c646c6eca24914fdd48b"
|
||||
},
|
||||
{
|
||||
"ImportPath": "github.com/google/gofuzz",
|
||||
|
|
43
Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go
generated
vendored
43
Godeps/_workspace/src/github.com/google/cadvisor/container/libcontainer/helpers.go
generated
vendored
|
@ -92,29 +92,30 @@ func GetStats(cgroupManager cgroups.Manager, rootFs string, pid int, ignoreMetri
|
|||
stats := toContainerStats(libcontainerStats)
|
||||
|
||||
// If we know the pid then get network stats from /proc/<pid>/net/dev
|
||||
if pid > 0 {
|
||||
if !ignoreMetrics.Has(container.NetworkUsageMetrics) {
|
||||
netStats, err := networkStatsFromProc(rootFs, pid)
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Unable to get network stats from pid %d: %v", pid, err)
|
||||
} else {
|
||||
stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...)
|
||||
}
|
||||
if pid == 0 {
|
||||
return stats, nil
|
||||
}
|
||||
if !ignoreMetrics.Has(container.NetworkUsageMetrics) {
|
||||
netStats, err := networkStatsFromProc(rootFs, pid)
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Unable to get network stats from pid %d: %v", pid, err)
|
||||
} else {
|
||||
stats.Network.Interfaces = append(stats.Network.Interfaces, netStats...)
|
||||
}
|
||||
}
|
||||
if !ignoreMetrics.Has(container.NetworkTcpUsageMetrics) {
|
||||
t, err := tcpStatsFromProc(rootFs, pid, "net/tcp")
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Unable to get tcp stats from pid %d: %v", pid, err)
|
||||
} else {
|
||||
stats.Network.Tcp = t
|
||||
}
|
||||
if !ignoreMetrics.Has(container.NetworkTcpUsageMetrics) {
|
||||
t, err := tcpStatsFromProc(rootFs, pid, "net/tcp")
|
||||
if err != nil {
|
||||
glog.V(2).Infof("Unable to get tcp stats from pid %d: %v", pid, err)
|
||||
} else {
|
||||
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.Network.Tcp6 = t6
|
||||
}
|
||||
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.Network.Tcp6 = t6
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -64,6 +64,12 @@ type rawContainerHandler struct {
|
|||
|
||||
// Metrics to be ignored.
|
||||
ignoreMetrics container.MetricSet
|
||||
|
||||
pid int
|
||||
}
|
||||
|
||||
func isRootCgroup(name string) bool {
|
||||
return name == "/"
|
||||
}
|
||||
|
||||
func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSubsystems, machineInfoFactory info.MachineInfoFactory, fsInfo fs.FsInfo, watcher *InotifyWatcher, rootFs string, ignoreMetrics container.MetricSet) (container.ContainerHandler, error) {
|
||||
|
@ -94,6 +100,11 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu
|
|||
}
|
||||
}
|
||||
|
||||
pid := 0
|
||||
if isRootCgroup(name) {
|
||||
pid = 1
|
||||
}
|
||||
|
||||
return &rawContainerHandler{
|
||||
name: name,
|
||||
cgroupSubsystems: cgroupSubsystems,
|
||||
|
@ -106,6 +117,7 @@ func newRawContainerHandler(name string, cgroupSubsystems *libcontainer.CgroupSu
|
|||
watcher: watcher,
|
||||
rootFs: rootFs,
|
||||
ignoreMetrics: ignoreMetrics,
|
||||
pid: pid,
|
||||
}, nil
|
||||
}
|
||||
|
||||
|
@ -150,7 +162,7 @@ func readUInt64(dirpath string, file string) uint64 {
|
|||
|
||||
func (self *rawContainerHandler) GetRootNetworkDevices() ([]info.NetInfo, error) {
|
||||
nd := []info.NetInfo{}
|
||||
if self.name == "/" {
|
||||
if isRootCgroup(self.name) {
|
||||
mi, err := self.machineInfoFactory.GetMachineInfo()
|
||||
if err != nil {
|
||||
return nd, err
|
||||
|
@ -278,7 +290,7 @@ func (self *rawContainerHandler) GetSpec() (info.ContainerSpec, error) {
|
|||
|
||||
func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
||||
// Get Filesystem information only for the root cgroup.
|
||||
if self.name == "/" {
|
||||
if isRootCgroup(self.name) {
|
||||
filesystems, err := self.fsInfo.GetGlobalFsInfo()
|
||||
if err != nil {
|
||||
return err
|
||||
|
@ -341,7 +353,7 @@ func (self *rawContainerHandler) getFsStats(stats *info.ContainerStats) error {
|
|||
}
|
||||
|
||||
func (self *rawContainerHandler) GetStats() (*info.ContainerStats, error) {
|
||||
stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, os.Getpid(), self.ignoreMetrics)
|
||||
stats, err := libcontainer.GetStats(self.cgroupManager, self.rootFs, self.pid, self.ignoreMetrics)
|
||||
if err != nil {
|
||||
return stats, err
|
||||
}
|
||||
|
|
|
@ -50,42 +50,6 @@ var eventStorageAgeLimit = flag.String("event_storage_age_limit", "default=24h",
|
|||
var eventStorageEventLimit = flag.String("event_storage_event_limit", "default=100000", "Max number of events to store (per type). Value is a comma separated list of key values, where the keys are event types (e.g.: creation, oom) or \"default\" and the value is an integer. Default is applied to all non-specified event types")
|
||||
var applicationMetricsCountLimit = flag.Int("application_metrics_count_limit", 100, "Max number of application metrics to store (per container)")
|
||||
|
||||
var (
|
||||
// Metrics to be ignored.
|
||||
ignoreMetrics metricSetValue = metricSetValue{container.MetricSet{}}
|
||||
// List of metrics that can be ignored.
|
||||
ignoreWhitelist = container.MetricSet{
|
||||
container.DiskUsageMetrics: struct{}{},
|
||||
container.NetworkUsageMetrics: struct{}{},
|
||||
container.NetworkTcpUsageMetrics: struct{}{},
|
||||
}
|
||||
)
|
||||
|
||||
func init() {
|
||||
flag.Var(&ignoreMetrics, "disable_metrics", "comma-separated list of metrics to be disabled. Options are `disk`, `network`, `tcp`. Note: tcp is disabled by default due to high CPU usage.")
|
||||
// Tcp metrics are ignored by default.
|
||||
flag.Set("disable_metrics", "tcp")
|
||||
}
|
||||
|
||||
type metricSetValue struct {
|
||||
container.MetricSet
|
||||
}
|
||||
|
||||
func (ml *metricSetValue) String() string {
|
||||
return fmt.Sprint(*ml)
|
||||
}
|
||||
|
||||
func (ml *metricSetValue) Set(value string) error {
|
||||
for _, metric := range strings.Split(value, ",") {
|
||||
if ignoreWhitelist.Has(container.MetricKind(metric)) {
|
||||
(*ml).Add(container.MetricKind(metric))
|
||||
} else {
|
||||
return fmt.Errorf("unsupported metric %q specified in disable_metrics", metric)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// The Manager interface defines operations for starting a manager and getting
|
||||
// container and machine information.
|
||||
type Manager interface {
|
||||
|
@ -155,7 +119,7 @@ type Manager interface {
|
|||
}
|
||||
|
||||
// New takes a memory storage and returns a new manager.
|
||||
func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingInterval time.Duration, allowDynamicHousekeeping bool) (Manager, error) {
|
||||
func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingInterval time.Duration, allowDynamicHousekeeping bool, ignoreMetricsSet container.MetricSet) (Manager, error) {
|
||||
if memoryCache == nil {
|
||||
return nil, fmt.Errorf("manager requires memory storage")
|
||||
}
|
||||
|
@ -194,7 +158,7 @@ func New(memoryCache *memory.InMemoryCache, sysfs sysfs.SysFs, maxHousekeepingIn
|
|||
startupTime: time.Now(),
|
||||
maxHousekeepingInterval: maxHousekeepingInterval,
|
||||
allowDynamicHousekeeping: allowDynamicHousekeeping,
|
||||
ignoreMetrics: ignoreMetrics.MetricSet,
|
||||
ignoreMetrics: ignoreMetricsSet,
|
||||
}
|
||||
|
||||
machineInfo, err := getMachineInfo(sysfs, fsInfo, inHostNamespace)
|
||||
|
|
|
@ -27,6 +27,7 @@ import (
|
|||
|
||||
"github.com/golang/glog"
|
||||
"github.com/google/cadvisor/cache/memory"
|
||||
cadvisorMetrics "github.com/google/cadvisor/container"
|
||||
"github.com/google/cadvisor/events"
|
||||
cadvisorfs "github.com/google/cadvisor/fs"
|
||||
cadvisorhttp "github.com/google/cadvisor/http"
|
||||
|
@ -66,7 +67,7 @@ func New(port uint) (Interface, error) {
|
|||
}
|
||||
|
||||
// Create and start the cAdvisor container manager.
|
||||
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping)
|
||||
m, err := manager.New(memory.New(statsCacheDuration, nil), sysFs, maxHousekeepingInterval, allowDynamicHousekeeping, cadvisorMetrics.MetricSet{cadvisorMetrics.NetworkTcpUsageMetrics: struct{}{}})
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue