add docker
This commit is contained in:
24
pkg/sysstats/disk_unix.go
Normal file
24
pkg/sysstats/disk_unix.go
Normal file
@@ -0,0 +1,24 @@
|
||||
//go:build unix
|
||||
|
||||
package sysstats
|
||||
|
||||
import "syscall"
|
||||
|
||||
func diskUsage(path string) (Disk, error) {
|
||||
var st syscall.Statfs_t
|
||||
if err := syscall.Statfs(path, &st); err != nil {
|
||||
return Disk{}, err
|
||||
}
|
||||
bsize := uint64(st.Bsize)
|
||||
total := uint64(st.Blocks) * bsize
|
||||
free := uint64(st.Bavail) * bsize // space available to non-root users
|
||||
used := total - uint64(st.Bfree)*bsize
|
||||
|
||||
return Disk{
|
||||
Path: path,
|
||||
TotalBytes: total,
|
||||
UsedBytes: used,
|
||||
FreeBytes: free,
|
||||
UsagePercent: percent(used, used+free),
|
||||
}, nil
|
||||
}
|
||||
Reference in New Issue
Block a user