Skip to content

Commit

Permalink
Return bytes, instead of 512 blocks (elastic/topbeat#11)
Browse files Browse the repository at this point in the history
The size of the block depends on the operating system. For example, in GNU, 1K block means 1024 bytes.
Under OSX, there are 512 blocks. So, returning bytes seems to be the best solution.
  • Loading branch information
monicasarbu committed Sep 1, 2015
1 parent 122465c commit b16b1e1
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions sigar_unix.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,9 @@ func (self *FileSystemUsage) Get(path string) error {
return err
}

bsize := stat.Bsize / 512

self.Total = (uint64(stat.Blocks) * uint64(bsize)) >> 1
self.Free = (uint64(stat.Bfree) * uint64(bsize)) >> 1
self.Avail = (uint64(stat.Bavail) * uint64(bsize)) >> 1
self.Total = uint64(stat.Blocks) * uint64(stat.Bsize)
self.Free = uint64(stat.Bfree) * uint64(stat.Bsize)
self.Avail = uint64(stat.Bavail) * uint64(stat.Bsize)
self.Used = self.Total - self.Free
self.Files = stat.Files
self.FreeFiles = stat.Ffree
Expand Down

0 comments on commit b16b1e1

Please sign in to comment.