fix(secrets): Make "insufficient lockable memory" warning work on BSDs (#16682)
Co-authored-by: Stephan Gabert <stepga@nirgendwo.eu>
This commit is contained in:
parent
5caa5f6791
commit
55f471aa32
|
|
@ -4,6 +4,7 @@ package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
"log"
|
||||||
|
"runtime"
|
||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
@ -20,8 +21,16 @@ func (t *Telegraf) Run() error {
|
||||||
}
|
}
|
||||||
|
|
||||||
func getLockedMemoryLimit() uint64 {
|
func getLockedMemoryLimit() uint64 {
|
||||||
// From https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/resource.h#L35
|
var rLimitMemlock int
|
||||||
const rLimitMemlock = 8
|
|
||||||
|
switch runtime.GOOS {
|
||||||
|
case "dragonfly", "freebsd", "netbsd", "openbsd":
|
||||||
|
// From https://cgit.freebsd.org/src/tree/sys/sys/resource.h#n107
|
||||||
|
rLimitMemlock = 6
|
||||||
|
default:
|
||||||
|
// From https://elixir.bootlin.com/linux/latest/source/include/uapi/asm-generic/resource.h#L35
|
||||||
|
rLimitMemlock = 8
|
||||||
|
}
|
||||||
|
|
||||||
var limit syscall.Rlimit
|
var limit syscall.Rlimit
|
||||||
if err := syscall.Getrlimit(rLimitMemlock, &limit); err != nil {
|
if err := syscall.Getrlimit(rLimitMemlock, &limit); err != nil {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue