FreeKB - sar command (sysstat CPU statistics)
Linux Commands - sar command (sysstat CPU statistics)

Use apt-get or yum to install sysstat.

~]# yum install sysstat

 

The ps command can be used to determine if your system is using init or systemd. If PID 1 is init, then you will use the service command. If PID 1 is systemd, then you will use the systemctl command.

If your system is using systemd, use the systemctl command to start and enable sysstat.

systemctl enable sysstat
systemctl start sysstat
systemctl status sysstat

 

If your system is using init, use the chkconfig and service commands to start and enable sysstat.

chkconfig sysstat on
service sysstat start
service sysstat status

 

The /etc/cron.d/sysstat file runs sa1 once every 10 minutes and saves system monitoring data at /var/log/sa/sa##. At 23:53, the /var/log/sa/sa# file is saved to /var/log/sa/sar##.

# run system activity accounting tool every 10 minutes
*/10 * * * * root /usr/lib64/sa/sa1 1 1
# generate a daily summary of process accounting at 23:53
53 23 * * * root /usr/lib64/sa/sa2 -A

 


SAR command

One of the most popular components of sysstat is the SAR command. By default, the SAR command prints the system utilization usage every every 10 minutes and also the system average.

~]# sar
              CPU  %user  %nice  %system  %iowait  %steal  %idle
08:00:01 CDT  all  0.45   0.00    0.11     0.00     0.00   99.34
08:10:01 CDT  all  0.04   0.00    0.00     0.00     0.00   99.96
08:20:01 CDT  all  0.21   0.00    0.00     0.00     0.00   99.79 
average:      all  0.23%  0.00%   0.04%    0.00%    0.00%  99.70%

 

The SAR 1 3 command can be used to get the system average every 1 second 3 times.

~]# sar
              CPU  %user  %nice  %system  %iowait  %steal  %idle
08:00:01 CDT  all  0.45   0.00    0.11     0.00     0.00   99.34
08:00:02 CDT  all  0.04   0.00    0.00     0.00     0.00   99.96
08:00:03 CDT  all  0.21   0.00    0.00     0.00     0.00   99.79 
average:      all  0.23%  0.00%   0.04%    0.00%    0.00%  99.70%

 



Add a Comment




We will never share your name or email with anyone. Enter your email if you would like to be notified when we respond to your comment.




Please enter 77a75 in the box below so that we can be sure you are a human.




Comments

Web design by yours truely - me, myself, and I   |   jeremy.canfield@freekb.net   |