How to install and use SAR command (to Monitor system Performance) in Linux

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"

Introduction

System Activity Report (sar) is a Unix System V-derived system monitor command used to report on various system loads, including CPU activity, memory/paging, interrupts, device load, network and swap space utilization. Sar uses /proc filesystem for gathering information.

In this tutorial, We will show you how to install and use SAR command in Linux.

Installation

  • So sar may not installed by default. We need to install sysstat before using it
dnf install sysstat -y       #CentOS
sudo apt install sysstat -y  #Ubuntu
  • Also start and enable sysstat service
systemctl start sysstat.service && systemctl enable sysstat.service
  • Then verify the sar version
sar -V

Using SAR command

Syntax:

sar -[options] [time_interval]
  • To report CPU details total 10 times with the interval of 2 seconds.
sar -u 2 10
  • To display the memory used, memory free, available cache, buffers total 5 times with the interval of 1 second. 
sar -r 1 5
  • Show file systems mounted on the device total 5 times with the interval of 2 seconds. 
sar -F 2 5
  • Display the block devices details total 4 times with the interval of 3 second. 
sar -d 3 4
  • Also display, run queue length, number of processes and load average.
sar -q 1 4
  • Show cpu usage for given core. (For mine i will select 2 core)
sar -P 1 2 2
  • For displaying network interface, network speed, IPV4, TCPV4, ICMPV4 network traffic and errors for total 4 times and 2 seconds interval time , run
sar -n DEV 2 4 | egrep -v lo
  • Show the process, kernel thread, i-node, and the file tables 
sar -v 1 4
  • report statistics about swapping 
sar -S 1 4
  • Also report I/O like transaction per second, read per second, write per second 
sar -b 1 5
  • Show context switching, number of processes created per second and number of swap per second 
sar -w 2 3
  • Show paging statistics KBs paged-in/sec, KBs paged-out/sec, andpagefault/sec 
sar -B 1 4

NOTE: If the interval command is set to zero, average statistics from the time system started are presented. If the count is not provided and the interval is given, statistics are provided continuously after every interval. 

Conclusion

That’s it.

We illustrated how to install and use SAR command in Linux.

Thanks

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
MQ-Jr
MQ-Jr
unixcop Admin

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook