How to install Sar and Ksar on RHEL-based distributions

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

Hello, friends. In this post, you will learn how to install Sar and Ksar on RHEL-based distributions. The procedure is easy. Let’s go.

Sar is a tool that allows you to obtain system information. It works similar to a monitoring tool with the great advantage of being easy and simple to use.

Some information you can get with Sar are:

  • CPU utilization
  • Memory paging and its utilization
  • Network I/O, and transfer statistics
  • Process creation activity

Let’s go for it.

Install Sar on RHEL-based distributions

Sar is present in the official repositories of RHEL and therefore of RHEL-based distributions like Rock Linux. So, first update the system

sudo dnf update

And then, install it by running

sudo dnf install sysstat
Install Sar command on RHEL
Install Sar command on RHEL

This will be enough, and you will be able to check the Sar version.

sar -V

Sample output:

sysstat version 12.5.4
(C) Sebastien Godard (sysstat <at> orange.fr)

Sar is a system service, so we have to start it manually

sudo systemctl enable --now sysstat

By default, the frequency at which Sar monitors the system is 10 minutes. We can always modify it by running.

sudo systemctl edit sysstat-collect.timer

And in the timer section, replace 10 with the number of minutes you want Sar to monitor.

Change the default time for Sar
Change the default time for Sar

Apply the changes by running

sudo systemctl daemon-reload

Now test Sar with some of its options.

sar 2 4

This indicates that it will refresh every 2 seconds and with four repetitions. This is just a test.

You will get an output like this

Using Sar to monitor Linux
Using Sar to monitor Linux

Now Sar is working.

Install KSar to get graphing from Sar

ksar is a sar graphing tool that can graph for now Linux, macOS and solaris sar output. sar statistics graph can be output to a PDF file. It requires Java, so you can use it on many operating systems.

So, download it from this link or by running

wget https://github.com/vlsi/ksar/releases/download/v5.2.3/ksar-5.2.3-all.jar

And then run it with the java command.

java -jar ksar-5.2.3-all.jar

You will see this screen

Ksar main screen
Ksar main screen

Then, we have to generate the data from the server where Sar is. To do this run.

LC_ALL=C sar -A > ~/sarfile

The -A parameter indicates that it will collect all possible statistics. It will also place them in the user’s HOME directory, but you can use any other location.

Now with Ksar open, go to the data menu, choose the Load from Text file option and select the file from its location.

You will see something like this

Ksar screen after loading the text file
Ksar screen after loading the text file

Now, in the Export menu you can generate the PDF which you can open with a desktop application

PDF report from Sar using KSar
PDF report from Sar using KSar

Conclusion

Monitoring is an important thing, and it always helps to have simple tools to get relevant information about how the system is doing.

Everything Linux, A.I, IT News, DataOps, Open Source and more delivered right to you.
Subscribe
"The best Linux newsletter on the web"
Angelo
Angelo
I am Angelo. A systems engineer passionate about Linux and all open-source software. Although here I'm just another member of the family.

LEAVE A REPLY

Please enter your comment!
Please enter your name here

Latest articles

Join us on Facebook