in metric/system/cgroup/cgv2/memory.go [170:211]
func memoryData(path, file string) (MemoryData, error) {
// root cgroups won't have these files.
// If .high doesn't exist, assume the rest don't either.
_, err := os.Stat(filepath.Join(path, file+".high"))
if errors.Is(err, os.ErrNotExist) {
return MemoryData{}, nil
}
data := MemoryData{}
// High and max can be set to "max", which means "off"
lowMetric, err := cgcommon.ParseUintFromFile(filepath.Join(path, file+".low"))
if err != nil {
return data, fmt.Errorf("error reading %s.low file: %w", file, err)
}
highMetric, err := maxOrValue(path, file+".high")
if err != nil {
return data, fmt.Errorf("error parsing %s.high file: %w", file, err)
}
maxMetric, err := maxOrValue(path, file+".max")
if err != nil {
return data, fmt.Errorf("error parsing %s.max file: %w", file, err)
}
currentMetric, err := cgcommon.ParseUintFromFile(filepath.Join(path, file+".current"))
if err != nil {
return data, fmt.Errorf("error reading %s.current file: %w", file, err)
}
data.Low.Bytes = lowMetric
data.High.Bytes = highMetric
data.Max.Bytes = maxMetric
data.Usage.Bytes = currentMetric
data.Events, err = fetchEventsFile(path, file+".events")
if err != nil {
return data, fmt.Errorf("error fetching events file for %s: %w", file, err)
}
return data, nil
}