Sunday, September 21, 2014

Finding a process that is consuming CPU excessively


  • Look at top output




  • Next check ps output to see the location on the file system where the process is running from 


$ps -eo pcpu,pid,user,args | sort -k 1 -r | head -10
%CPU   PID USER     COMMAND
59.5 11286 ec2-user      /bin/sh /tmp/ismp002/1978898.tmp
59.1 22608 ec2-user      /bin/sh /tmp/ismp002/2326448.tmp
 5.8 22861 ec2-user     ./engine -Djmx_port=5555
 4.7 22865 ec2-user      ./engine --innerProcess


  • Run strace to see what calls are consuming the cpu cycles


$strace -c -p 11286
Process 11286 attached - interrupt to quit
Process 11286 detached
% time     seconds  usecs/call     calls    errors syscall
------ ----------- ----------- --------- --------- ----------------
 90.77    0.667227         273      2447           clone
  6.38    0.046881          10      4892      2446 wait4
  1.33    0.009747           0     22014     19568 stat
  1.02    0.007489           0     31802           rt_sigprocmask
  0.12    0.000864           0      4893           rt_sigaction
  0.11    0.000826           0      2446      2446 ioctl
  0.11    0.000819           0      2446           read
  0.09    0.000659           0      2446      2446 lseek
  0.08    0.000579           0      2446           rt_sigreturn
------ ----------- ----------- --------- --------- ----------------
100.00    0.735091                 75832     26906 total


  • In the above case the /tmp/ismp002/1978898.tmp file was not on the system, so it looks like a zombie process that was left running on the system
  • do a kill -9 on the unwanted processes



1 comment:

  1. Do you know what that process is for (/bin/sh /tmp/ismp002/1978898.tmp) ? I have a very similar process running on one of our production Linux servers, but I cannot figure out what it is. I assume the integer name was just a PID for something that sh ran, but I'm not sure what ismp002 is.

    Thank you

    ReplyDelete