disk inodes usage

This commit is contained in:
Nikolay Sivko 2014-08-26 12:38:52 +04:00
parent bc8d9df079
commit e8bb28fc98
3 changed files with 13 additions and 0 deletions

View File

@ -10,6 +10,10 @@ type DiskUsageStat struct {
Free uint64 `json:"free"`
Used uint64 `json:"used"`
UsedPercent float64 `json:"usedPercent"`
InodesTotal uint64 `json:"inodesTotal"`
InodesUsed uint64 `json:"inodesUsed"`
InodesFree uint64 `json:"inodesFree"`
InodesUsedPercent float64 `json:"inodesUsedPercent"`
}
type DiskPartitionStat struct {

View File

@ -17,8 +17,12 @@ func DiskUsage(path string) (*DiskUsageStat, error) {
Path: path,
Total: (uint64(stat.Blocks) * 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.UsedPercent = (float64(ret.Used) / float64(ret.Total)) * 100.0

View File

@ -41,6 +41,11 @@ func DiskUsage(path string) (DiskUsageStat, error) {
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
return ret, nil
}