2021-06-01 17:43:51 +00:00
|
|
|
// +build !windows
|
|
|
|
|
|
|
|
package diagnose
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
|
|
|
"fmt"
|
2021-07-11 22:44:19 +00:00
|
|
|
|
2021-06-01 17:43:51 +00:00
|
|
|
"golang.org/x/sys/unix"
|
|
|
|
)
|
|
|
|
|
|
|
|
func OSChecks(ctx context.Context) {
|
2021-07-11 22:44:19 +00:00
|
|
|
ctx, span := StartSpan(ctx, "Check Operating System")
|
2021-06-02 17:17:52 +00:00
|
|
|
defer span.End()
|
|
|
|
|
2021-07-11 22:44:19 +00:00
|
|
|
fileLimitsName := "Check Open File Limits"
|
|
|
|
|
2021-06-01 17:43:51 +00:00
|
|
|
var limit unix.Rlimit
|
|
|
|
if err := unix.Getrlimit(unix.RLIMIT_NOFILE, &limit); err != nil {
|
2021-07-11 22:44:19 +00:00
|
|
|
SpotError(ctx, fileLimitsName, fmt.Errorf("Could not determine open file limit: %w.", err))
|
2021-06-01 17:43:51 +00:00
|
|
|
} else {
|
|
|
|
min := limit.Cur
|
|
|
|
if limit.Max < min {
|
|
|
|
min = limit.Max
|
|
|
|
}
|
|
|
|
if min <= 1024 {
|
2021-07-15 23:01:51 +00:00
|
|
|
SpotWarn(ctx, fileLimitsName, fmt.Sprintf("Open file limits are set to %d", min),
|
|
|
|
Advice("These limits may be insufficient. We recommend raising the soft and hard limits to 1024768."))
|
2021-06-01 17:43:51 +00:00
|
|
|
} else {
|
2021-07-11 22:44:19 +00:00
|
|
|
SpotOk(ctx, fileLimitsName, fmt.Sprintf("Open file limits are set to %d.", min))
|
2021-06-01 17:43:51 +00:00
|
|
|
}
|
|
|
|
}
|
2021-06-02 17:17:52 +00:00
|
|
|
|
|
|
|
diskUsage(ctx)
|
2021-06-01 17:43:51 +00:00
|
|
|
}
|