oom killer
OOM user check script
nano check_oom_users.sh
chmod +x check_oom_users.sh
#!/bin/bash
# File containing the log entries
LOG_FILE="/var/log/messages"
# Check if the log file exists
if [ ! -f "$LOG_FILE" ]; then
echo "Log file does not exist: $LOG_FILE"
exit 1
fi
# Pattern to extract UID from OOM messages
PATTERN="oom_memcg.+,task_memcg.+,task=.+,pid=.+,uid="
# Extract UIDs and count occurrences
grep -oP "$PATTERN[0-9]+" $LOG_FILE | awk -F'uid=' '{print $2}' | sort | uniq -c | while read count uid; do
# Convert UID to username
username=$(getent passwd "$uid" | cut -d: -f1)
if [ -z "$username" ]; then
username="UID $uid (no username found)"
fi
echo "User $username has hit OOM $count times."
done