Skip to content

Commit

Permalink
Merge pull request #1688 from zmyzheng/zmyzheng/fix-IOCountersWithCon…
Browse files Browse the repository at this point in the history
…text

fix(IOCountersWithContext): Fix the issue of not using names to fil ter devices in func IOCountersWithContext of the windows implementation
  • Loading branch information
shirou authored Aug 14, 2024
2 parents 6dfedba + 16d7f32 commit edff3ad
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions disk/disk_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,17 @@ func IOCountersWithContext(ctx context.Context, names ...string) (map[string]IOC
if err != nil {
return drivemap, err
}
drivemap[path] = IOCountersStat{
ReadBytes: uint64(diskPerformance.BytesRead),
WriteBytes: uint64(diskPerformance.BytesWritten),
ReadCount: uint64(diskPerformance.ReadCount),
WriteCount: uint64(diskPerformance.WriteCount),
ReadTime: uint64(diskPerformance.ReadTime / 10000 / 1000), // convert to ms: https://github.com/giampaolo/psutil/issues/1012
WriteTime: uint64(diskPerformance.WriteTime / 10000 / 1000),
Name: path,

if len(names) == 0 || common.StringsHas(names, path) {
drivemap[path] = IOCountersStat{
ReadBytes: uint64(diskPerformance.BytesRead),
WriteBytes: uint64(diskPerformance.BytesWritten),
ReadCount: uint64(diskPerformance.ReadCount),
WriteCount: uint64(diskPerformance.WriteCount),
ReadTime: uint64(diskPerformance.ReadTime / 10000 / 1000), // convert to ms: https://github.com/giampaolo/psutil/issues/1012
WriteTime: uint64(diskPerformance.WriteTime / 10000 / 1000),
Name: path,
}
}
}
}
Expand Down

0 comments on commit edff3ad

Please sign in to comment.