mirror of
https://github.com/prometheus/prometheus
synced 2024-12-26 00:23:18 +00:00
prometheus: log virtual memory limits
Signed-off-by: Simon Pasquier <spasquie@redhat.com>
This commit is contained in:
parent
3b5dea4e6d
commit
ba22b10113
@ -21,12 +21,30 @@ import (
|
|||||||
"syscall"
|
"syscall"
|
||||||
)
|
)
|
||||||
|
|
||||||
// FdLimits returns the soft and hard limits for file descriptors
|
var unlimited int64 = syscall.RLIM_INFINITY
|
||||||
func FdLimits() string {
|
|
||||||
flimit := syscall.Rlimit{}
|
func limitToString(v uint64) string {
|
||||||
err := syscall.Getrlimit(syscall.RLIMIT_NOFILE, &flimit)
|
if v == uint64(unlimited) {
|
||||||
|
return "unlimited"
|
||||||
|
}
|
||||||
|
return fmt.Sprintf("%d", v)
|
||||||
|
}
|
||||||
|
|
||||||
|
func getLimits(resource int) string {
|
||||||
|
rlimit := syscall.Rlimit{}
|
||||||
|
err := syscall.Getrlimit(resource, &rlimit)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Fatal("Error!")
|
log.Fatal("Error!")
|
||||||
}
|
}
|
||||||
return fmt.Sprintf("(soft=%d, hard=%d)", flimit.Cur, flimit.Max)
|
return fmt.Sprintf("(soft=%s, hard=%s)", limitToString(rlimit.Cur), limitToString(rlimit.Max))
|
||||||
|
}
|
||||||
|
|
||||||
|
// FdLimits returns the soft and hard limits for file descriptors.
|
||||||
|
func FdLimits() string {
|
||||||
|
return getLimits(syscall.RLIMIT_NOFILE)
|
||||||
|
}
|
||||||
|
|
||||||
|
// VmLimits returns the soft and hard limits for virtual memory.
|
||||||
|
func VmLimits() string {
|
||||||
|
return getLimits(syscall.RLIMIT_AS)
|
||||||
}
|
}
|
@ -19,3 +19,8 @@ package main
|
|||||||
func FdLimits() string {
|
func FdLimits() string {
|
||||||
return "N/A"
|
return "N/A"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// VmLimits not supported on Windows
|
||||||
|
func VmLimits() string {
|
||||||
|
return "N/A"
|
||||||
|
}
|
@ -223,6 +223,7 @@ func main() {
|
|||||||
level.Info(logger).Log("build_context", version.BuildContext())
|
level.Info(logger).Log("build_context", version.BuildContext())
|
||||||
level.Info(logger).Log("host_details", Uname())
|
level.Info(logger).Log("host_details", Uname())
|
||||||
level.Info(logger).Log("fd_limits", FdLimits())
|
level.Info(logger).Log("fd_limits", FdLimits())
|
||||||
|
level.Info(logger).Log("vm_limits", VmLimits())
|
||||||
|
|
||||||
var (
|
var (
|
||||||
localStorage = &tsdb.ReadyStorage{}
|
localStorage = &tsdb.ReadyStorage{}
|
||||||
|
Loading…
Reference in New Issue
Block a user