disk inodes usage
This commit is contained in:
parent
bc8d9df079
commit
e8bb28fc98
4
disk.go
4
disk.go
|
@ -10,6 +10,10 @@ type DiskUsageStat struct {
|
||||||
Free uint64 `json:"free"`
|
Free uint64 `json:"free"`
|
||||||
Used uint64 `json:"used"`
|
Used uint64 `json:"used"`
|
||||||
UsedPercent float64 `json:"usedPercent"`
|
UsedPercent float64 `json:"usedPercent"`
|
||||||
|
InodesTotal uint64 `json:"inodesTotal"`
|
||||||
|
InodesUsed uint64 `json:"inodesUsed"`
|
||||||
|
InodesFree uint64 `json:"inodesFree"`
|
||||||
|
InodesUsedPercent float64 `json:"inodesUsedPercent"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type DiskPartitionStat struct {
|
type DiskPartitionStat struct {
|
||||||
|
|
|
@ -17,8 +17,12 @@ func DiskUsage(path string) (*DiskUsageStat, error) {
|
||||||
Path: path,
|
Path: path,
|
||||||
Total: (uint64(stat.Blocks) * uint64(bsize)) >> 1,
|
Total: (uint64(stat.Blocks) * uint64(bsize)) >> 1,
|
||||||
Free: (uint64(stat.Bfree) * uint64(bsize)) >> 1,
|
Free: (uint64(stat.Bfree) * uint64(bsize)) >> 1,
|
||||||
|
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 = (ret.Total - ret.Free)
|
||||||
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
|
ret.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0
|
||||||
|
|
||||||
|
|
|
@ -41,6 +41,11 @@ func DiskUsage(path string) (DiskUsageStat, error) {
|
||||||
ret.Used = ret.Total - ret.Free
|
ret.Used = ret.Total - ret.Free
|
||||||
ret.UsedPercent = float64(ret.Used) / float64(ret.Total) * 100.0
|
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
|
||||||
return ret, nil
|
return ret, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue