Wednesday, June 5, 2019

How to find out what processes were killed by OOM on Linux

Problem

Services with high memory utilization are dying sporadically.

Solution

Run the following command to get a list of processes killed by oom.

dmesg | egrep -i 'killed process'


Useful articles:

1. How to troubleshoot OOM
https://access.redhat.com/solutions/2612861

2. How to add swap file to Linux Azure VM
https://support.microsoft.com/en-us/help/4010058/how-to-add-a-swap-file-in-linux-azure-virtual-machines

vi /etc/waagent.conf
ResourceDisk.Format=y
ResourceDisk.EnableSwap=y
ResourceDisk.SwapSizeMB=xx
service walinuxagent restart

How to find out how long the process has been running on Linux

Problem

Need to find out how long process is running

Solution

In order to get time how long process is running, execute following command;

ps -o etime= -p <your pid>