MCPcopy Create free account
hub / github.com/containerd/cgroups / StatFiltered

Method StatFiltered

cgroup2/manager.go:585–636  ·  view source on GitHub ↗

StatFiltered returns cgroup stats for the specified controllers.

(mask StatMask)

Source from the content-addressed store, hash-verified

583
584// StatFiltered returns cgroup stats for the specified controllers.
585func (c *Manager) StatFiltered(mask StatMask) (*stats.Metrics, error) {
586 var metrics stats.Metrics
587 var err error
588
589 if mask&StatPids != 0 {
590 metrics.Pids = &stats.PidsStat{
591 Current: getStatFileContentUint64(filepath.Join(c.path, "pids.current")),
592 Limit: getStatFileContentUint64(filepath.Join(c.path, "pids.max")),
593 }
594 }
595
596 if mask&StatCPU != 0 {
597 metrics.CPU, err = readCPUStats(c.path)
598 if err != nil {
599 return nil, err
600 }
601 }
602
603 if mask&StatMemory != 0 {
604 metrics.Memory, err = readMemoryStats(c.path)
605 if err != nil {
606 return nil, err
607 }
608 }
609
610 if mask&StatMemoryEvents != 0 {
611 metrics.MemoryEvents, err = readMemoryEvents(c.path)
612 if err != nil {
613 return nil, err
614 }
615 }
616
617 if mask&StatIO != 0 {
618 metrics.Io = &stats.IOStat{
619 Usage: readIoStats(c.path),
620 PSI: getStatPSIFromFile(filepath.Join(c.path, "io.pressure")),
621 }
622 }
623
624 if mask&StatRdma != 0 {
625 metrics.Rdma = &stats.RdmaStat{
626 Current: rdmaStats(filepath.Join(c.path, "rdma.current")),
627 Limit: rdmaStats(filepath.Join(c.path, "rdma.max")),
628 }
629 }
630
631 if mask&StatHugetlb != 0 {
632 metrics.Hugetlb = readHugeTlbStats(c.path)
633 }
634
635 return &metrics, nil
636}
637
638func readCPUStats(cgroupPath string) (*stats.CPUStat, error) {
639 cpuStat := make(map[string]uint64)

Callers 3

TestStatFilteredFunction · 0.95
BenchmarkStatFilteredFunction · 0.95
StatMethod · 0.95

Calls 8

getStatFileContentUint64Function · 0.85
readCPUStatsFunction · 0.85
readMemoryStatsFunction · 0.85
readMemoryEventsFunction · 0.85
readIoStatsFunction · 0.85
getStatPSIFromFileFunction · 0.85
rdmaStatsFunction · 0.85
readHugeTlbStatsFunction · 0.85

Tested by 2

TestStatFilteredFunction · 0.76
BenchmarkStatFilteredFunction · 0.76