disk_usage as in psutil

This commit is contained in:
Pavel Trukhanov 2015-01-28 16:25:25 +03:00 committed by Nikolay Sivko
parent 79f4358f65
commit 4f6e4f73f3
1 changed files with 2 additions and 2 deletions

View File

@ -16,14 +16,14 @@ func DiskUsage(path string) (*DiskUsageStat, error) {
ret := &DiskUsageStat{ ret := &DiskUsageStat{
Path: path, Path: path,
Total: (uint64(stat.Blocks) * uint64(bsize)), Total: (uint64(stat.Blocks) * uint64(bsize)),
Free: (uint64(stat.Bfree) * uint64(bsize)), Free: (uint64(stat.Bavail) * uint64(bsize)),
InodesTotal: (uint64(stat.Files)), InodesTotal: (uint64(stat.Files)),
InodesFree: (uint64(stat.Ffree)), InodesFree: (uint64(stat.Ffree)),
} }
ret.InodesUsed = (ret.InodesTotal - ret.InodesFree) ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0 ret.InodesUsedPercent = (float64(ret.InodesUsed) / float64(ret.InodesTotal)) * 100.0
ret.Used = (ret.Total - ret.Free) ret.Used = (uint64(stat.Blocks) - uint64(stat.Bfree)) * uint64(bsize)
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0 ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
return ret, nil return ret, nil