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

Method parseStats

cgroup1/memory.go:319–369  ·  view source on GitHub ↗
(r io.Reader, stat *v1.MemoryStat)

Source from the content-addressed store, hash-verified

317}
318
319func (m *memoryController) parseStats(r io.Reader, stat *v1.MemoryStat) error {
320 var (
321 raw = make(map[string]uint64)
322 sc = bufio.NewScanner(r)
323 line int
324 )
325 for sc.Scan() {
326 key, v, err := parseKV(sc.Text())
327 if err != nil {
328 return fmt.Errorf("%d: %v", line, err)
329 }
330 raw[key] = v
331 line++
332 }
333 if err := sc.Err(); err != nil {
334 return err
335 }
336 stat.Cache = raw["cache"]
337 stat.RSS = raw["rss"]
338 stat.RSSHuge = raw["rss_huge"]
339 stat.MappedFile = raw["mapped_file"]
340 stat.Dirty = raw["dirty"]
341 stat.Writeback = raw["writeback"]
342 stat.PgPgIn = raw["pgpgin"]
343 stat.PgPgOut = raw["pgpgout"]
344 stat.PgFault = raw["pgfault"]
345 stat.PgMajFault = raw["pgmajfault"]
346 stat.InactiveAnon = raw["inactive_anon"]
347 stat.ActiveAnon = raw["active_anon"]
348 stat.InactiveFile = raw["inactive_file"]
349 stat.ActiveFile = raw["active_file"]
350 stat.Unevictable = raw["unevictable"]
351 stat.HierarchicalMemoryLimit = raw["hierarchical_memory_limit"]
352 stat.HierarchicalSwapLimit = raw["hierarchical_memsw_limit"]
353 stat.TotalCache = raw["total_cache"]
354 stat.TotalRSS = raw["total_rss"]
355 stat.TotalRSSHuge = raw["total_rss_huge"]
356 stat.TotalMappedFile = raw["total_mapped_file"]
357 stat.TotalDirty = raw["total_dirty"]
358 stat.TotalWriteback = raw["total_writeback"]
359 stat.TotalPgPgIn = raw["total_pgpgin"]
360 stat.TotalPgPgOut = raw["total_pgpgout"]
361 stat.TotalPgFault = raw["total_pgfault"]
362 stat.TotalPgMajFault = raw["total_pgmajfault"]
363 stat.TotalInactiveAnon = raw["total_inactive_anon"]
364 stat.TotalActiveAnon = raw["total_active_anon"]
365 stat.TotalInactiveFile = raw["total_inactive_file"]
366 stat.TotalActiveFile = raw["total_active_file"]
367 stat.TotalUnevictable = raw["total_unevictable"]
368 return nil
369}
370
371func (m *memoryController) parseOomControlStats(r io.Reader, stat *v1.MemoryOomControl) error {
372 var (

Callers 2

StatMethod · 0.95
TestParseMemoryStatsFunction · 0.80

Calls 1

parseKVFunction · 0.70

Tested by 1

TestParseMemoryStatsFunction · 0.64