DEV Community

Cover image for Unveiling Linux Command's - sar
Syam SV
Syam SV

Posted on

Unveiling Linux Command's - sar

In the world of computers, the SAR (System Activity Reporter) command is like a magic tool. It helps us understand how our computer is doing and where it might need some help. In this article, we'll take a look at the SAR command and see how it can tell us interesting things about our computer.

What is SAR?

SAR stands for System Activity Reporter. It's like a detective that watches over our computer and takes notes about what it's doing. It looks at what's happening on our computer and makes reports about it. It can tell us things like how busy our computer is, how much memory it's using, how the network is behaving, and much more. It's like a data historian that keeps track of what our computer has been up to.

For detailed matrix information, please refer to here* and here

sar [ options ] [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -b 1 10
Enter fullscreen mode Exit fullscreen mode
sar -r 1
Enter fullscreen mode Exit fullscreen mode

SAR can do many helpful jobs for us. Let's look at some of them and see what they mean

Checking I/O and Transfer Rate

Imagine your computer is sending and receiving data. SAR can tell us how busy it is doing that. It can count how many times it's doing these jobs and how much data is being sent and received every second.

sar -b [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -b 1 10
Enter fullscreen mode Exit fullscreen mode

Paging Statistics

Sometimes, our computer needs to get information from the hard drive. This is called paging. SAR can tell us how often this happens and how much data is being moved between the hard drive and the computer's memory.

sar -B [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -B 1 10
Enter fullscreen mode Exit fullscreen mode

Network Numbers

If our computer is connected to the internet, SAR can tell us how much data is going in and out. It can show us how many packets of data are being sent and received. This helps us understand if our internet connection is fast or slow.

sar -n [options] [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -n DEV 1 10
sar -n TCP,UDP 1 10
Enter fullscreen mode Exit fullscreen mode

Load and Queue

When our computer is doing many things at once, it has a "load." SAR can tell us how heavy this load is. It can also tell us how many things are waiting to be done. This is like knowing how many people are waiting in line at a store.

sar -q [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -q 1 10
Enter fullscreen mode Exit fullscreen mode

Memory and Swap Info

Our computer uses memory to work. SAR can show us how much of this memory is being used. It can also tell us if the computer is using "swap space," which is like extra memory.

sar -r [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -r 1 10
Enter fullscreen mode Exit fullscreen mode

CPU Usage

The "brain" of our computer is called the CPU. SAR can tell us how busy the CPU is. It can say if it's mostly being used by programs, or if it's waiting for something to happen.

sar -u [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -u 1 10
Enter fullscreen mode Exit fullscreen mode

Page Swapping

Sometimes, the computer needs to exchange data quickly. This is called "swapping." SAR can tell us if this is happening a lot and if it's causing any problems.

sar -W [ <interval> [ <count> ] ]
Enter fullscreen mode Exit fullscreen mode

example:

sar -W 1 10
Enter fullscreen mode Exit fullscreen mode

Conclusion

SAR is like a helpful friend that watches over our computer. It tells us all sorts of things about what's happening inside. Whether it's how busy our computer is, how much memory it's using, or how well the internet is working, SAR gives us answers. So, the next time you're curious about how your computer is performing, remember to ask SAR! Keep in mind that this article provides a simplified overview of SAR, and if you're interested in diving deeper, be sure to refer back to the detailed explanations above.

Top comments (0)