cleanup after 5a49bb8e88
This commit is contained in:
parent
53fe52ac0e
commit
096d705076
@ -236,17 +236,18 @@ func getMemStats(path string) (*memStats, error) {
|
|||||||
// Extract key value.
|
// Extract key value.
|
||||||
line := strings.Fields(s)
|
line := strings.Fields(s)
|
||||||
if len(line) != 3 {
|
if len(line) != 3 {
|
||||||
return nil, fmt.Errorf("cannot extract soft limit from %q", s)
|
return nil, fmt.Errorf("unexpected number of fields found in %q; got %d; want %d", s, len(line), 3)
|
||||||
}
|
}
|
||||||
memStatName := line[0]
|
memStatName := line[0]
|
||||||
memStatValue := line[1]
|
memStatValue := line[1]
|
||||||
value, err := strconv.ParseUint(memStatValue, 10, 64)
|
value, err := strconv.ParseUint(memStatValue, 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("cannot parse soft limit from %q: %s", s, err)
|
return nil, fmt.Errorf("cannot parse number from %q: %w", s, err)
|
||||||
}
|
}
|
||||||
if line[2] == "kB" {
|
if line[2] != "kB" {
|
||||||
value = value * 1024
|
return nil, fmt.Errorf("expecting kB value in %q; got %q", s, line[2])
|
||||||
}
|
}
|
||||||
|
value *= 1024
|
||||||
switch memStatName {
|
switch memStatName {
|
||||||
case "VmPeak:":
|
case "VmPeak:":
|
||||||
ms.vmPeak = value
|
ms.vmPeak = value
|
||||||
|
Loading…
Reference in New Issue
Block a user