Skip to content

Commit

Permalink
Simplify stats
Browse files Browse the repository at this point in the history
Signed-off-by: bpopovschi <zyqsempai@mail.ru>
  • Loading branch information
Zyqsempai committed Nov 14, 2019
1 parent 344a8ab commit 4d88c26
Show file tree
Hide file tree
Showing 4 changed files with 153 additions and 351 deletions.
19 changes: 4 additions & 15 deletions v2/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -325,22 +325,11 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
Pglazyfreed: out["pglazyfreed"].(uint64),
ThpFaultAlloc: out["thp_fault_alloc"].(uint64),
ThpCollapseAlloc: out["thp_collapse_alloc"].(uint64),
Usage: getStatFileContent(filepath.Join(c.path, "memory.current")),
UsageLimit: getStatFileContent(filepath.Join(c.path, "memory.max")),
SwapUsage: getStatFileContent(filepath.Join(c.path, "memory.swap.current")),
SwapLimit: getStatFileContent(filepath.Join(c.path, "memory.swap.max")),
}
cur_mem := getStatFileContent(filepath.Join(c.path, "memory.current"))
max_mem := getStatFileContent(filepath.Join(c.path, "memory.max"))
cur_swap := getStatFileContent(filepath.Join(c.path, "memory.swap.current"))
max_swap := getStatFileContent(filepath.Join(c.path, "memory.swap.max"))

usage := stats.MemoryEntry{
Usage: cur_mem,
Limit: max_mem,
}
swwap := stats.MemoryEntry{
Usage: cur_swap,
Limit: max_swap,
}
metrics.Memory.Usage = &usage
metrics.Memory.SwapUsage = &swwap

return &metrics, nil
}
Expand Down
Loading

0 comments on commit 4d88c26

Please sign in to comment.