Skip to content

Commit

Permalink
v2/stats: add all fields of memory.events
Browse files Browse the repository at this point in the history
Signed-off-by: Akihiro Suda <akihiro.suda.cz@hco.ntt.co.jp>
  • Loading branch information
AkihiroSuda committed May 30, 2020
1 parent 31aeab7 commit f9dd635
Show file tree
Hide file tree
Showing 4 changed files with 456 additions and 96 deletions.
13 changes: 10 additions & 3 deletions v2/manager.go
Expand Up @@ -359,7 +359,6 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
return nil, err
}
out := make(map[string]interface{})
memoryEvents := make(map[string]interface{})
for _, controller := range controllers {
switch controller {
case "cpu", "memory":
Expand All @@ -380,6 +379,7 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
return nil, err
}
}
memoryEvents := make(map[string]interface{})
if err := readKVStatsFile(c.path, "memory.events", memoryEvents); err != nil {
if !os.IsNotExist(err) {
return nil, err
Expand Down Expand Up @@ -435,9 +435,16 @@ func (c *Manager) Stat() (*stats.Metrics, error) {
UsageLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.max")),
SwapUsage: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.current")),
SwapLimit: getStatFileContentUint64(filepath.Join(c.path, "memory.swap.max")),
EventsMax: getUint64Value("max", memoryEvents),
}

if len(memoryEvents) > 0 {
metrics.MemoryEvents = &stats.MemoryEvents{
Low: getUint64Value("low", memoryEvents),
High: getUint64Value("high", memoryEvents),
Max: getUint64Value("max", memoryEvents),
Oom: getUint64Value("oom", memoryEvents),
OomKill: getUint64Value("oom_kill", memoryEvents),
}
}
metrics.Io = &stats.IOStat{Usage: readIoStats(c.path)}
metrics.Rdma = &stats.RdmaStat{
Current: rdmaStats(filepath.Join(c.path, "rdma.current")),
Expand Down

0 comments on commit f9dd635

Please sign in to comment.