This page describes the tools and procedure to use to identify the root cause of a CPU spike in a RedHat Linux environment.
We start by trying to build up a picture of the CPU resources available to the system. The kinds of questions we may have are:
Running the RedHat Linux "xxxxx" command answers most of the questions we may have.
% xxxxxxxxWe refer the reader to the xxxxxx man page for field by field descriptions of this output.
% nohup vmstat -a 1 <iterations> > vmstat.out &This command runs vmstat in the background (and wrapped with a nohup command) and redirects the output to a vmstat.out file. It will collect data with a 1 second granularity. Maybe a value of 604800, which collects data for a week, is appropriate for iterations. [If so, the output file could be quite large]. If the mean time between CPU peaks, is small (say daily) then a smaller value for
Please note that this level of granularity is necessary for a comprehensive insight into the consumption of this resource. A system administrator may well be running other tools that are also collecting data (sar) with a larger (e.g. 5 minute or 15 minute) granularity - but this output, though useful for capacity planning purposes, will not be helpful in the analysis of possibly short-lived CPU spikes.
Check the vmstat output to identify the time of the CPU spike, its duration, its amplitude, and whether, when CPU consumption is high, whether this CPU is in kernel, user or wait I/O? Check also for excessive paging.
Log top output to a file, for example with this command:
% nohup top -b -n <iterations> > top.out &which will collect "iterations" samples to an output file, top.out. Assuming a 3-second delay time, maybe a value of 201600, which collects data for a week, is appropriate for iterations. [If so, the output file could be quite large]. If the mean time between CPU peaks, is small (say daily) then a smaller value for
Analyze the top output to check if there one process consuming a lot of CPU, or several, or many? If it is just the java process that is consuming memory, see the next section. If processes other than java are responsible for the CPU peak, ascertain if these really need to run on this system.
Status icon key: