Search CPU usage rate of the process method
Problem Description
Node newspaper CPU usage is high, or even "ALM-12016 CPU usage exceeds threshold" alert, locate what process CPU usage rate.
Process
For sustained high cpu process:
1. In the correspondent node "top" command, and keyboard input "C", i.e. sorting process according to CPU utilization.
2. Run ps -ef | grep <PID CPU usage rate of>
For more information about the confirmation process, verify that the log of the process. Check the component logs, taking up high CPU is normal.
For cpu sporadic excessive treatment:
1. In the operating system logs "/var/log/osinfo/statistics/ps.txt" will record the results every two minutes to perform a ps command.
However, this information is only recorded basic information processes
2. Use the following command, you can print out the top ten CPU utilization process information
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head
3. Create the following shell file checkcpu.sh in the corresponding node
#!/usr/bin/env bash
logFile=/var/log/Bigdata/checkCpuUsage.log
delayTime=30 # seconds between each excute, default value is 30 seconds
while( true )
do
echo `date` >> $logFile
echo "USER PID %CPU %MEM VSZ RSS TTY STAT START TIME COMMAND " >> $logFile
ps aux|head -1;ps aux|grep -v PID|sort -rn -k +3|head >> $logFile
sleep $ delayTime
echo " " >> $logFile
done
4. Background to execute the script
In the shell node performs the following files in the background
chmd 700 /opt/checkcpu.sh
nohup /opt/checkcpu.sh > /dev/null 2>/dev/null &
5. View Log
View /var/log/Bigdata/checkCpuUsage.log log, if there is more information to print high CPU usage of the process.
6. Stop process
In the node performs "ps -ef | grep checkcpu.sh | grep -v grep" to find the pid of the process, kill can.