Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get disk usage stats working on windows #118

Merged
merged 1 commit into from
Aug 18, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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