StatFiltered returns cgroup stats for the specified controllers.
(mask StatMask)
| 583 | |
| 584 | // StatFiltered returns cgroup stats for the specified controllers. |
| 585 | func (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 | |
| 638 | func readCPUStats(cgroupPath string) (*stats.CPUStat, error) { |
| 639 | cpuStat := make(map[string]uint64) |