healtcheck: add extra build tags+files for netbsd and openbsd
Without these changes, the disk check portions won't compile on these platforms.
This commit is contained in:
parent
fa342a1230
commit
9887b2d731
@ -1,4 +1,4 @@
|
||||
// +build !windows,!solaris
|
||||
// +build !windows,!solaris,!netbsd,!openbsd
|
||||
|
||||
package healthcheck
|
||||
|
||||
|
17
healthcheck/diskcheck_netbsd.go
Normal file
17
healthcheck/diskcheck_netbsd.go
Normal file
@ -0,0 +1,17 @@
|
||||
package healthcheck
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// AvailableDiskSpace returns ratio of available disk space to total capacity
|
||||
// for solaris.
|
||||
func AvailableDiskSpace(path string) (float64, error) {
|
||||
s := unix.Statvfs_t{}
|
||||
err := unix.Statvfs(path, &s)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Calculate our free blocks/total blocks to get our total ratio of
|
||||
// free blocks.
|
||||
return float64(s.Bfree) / float64(s.Blocks), nil
|
||||
}
|
17
healthcheck/diskcheck_openbsd.go
Normal file
17
healthcheck/diskcheck_openbsd.go
Normal file
@ -0,0 +1,17 @@
|
||||
package healthcheck
|
||||
|
||||
import "golang.org/x/sys/unix"
|
||||
|
||||
// AvailableDiskSpace returns ratio of available disk space to total capacity
|
||||
// for solaris.
|
||||
func AvailableDiskSpace(path string) (float64, error) {
|
||||
s := unix.Statfs_t{}
|
||||
err := unix.Statfs(path, &s)
|
||||
if err != nil {
|
||||
return 0, err
|
||||
}
|
||||
|
||||
// Calculate our free blocks/total blocks to get our total ratio of
|
||||
// free blocks.
|
||||
return float64(s.F_bfree) / float64(s.F_blocks), nil
|
||||
}
|
Loading…
Reference in New Issue
Block a user