Got it

Identifying Processes with High CPU Usage

134 0 0 0 0

Hello, everyone! 

I will share with you how to deal with the problem of identifying processes with high CPU usage.

Symptom

The CPU usage of a node is high or even exceeds the threshold.

CPU Usage Remains High

  1. Run the top command on the involved node and press P on the keyboard (to sort the processes by CPU usage).

    1_en-us_image_0228249375.png

  2. Run ps -ef | grep <PID of the process with high CPU usage>.

    Check detailed information about the process and query its log. Check whether the high CPU usage is normal.

  3. Run the following command to query the top 10 processes that occupy the most CPU resources:

    ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

    1_en-us_image_0228249376.png

CPU Usage Is High Occasionally

  1. Query the /var/log/osinfo/statistics/ps.txt file. It records the results of the ps command that is executed every minute.

    The file records only the basic information of the processes.

    1_en-us_image_0228249377.png

  2. Run the following command to query the top 10 processes that occupy the most CPU resources:

    ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head

  3. Create the checkcpu.sh file on the involved node. logFile is the log file and delayTime is the execution interval (s).

    #!/usr/bin/env bashlogFile=/var/log/Bigdata/checkCpuUsage.logdelayTime=30  # seconds between each excute, default value is 30 secondswhile( true )doecho `date` >> $logFileecho "USER        PID %CPU %MEM    VSZ RSS TTY      STAT START TIME COMMAND " >> $logFileps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head >> $logFilesleep $delayTimeecho " " >> $logFiledone

  4. Run the following scripts at the background:

    chmd 700 /opt/checkcpu.sh

    nohup /opt/checkcpu.sh  > /dev/null  2>/dev/null  &

  5. Query the /var/log/Bigdata/checkCpuUsage.log file and check for information about high CPU usage.

    If a Java process is using great CPU resources, the common cause is that the memory is insufficient and garbage collection is frequently triggered, causing high CPU usage.

  6. Stop the check script process.

    On the node, run ps -ef | grep checkcpu.sh | grep -v grep. Find the PID and kill the process.


We warmly welcome you to enjoy our community!

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.