A lightweight daemon to monitor Linux OOM (Out of Memory) killer events and send notifications to Slack. This is a Go implementation inspired by the original Rust-based oom-notifier, simplified to support only Slack notifications.
For reference visit: https://gallery.ecr.aws/r3x5s3v3/oom-notifier
- Monitors
/dev/kmsgfor OOM killer events - Captures full command line of killed processes
- Sends real-time notifications to Slack
- Lightweight and efficient with minimal dependencies
- Linux system with access to
/dev/kmsg(requires root/privileged access) - Go 1.21 or higher (for building from source)
- Slack webhook URL
go mod download
go build -o ./oom-notifier ./cmd/oom-notifierBuild the Docker image:
docker build -t oom-notifier-go .Run the container:
docker run --privileged \
-v /proc:/proc:ro \
-v /dev/kmsg:/dev/kmsg:ro \
oom-notifier-go \
--slack-webhook "https://hooks.slack.com/services/YOUR/WEBHOOK/URL" \
--slack-channel "#alerts"The daemon requires root privileges to access /dev/kmsg:
sudo ./oom-notifier \
--slack-webhook "https://hooks.slack.com/services/YOUR/WEBHOOK/URL" \
--slack-channel "#oom-notifications"--slack-webhook: Slack webhook URL (required)--slack-channel: Slack channel to send notifications (default: "#alerts")--process-refresh: Process cache refresh interval in seconds (default: 5)--kernel-log-refresh: Kernel log check interval in seconds (default: 10)
LOGGING_LEVEL: Set logging verbosity (default: "info")
To run as a DaemonSet on Kubernetes:
- Create a ConfigMap with your Slack webhook:
apiVersion: v1
kind: ConfigMap
metadata:
name: oom-notifier-config
data:
slack-webhook: "https://hooks.slack.com/services/YOUR/WEBHOOK/URL"
slack-channel: "#oom-alerts"- Deploy the DaemonSet (see
k8s/daemonset.yamlfor a complete example)
The Go implementation maintains the core architecture of the original Rust version:
- Process Cache: Continuously refreshes a cache of running processes and their command lines
- Kernel Log Monitor: Monitors
/dev/kmsgfor OOM killer messages - Event Processing: When an OOM event is detected, retrieves the full command line from the cache
- Slack Notification: Sends formatted notifications to the configured Slack channel
This Go implementation:
- Supports only Slack notifications (removed Syslog, Elasticsearch, and Kafka)
- Simplified codebase for easier maintenance
- Uses standard Go libraries and minimal dependencies
Licensed under the Apache License, Version 2.0 - see https://www.apache.org/licenses/LICENSE-2.0 for details.