mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-09-13 18:10:25 +02:00
multi: add minimum disk space check
This commit is contained in:
18
healthcheck/diskcheck.go
Normal file
18
healthcheck/diskcheck.go
Normal file
@@ -0,0 +1,18 @@
|
||||
// +build !windows,!solaris
|
||||
|
||||
package healthcheck
|
||||
|
||||
import "syscall"
|
||||
|
||||
// AvailableDiskSpace returns ratio of available disk space to total capacity.
|
||||
func AvailableDiskSpace(path string) (float64, error) {
|
||||
s := syscall.Statfs_t{}
|
||||
err := syscall.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.Bfree) / float64(s.Blocks), nil
|
||||
}
|
Reference in New Issue
Block a user