Adding memory pressure and OOM-kill checks to a host status command
What happened
I extended a host check command with memory pressure and OOM-kill checks. I wanted an early warning for memory problems. It should also tell me when it's time to move to a bigger host.
The fix / What I built
I added three new checks:
- Memory use, from
free -m. - Swap use.
- Out-of-memory (OOM) kill events from the kernel log, over a recent window.
The thresholds are simple:
- Warn when available memory or swap headroom runs low.
- Fail on any OOM kill of an application container.
Why it works
Disk and container-state checks only show the symptom. By the time a container has restarted several times, the memory problem has been going on for a while. Available memory and swap show the pressure building up. The kernel log records an OOM kill even if the container came back on its own and looks healthy now.
A window of several days means a kill that happened over a weekend still shows up on Monday. Failing on any OOM kill is deliberately strict. On a small host, I want to hear about every one.
The lesson is to watch memory pressure and OOM events directly. Don't wait for the downstream symptoms.