open-vault/vault/diagnose/os_unix.go
Scott Miller d151b0b55b
Segment out disk checks to disable on openbsd/arm (#11749)
* Segment out disk checks to disable on openbsd/arm

Also add a spot skipped helper.

* Expected results may be fewer than actual because of variable length tests like disk usage

* Move to os_common and build on windows
2021-06-02 12:17:52 -05:00

32 lines
679 B
Go

// +build !windows
package diagnose
import (
"context"
"fmt"
"golang.org/x/sys/unix"
)
func OSChecks(ctx context.Context) {
ctx, span := StartSpan(ctx, "operating system")
defer span.End()
var limit unix.Rlimit
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &limit); err != nil {
SpotError(ctx, "open file limits", fmt.Errorf("could not determine open file limit: %w", err))
} else {
min := limit.Cur
if limit.Max < min {
min = limit.Max
}
if min <= 1024 {
SpotWarn(ctx, "open file limits", fmt.Sprintf("set to %d, which may be insufficient.", min))
} else {
SpotOk(ctx, "open file limits", fmt.Sprintf("set to %d", min))
}
}
diskUsage(ctx)
}