1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-02 22:17:08 +08:00

* fix IOCountersStat

This commit is contained in:
Nikolay Sivko 2014-11-02 11:33:51 +03:00
parent 28f9a28626
commit 4fd429ca00
2 changed files with 17 additions and 14 deletions

View File

@ -33,10 +33,10 @@ type RlimitStat struct {
}
type IOCountersStat struct {
ReadCount int32 `json:"read_count"`
WriteCount int32 `json:"write_count"`
ReadBytes int32 `json:"read_bytes"`
WriteBytes int32 `json:"write_bytes"`
ReadCount uint64 `json:"read_count"`
WriteCount uint64 `json:"write_count"`
ReadBytes uint64 `json:"read_bytes"`
WriteBytes uint64 `json:"write_bytes"`
}
type NumCtxSwitchesStat struct {

View File

@ -346,24 +346,27 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
ret := &IOCountersStat{}
for _, line := range lines {
field := strings.Split(line, ":")
field := strings.Fields(line)
if len(field) < 2 {
continue
}
t, err := strconv.ParseInt(strings.Trim(field[1], " \t"), 10, 32)
t, err := strconv.ParseUint(field[1], 10, 64)
if err != nil {
return nil, err
}
switch field[0] {
case "rchar":
ret.ReadCount = int32(t)
case "wchar":
ret.WriteCount = int32(t)
param := field[0]
if strings.HasSuffix(param, ":") {
param = param[:len(param)-1]
}
switch param {
case "syscr":
ret.ReadCount = t
case "syscw":
ret.WriteCount = t
case "read_bytes":
ret.ReadBytes = int32(t)
ret.ReadBytes = t
case "write_bytes":
ret.WriteBytes = int32(t)
ret.WriteBytes = t
}
}