Refactor stats and add them to all subsystems
Docker-DCO-1.1-Signed-off-by: Michael Crosby <michael@crosbymichael.com> (github: crosbymichael)
This commit is contained in:
parent
b5b44ad439
commit
ab15aa234c
10 changed files with 88 additions and 61 deletions
|
@ -2,7 +2,6 @@ package fs
|
|||
|
||||
import (
|
||||
"bufio"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"strconv"
|
||||
|
@ -51,19 +50,20 @@ func (s *memoryGroup) Stats(d *data) (map[string]float64, error) {
|
|||
paramData := make(map[string]float64)
|
||||
path, err := d.path("memory")
|
||||
if err != nil {
|
||||
fmt.Errorf("Unable to read %s cgroup param: %s", path, err)
|
||||
return paramData, err
|
||||
return nil, err
|
||||
}
|
||||
|
||||
f, err := os.Open(filepath.Join(path, "memory.stat"))
|
||||
if err != nil {
|
||||
return paramData, err
|
||||
return nil, err
|
||||
}
|
||||
defer f.Close()
|
||||
|
||||
sc := bufio.NewScanner(f)
|
||||
for sc.Scan() {
|
||||
t, v, err := getCgroupParamKeyValue(sc.Text())
|
||||
if err != nil {
|
||||
return paramData, fmt.Errorf("Error parsing param data: %s", err)
|
||||
return nil, err
|
||||
}
|
||||
paramData[t] = v
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue