mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-02 22:17:08 +08:00
* fix IOCountersStat
This commit is contained in:
parent
28f9a28626
commit
4fd429ca00
@ -33,10 +33,10 @@ type RlimitStat struct {
|
|||||||
}
|
}
|
||||||
|
|
||||||
type IOCountersStat struct {
|
type IOCountersStat struct {
|
||||||
ReadCount int32 `json:"read_count"`
|
ReadCount uint64 `json:"read_count"`
|
||||||
WriteCount int32 `json:"write_count"`
|
WriteCount uint64 `json:"write_count"`
|
||||||
ReadBytes int32 `json:"read_bytes"`
|
ReadBytes uint64 `json:"read_bytes"`
|
||||||
WriteBytes int32 `json:"write_bytes"`
|
WriteBytes uint64 `json:"write_bytes"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type NumCtxSwitchesStat struct {
|
type NumCtxSwitchesStat struct {
|
||||||
|
@ -346,24 +346,27 @@ func (p *Process) fillFromIO() (*IOCountersStat, error) {
|
|||||||
ret := &IOCountersStat{}
|
ret := &IOCountersStat{}
|
||||||
|
|
||||||
for _, line := range lines {
|
for _, line := range lines {
|
||||||
field := strings.Split(line, ":")
|
field := strings.Fields(line)
|
||||||
if len(field) < 2 {
|
if len(field) < 2 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
t, err := strconv.ParseInt(strings.Trim(field[1], " \t"), 10, 32)
|
t, err := strconv.ParseUint(field[1], 10, 64)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
param := field[0]
|
||||||
switch field[0] {
|
if strings.HasSuffix(param, ":") {
|
||||||
case "rchar":
|
param = param[:len(param)-1]
|
||||||
ret.ReadCount = int32(t)
|
}
|
||||||
case "wchar":
|
switch param {
|
||||||
ret.WriteCount = int32(t)
|
case "syscr":
|
||||||
|
ret.ReadCount = t
|
||||||
|
case "syscw":
|
||||||
|
ret.WriteCount = t
|
||||||
case "read_bytes":
|
case "read_bytes":
|
||||||
ret.ReadBytes = int32(t)
|
ret.ReadBytes = t
|
||||||
case "write_bytes":
|
case "write_bytes":
|
||||||
ret.WriteBytes = int32(t)
|
ret.WriteBytes = t
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user