Skip to content

oomparser - new constructor to support streaming of new/current OOM events only. #3716

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

jesseward
Copy link

Summary

This adds a new constructor NewFromNow that moves the /dev/kmsg reader offset to the end of the queue. Allowing the user to ignore OOM events that occurred prior to the creation of the OomParser object.

Examples

Create stream using New (default behaviour)

Returns all available OOM events in the kmsg buffer. This is the default behaviour and is not changed.

$ sudo go run oomexample/main.go 
I0727 20:31:50.742685 1989715 main.go:48] Reading the buffer. Output is &{393038 stress-ng-vm 2025-07-25 23:11:27.182087673 +0000 UTC m=-163223.536149722 /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice/cri-containerd-85a888cadb58adab390959abaa0db3996a9997193d137ed321dcf0e0b56c680b.scope /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice CONSTRAINT_MEMCG}
I0727 20:31:50.743393 1989715 main.go:48] Reading the buffer. Output is &{393053 stress-ng-vm 2025-07-25 23:11:27.910033673 +0000 UTC m=-163222.808203722 /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice/cri-containerd-85a888cadb58adab390959abaa0db3996a9997193d137ed321dcf0e0b56c680b.scope /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice CONSTRAINT_MEMCG}
I0727 20:31:50.744026 1989715 main.go:48] Reading the buffer. Output is &{393056 stress-ng-vm 2025-07-25 23:11:28.623308673 +0000 UTC m=-163222.094928722 /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice/cri-containerd-85a888cadb58adab390959abaa0db3996a9997193d137ed321dcf0e0b56c680b.scope /system.slice/docker-4876bd1d7f860bacc8df1c342f058bb861c41a328a1cce0b753eae6f0849b241.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-podd993a249_6fb5_48dc_90fe_5c176fa43a7f.slice CONSTRAINT_MEMCG}

Create stream using NewFromNow

When launched, old OOM events are ignored and net new events are reported (as seen at I0727 20:05:50.120013)

$ sudo go run oomexample/main.go -ignore_old
I0727 20:05:50.120013 1966714 main.go:48] Reading the buffer. Output is &{1967893 awk 2025-07-27 20:05:46.893944354 +0000 UTC m=+51.345637220 /system.slice/docker-8e95fa377f7d8be8aa72ddb5cf50b76111d3d6c4d89f2048c597a7b2fb6970b0.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-pod0997ebc7_7b70_4a20_9a87_c7eca4342fc9.slice/cri-containerd-cb0c72b671bad34ce5255356006d91fdd704506e8da2b51887168f29815ef9ac.scope /system.slice/docker-8e95fa377f7d8be8aa72ddb5cf50b76111d3d6c4d89f2048c597a7b2fb6970b0.scope/kubelet.slice/kubelet-kubepods.slice/kubelet-kubepods-burstable.slice/kubelet-kubepods-burstable-pod0997ebc7_7b70_4a20_9a87_c7eca4342fc9.slice CONSTRAINT_MEMCG}

Related

jesseward and others added 2 commits July 27, 2025 11:40
Ignores OOMs that occurred before the parser was created.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

cadvisor/utils/oomparser - Add constructor to (optionally) allow streaming of current+new OOMs only.
1 participant