oomwatch

package
v1.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 26, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package oomwatch provides a way to detect near OOM conditions.

Index

Constants

View Source
const (
	// MemoryLimitFile is the cgroup v1 memory.limit_in_bytes filepath relative
	// to DefaultCgroupPath.
	MemoryLimitFile = "memory/memory.limit_in_bytes"
	// MemoryUsageFile is the cgroup v1 memory.usage_in_bytes filepath relative
	// to DefaultCgroupPath.
	MemoryUsageFile = "memory/memory.usage_in_bytes"

	// MemoryMaxFile is the cgroup v2 memory.max filepath relative to
	// DefaultCgroupPath.
	MemoryMaxFile = "memory.max"
	// MemoryCurrentFile is the cgroup v2 memory.current filepath relative to
	// DefaultCgroupPath.
	MemoryCurrentFile = "memory.current"
)

Variables

View Source
var (
	// DefaultCgroupPath is the default path to the cgroup directory within a
	// container. It is used to discover the cgroup files if they are not
	// provided.
	DefaultCgroupPath = "/sys/fs/cgroup/"
)

Functions

This section is empty.

Types

type Watcher

type Watcher struct {
	// contains filtered or unexported fields
}

Watcher can be used to detect near OOM conditions.

func New

func New(memoryMaxPath, memoryCurrentPath string, memoryUsagePercentThreshold uint8, interval time.Duration, logger logr.Logger) (_ *Watcher, err error)

New returns a new Watcher with the given configuration. If the provided paths are empty, it will attempt to discover the paths to the cgroup files. It returns an error if the paths cannot be discovered or if the provided configuration is invalid.

func (*Watcher) Watch

func (w *Watcher) Watch(ctx context.Context) context.Context

Watch returns a context that is canceled when the system reaches the configured memory usage threshold. Calling Watch multiple times will return the same context.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL