Skip to content

Commit

Permalink
Get disk usage stats working on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
srfraser committed Aug 18, 2015
1 parent 2cd56e4 commit 7273e2e
Showing 1 changed file with 15 additions and 15 deletions.
30 changes: 15 additions & 15 deletions plugins/system/ps/disk/disk_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,8 @@ var (

const WaitMSec = 500

func DiskUsage(path string) (DiskUsageStat, error) {
ret := DiskUsageStat{}
func DiskUsage(path string) (*DiskUsageStat, error) {

ret.Path = path
lpFreeBytesAvailable := int64(0)
lpTotalNumberOfBytes := int64(0)
lpTotalNumberOfFreeBytes := int64(0)
Expand All @@ -39,19 +37,21 @@ func DiskUsage(path string) (DiskUsageStat, error) {
uintptr(unsafe.Pointer(&lpTotalNumberOfBytes)),
uintptr(unsafe.Pointer(&lpTotalNumberOfFreeBytes)))
if diskret == 0 {
return ret, err
return nil, err
}
ret.Total = uint64(lpTotalNumberOfBytes)
// ret.Free = uint64(lpFreeBytesAvailable) // python psutil does not use this
ret.Free = uint64(lpTotalNumberOfFreeBytes)
ret.Used = ret.Total - ret.Free
ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0

//TODO: implement inodes stat
ret.InodesTotal = 0
ret.InodesUsed = 0
ret.InodesFree = 0
ret.InodesUsedPercent = 0.0

ret := &DiskUsageStat{
Path: path,
Total: uint64(lpTotalNumberOfBytes),
Free: uint64(lpTotalNumberOfFreeBytes),
// Used: uint64(lpTotalNumberOfBytes) - uint64(lpTotalNumberOfFreeBytes)
// UsedPercent: (float64(lpTotalNumberOfBytes) - float64(lpTotalNumberOfFreeBytes)) / float64(lpTotalNumberOfBytes) * 100
// InodesTotal: 0,
// InodesFree: 0,
// InodesUsed: 0,
// InodesUsedPercent: 0,
}

return ret, nil
}

Expand Down

0 comments on commit 7273e2e

Please sign in to comment.