MCPcopy
hub / github.com/google/cadvisor / GetStats

Method GetStats

container/docker/handler.go:344–370  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

342}
343
344func (h *containerHandler) GetStats() (*info.ContainerStats, error) {
345 // TODO(vmarmol): Get from libcontainer API instead of cgroup manager when we don't have to support older Dockers.
346 stats, err := h.libcontainerHandler.GetStats()
347 if err != nil {
348 return stats, err
349 }
350
351 // We assume that if Inspect fails then the container is not known to docker.
352 res, err := h.client.ContainerInspect(context.Background(), h.reference.Id, dclient.ContainerInspectOptions{})
353 if err != nil {
354 return nil, fmt.Errorf("failed to inspect container %q: %v", h.reference.Id, err)
355 }
356 ctnr := res.Container
357
358 if ctnr.State.Health != nil {
359 stats.Health.Status = string(ctnr.State.Health.Status)
360 }
361
362 // Get filesystem stats.
363 err = FsStats(stats, h.machineInfoFactory, h.metrics, h.storageDriver,
364 h.fsHandler, h.fsInfo, h.thinPoolName, h.rootfsStorageDir, h.zfsParent)
365 if err != nil {
366 return stats, err
367 }
368
369 return stats, nil
370}
371
372func (h *containerHandler) ListContainers(container.ListType) ([]info.ContainerReference, error) {
373 return []info.ContainerReference{}, nil

Callers

nothing calls this directly

Calls 4

ContainerInspectMethod · 0.80
ErrorfMethod · 0.80
FsStatsFunction · 0.70
GetStatsMethod · 0.65

Tested by

no test coverage detected