Make all cgroup stats output int64s instead of float64.
Docker-DCO-1.1-Signed-off-by: Victor Marmol <vmarmol@google.com> (github: vmarmol)
This commit is contained in:
parent
89b64d33ee
commit
c88ecf6acd
15 changed files with 72 additions and 78 deletions
|
@ -16,25 +16,25 @@ var (
|
|||
|
||||
// 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) {
|
||||
func getCgroupParamKeyValue(t string) (string, int64, error) {
|
||||
parts := strings.Fields(t)
|
||||
switch len(parts) {
|
||||
case 2:
|
||||
value, err := strconv.ParseFloat(parts[1], 64)
|
||||
value, err := strconv.ParseInt(parts[1], 10, 64)
|
||||
if err != nil {
|
||||
return "", 0.0, fmt.Errorf("Unable to convert param value to float: %s", err)
|
||||
return "", 0, fmt.Errorf("Unable to convert param value to int: %s", err)
|
||||
}
|
||||
return parts[0], value, nil
|
||||
default:
|
||||
return "", 0.0, ErrNotValidFormat
|
||||
return "", 0, ErrNotValidFormat
|
||||
}
|
||||
}
|
||||
|
||||
// Gets a single float64 value from the specified cgroup file.
|
||||
func getCgroupParamFloat64(cgroupPath, cgroupFile string) (float64, error) {
|
||||
// Gets a single int64 value from the specified cgroup file.
|
||||
func getCgroupParamInt(cgroupPath, cgroupFile string) (int64, error) {
|
||||
contents, err := ioutil.ReadFile(filepath.Join(cgroupPath, cgroupFile))
|
||||
if err != nil {
|
||||
return -1.0, err
|
||||
return -1, err
|
||||
}
|
||||
return strconv.ParseFloat(strings.TrimSpace(string(contents)), 64)
|
||||
return strconv.ParseInt(strings.TrimSpace(string(contents)), 10, 64)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue