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
|
@ -1,23 +1,25 @@
|
|||
package fs
|
||||
|
||||
import (
|
||||
"errors"
|
||||
"fmt"
|
||||
"strconv"
|
||||
"strings"
|
||||
)
|
||||
|
||||
var ErrNotSupportStat = errors.New("stats are not supported for subsystem")
|
||||
|
||||
// Parses a cgroup param and returns as name, value
|
||||
// i.e. "io_service_bytes 1234" will return as io_service_bytes, 1234
|
||||
func getCgroupParamKeyValue(t string) (string, float64, error) {
|
||||
parts := strings.Fields(t)
|
||||
switch len(parts) {
|
||||
case 2:
|
||||
name := parts[0]
|
||||
value, err := strconv.ParseFloat(parts[1], 64)
|
||||
if err != nil {
|
||||
return "", 0.0, fmt.Errorf("Unable to convert param value to float: %s", err)
|
||||
}
|
||||
return name, value, nil
|
||||
return parts[0], value, nil
|
||||
default:
|
||||
return "", 0.0, fmt.Errorf("Unable to parse cgroup param: not enough parts; expected 2")
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue