Add go sdk
This commit is contained in:
16
performancemetrics/disk.go
Normal file
16
performancemetrics/disk.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package performancemetrics
|
||||
|
||||
import "syscall"
|
||||
|
||||
func getDiskUsage(path string) (used, free, total uint64, err error) {
|
||||
var stat syscall.Statfs_t
|
||||
err = syscall.Statfs(path, &stat)
|
||||
if err != nil {
|
||||
return
|
||||
}
|
||||
|
||||
total = stat.Blocks * uint64(stat.Bsize)
|
||||
free = stat.Bfree * uint64(stat.Bsize)
|
||||
used = total - free
|
||||
return
|
||||
}
|
||||
Reference in New Issue
Block a user