How to convert sa to sar which is competible to ksar grapher tool.

In Linux, sysstat package installs tools like sar. It will setup a cron job to run sar to collect the output periodically. The output will be at /var/log/sa. At the end of each day, it will convert the file /var/log/sa to sar which is stored in /var/log/sar. The sar file can be used to generate graphs to show the CPU, Memory, IO and etc of the server for that particular day.

What if you need to generate the graph before the day ends?
Good news is that you can convert the sa file to sar manually at any time.

To convert sa to sar and save it to a file called sar_output.
[root@myserver]# sar -A -f /var/log/sa >> /var/log/sar_output

However you will notice that the sar file generated cannot be used to generate the graph from ksar grapher tool.
Question is WHY???

Try to open the sar file and via the output. You will notice that the time column contains AM/PM. In order for ksar grapher to work you will need to convert these timing to 24 hour format.

You will be thinking GREAT, more work and now you will need to learn bash inorder to do the conversion on the sar file. Luckily there is a parameter that we can set prior generating the sar file that will generate the sar file using 24 hour format.

To generate sar file that use 24 hour format.
[root@myserver]# LC_ALL=C; sar -A -f /var/log/sa >> /var/log/sar_output

*Note: LC_ALL=C is the parameter that we need to set inorder to get the sar file in 24 hour format.

If you need to generate utilization graphs for several days, you can do it the hard way which is generating them one by one from each day's sar file. Good news is that there is an easier way to do this. You can combine all the sar files needed into one and use that to input to ksar grapher tool to generate the graph.

To combine several sar files into one.
[root@myserver]# cat sar1 sar2 sar3 >> sar_all