1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-05-10 19:29:14 +08:00

Merge pull request #45 from okmeter/master

disk_usage as in psutil & Process.NumFds() for linux
This commit is contained in:
shirou 2015-04-09 10:54:28 +09:00
commit b55d373cee
3 changed files with 5 additions and 4 deletions

View File

@ -16,14 +16,14 @@ func DiskUsage(path string) (*DiskUsageStat, error) {
ret := &DiskUsageStat{
Path: path,
Total: (uint64(stat.Blocks) * uint64(bsize)),
Free: (uint64(stat.Bfree) * uint64(bsize)),
Free: (uint64(stat.Bavail) * uint64(bsize)),
InodesTotal: (uint64(stat.Files)),
InodesFree: (uint64(stat.Ffree)),
}
ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)
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
return ret, nil

View File

@ -53,7 +53,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
}
ret := &VirtualMemoryStat{
Total: parsed[0] * p,
Total: parsed[0],
Free: parsed[1] * p,
}

View File

@ -132,7 +132,8 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return p.numCtxSwitches, nil
}
func (p *Process) NumFDs() (int32, error) {
return 0, common.NotImplementedError
numFds, _, err := p.fillFromfd()
return numFds, err
}
func (p *Process) NumThreads() (int32, error) {
return p.numThreads, nil