(cgroupPath string)
| 707 | } |
| 708 | |
| 709 | func readMemoryEvents(cgroupPath string) (*stats.MemoryEvents, error) { |
| 710 | memoryEvents := make(map[string]uint64) |
| 711 | if err := readKVStatsFile(cgroupPath, "memory.events", memoryEvents); err != nil { |
| 712 | if !os.IsNotExist(err) { |
| 713 | return nil, err |
| 714 | } |
| 715 | } |
| 716 | if len(memoryEvents) == 0 { |
| 717 | return nil, nil |
| 718 | } |
| 719 | return &stats.MemoryEvents{ |
| 720 | Low: memoryEvents["low"], |
| 721 | High: memoryEvents["high"], |
| 722 | Max: memoryEvents["max"], |
| 723 | Oom: memoryEvents["oom"], |
| 724 | OomKill: memoryEvents["oom_kill"], |
| 725 | OomGroupKill: memoryEvents["oom_group_kill"], |
| 726 | }, nil |
| 727 | } |
| 728 | |
| 729 | func readKVStatsFile(path string, file string, out map[string]uint64) error { |
| 730 | f, err := os.Open(filepath.Join(path, file)) |
no test coverage detected
searching dependent graphs…