|
|
|
@ -22,45 +22,23 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
|
|
|
|
|
value := strings.TrimSpace(fields[1])
|
|
|
|
|
value = strings.Replace(value, " kB", "", -1)
|
|
|
|
|
|
|
|
|
|
t, err := strconv.ParseUint(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
switch key {
|
|
|
|
|
case "MemTotal":
|
|
|
|
|
ret.Total = mustParseUint64(value) * 1000
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Total = uint64(t) * 1000
|
|
|
|
|
ret.Total = t * 1000
|
|
|
|
|
case "MemFree":
|
|
|
|
|
ret.Free = mustParseUint64(value) * 1000
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Free = uint64(t) * 1000
|
|
|
|
|
ret.Free = t * 1000
|
|
|
|
|
case "Buffers":
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Buffers = uint64(t) * 1000
|
|
|
|
|
ret.Buffers = t * 1000
|
|
|
|
|
case "Cached":
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Cached = uint64(t) * 1000
|
|
|
|
|
ret.Cached = t * 1000
|
|
|
|
|
case "Active":
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Active = uint64(t) * 1000
|
|
|
|
|
ret.Active = t * 1000
|
|
|
|
|
case "Inactive":
|
|
|
|
|
t, err := strconv.ParseInt(value, 10, 64)
|
|
|
|
|
if err != nil {
|
|
|
|
|
return ret, err
|
|
|
|
|
}
|
|
|
|
|
ret.Inactive = uint64(t) * 1000
|
|
|
|
|
ret.Inactive = t * 1000
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
ret.Available = ret.Free + ret.Buffers + ret.Cached
|
|
|
|
|