diff --git a/disk.go b/disk.go index 7b3e6bd..397380c 100644 --- a/disk.go +++ b/disk.go @@ -5,14 +5,14 @@ import ( ) type DiskUsageStat struct { - Path string `json:"path"` - Total uint64 `json:"total"` - Free uint64 `json:"free"` - Used uint64 `json:"used"` - UsedPercent float64 `json:"usedPercent"` - InodesTotal uint64 `json:"inodesTotal"` - InodesUsed uint64 `json:"inodesUsed"` - InodesFree uint64 `json:"inodesFree"` + Path string `json:"path"` + Total uint64 `json:"total"` + 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"` } diff --git a/disk_test.go b/disk_test.go index f8d3fd7..635e77c 100644 --- a/disk_test.go +++ b/disk_test.go @@ -48,13 +48,17 @@ func TestDisk_io_counters(t *testing.T) { func TestDiskUsageStat_String(t *testing.T) { v := DiskUsageStat{ - Path: "/", - Total: 1000, - Free: 2000, - Used: 3000, - UsedPercent: 50.1, + Path: "/", + Total: 1000, + Free: 2000, + Used: 3000, + UsedPercent: 50.1, + InodesTotal: 4000, + InodesUsed: 5000, + InodesFree: 6000, + InodesUsedPercent: 49.1, } - e := `{"path":"/","total":1000,"free":2000,"used":3000,"usedPercent":50.1}` + e := `{"path":"/","total":1000,"free":2000,"used":3000,"usedPercent":50.1,"inodesTotal":4000,"inodesUsed":5000,"inodesFree":6000,"inodesUsedPercent":49.1}` if e != fmt.Sprintf("%v", v) { t.Errorf("DiskUsageStat string is invalid: %v", v) } diff --git a/disk_unix.go b/disk_unix.go index 403fb30..bf28ca7 100644 --- a/disk_unix.go +++ b/disk_unix.go @@ -14,11 +14,11 @@ func DiskUsage(path string) (*DiskUsageStat, error) { bsize := stat.Bsize / 512 ret := &DiskUsageStat{ - Path: path, - Total: (uint64(stat.Blocks) * uint64(bsize)) >> 1, - Free: (uint64(stat.Bfree) * uint64(bsize)) >> 1, + Path: path, + Total: (uint64(stat.Blocks) * uint64(bsize)) >> 1, + Free: (uint64(stat.Bfree) * uint64(bsize)) >> 1, InodesTotal: (uint64(stat.Files)), - InodesFree: (uint64(stat.Ffree)), + InodesFree: (uint64(stat.Ffree)), } ret.InodesUsed = (ret.InodesTotal - ret.InodesFree)