Tracking historical CPU usage
In this recipe, we are going to show how to use the sar
command in combination with various switches to analyze historical CPU load during some time in the past.
Getting ready
The commands used in this recipe have been performed on a CentOS Linux machine. The command output may vary in other Linux and Unix-based operating systems.
How to do it...
The sar command when used with the -u
switch is used to display CPU statistics. When used this way, the sar command will report on the current day's activities.
If we are looking to analyze the CPU statistic over some time period in the past we would need to use the -f switch in conjunction with the -u
switch of the sar
command. The -f
option is followed by the files that sar
uses to report on statistics for different days of the month, and these files are usually located in the /var/log/sa
directory and usually have a naming convention of sadd
, where dd
represents the numeric day of the month whose values are in a range...