diff options
| author | Chris Lu <chris.lu@gmail.com> | 2014-03-25 13:46:59 -0700 |
|---|---|---|
| committer | Chris Lu <chris.lu@gmail.com> | 2014-03-25 13:46:59 -0700 |
| commit | 39b774a131ac3bc454a516f7b72dcefabc593103 (patch) | |
| tree | 804763e28b55b1e30ebfefced71b552b8e3e34a1 /go/stats/disk.go | |
| parent | 6e0601a73bf199e7d3ffd3cd2990223e959d3e24 (diff) | |
| download | seaweedfs-39b774a131ac3bc454a516f7b72dcefabc593103.tar.xz seaweedfs-39b774a131ac3bc454a516f7b72dcefabc593103.zip | |
1. adding statistics reporting
2. refactor version to util package
Diffstat (limited to 'go/stats/disk.go')
| -rw-r--r-- | go/stats/disk.go | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/go/stats/disk.go b/go/stats/disk.go new file mode 100644 index 000000000..acbbd51b9 --- /dev/null +++ b/go/stats/disk.go @@ -0,0 +1,26 @@ +// +build !windows + +package stats + +import ( + "syscall" +) + +type DiskStatus struct { + All uint64 `json:"all"` + Used uint64 `json:"used"` + Free uint64 `json:"free"` +} + +func DiskUsage(path string) (disk *DiskStatus) { + disk = &DiskStatus{} + fs := syscall.Statfs_t{} + err := syscall.Statfs(path, &fs) + if err != nil { + return + } + disk.All = fs.Blocks * uint64(fs.Bsize) + disk.Free = fs.Bfree * uint64(fs.Bsize) + disk.Used = disk.All - disk.Free + return +} |
