提交 b55d373c 编写于 作者: S shirou

Merge pull request #45 from okmeter/master

disk_usage as in psutil & Process.NumFds() for linux
...@@ -16,14 +16,14 @@ func DiskUsage(path string) (*DiskUsageStat, error) { ...@@ -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
......
...@@ -53,7 +53,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) { ...@@ -53,7 +53,7 @@ func VirtualMemory() (*VirtualMemoryStat, error) {
} }
ret := &VirtualMemoryStat{ ret := &VirtualMemoryStat{
Total: parsed[0] * p, Total: parsed[0],
Free: parsed[1] * p, Free: parsed[1] * p,
} }
......
...@@ -132,7 +132,8 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) { ...@@ -132,7 +132,8 @@ func (p *Process) NumCtxSwitches() (*NumCtxSwitchesStat, error) {
return p.numCtxSwitches, nil return p.numCtxSwitches, nil
} }
func (p *Process) NumFDs() (int32, error) { func (p *Process) NumFDs() (int32, error) {
return 0, common.NotImplementedError numFds, _, err := p.fillFromfd()
return numFds, err
} }
func (p *Process) NumThreads() (int32, error) { func (p *Process) NumThreads() (int32, error) {
return p.numThreads, nil return p.numThreads, nil
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册