vendor: cadvisor v0.38.4

This commit is contained in:
David Porter
2020-11-13 19:52:57 +00:00
parent ec734aced7
commit 8af7405f17
396 changed files with 73154 additions and 18510 deletions

View File

@@ -23,48 +23,44 @@ import (
info "github.com/google/cadvisor/info/v1"
"github.com/google/cadvisor/stats"
"github.com/google/cadvisor/utils/sysinfo"
)
type manager struct {
events PerfEvents
numCores int
topology []info.Node
events PerfEvents
onlineCPUs []int
cpuToSocket map[int]int
stats.NoopDestroy
}
func NewManager(configFile string, numCores int, topology []info.Node) (stats.Manager, error) {
func NewManager(configFile string, topology []info.Node) (stats.Manager, error) {
if configFile == "" {
return &stats.NoopManager{}, nil
}
file, err := os.Open(configFile)
if err != nil {
return nil, fmt.Errorf("Unable to read configuration file %q: %q", configFile, err)
return nil, fmt.Errorf("unable to read configuration file %q: %w", configFile, err)
}
config, err := parseConfig(file)
if err != nil {
return nil, fmt.Errorf("Unable to read configuration file %q: %q", configFile, err)
return nil, fmt.Errorf("unable to parse configuration file %q: %w", configFile, err)
}
if areGroupedEventsUsed(config) {
return nil, fmt.Errorf("event grouping is not supported you must modify config file at %s", configFile)
onlineCPUs := sysinfo.GetOnlineCPUs(topology)
cpuToSocket := make(map[int]int)
for _, cpu := range onlineCPUs {
cpuToSocket[cpu] = sysinfo.GetSocketFromCPU(topology, cpu)
}
return &manager{events: config, numCores: numCores, topology: topology}, nil
}
func areGroupedEventsUsed(events PerfEvents) bool {
for _, group := range events.Core.Events {
if len(group) > 1 {
return true
}
}
return false
return &manager{events: config, onlineCPUs: onlineCPUs, cpuToSocket: cpuToSocket}, nil
}
func (m *manager) GetCollector(cgroupPath string) (stats.Collector, error) {
collector := newCollector(cgroupPath, m.events, m.numCores, m.topology)
collector := newCollector(cgroupPath, m.events, m.onlineCPUs, m.cpuToSocket)
err := collector.setup()
if err != nil {
collector.Destroy()