Input multiple files for SAR command

user3795293 picture user3795293 · Jul 1, 2014 · Viewed 7.2k times · Source

I am trying to input multiple sar files for a graph I am generating. I can input the files one at a time like so:

LC_ALL=C sar -A -f /var/log/sa/sa05 >> /tmp/sar.data3.txt

This systax does not work, but this is the idea of what I'm trying to do:

LC_ALL=C sar -A -f /var/log/sa/sa* >> /tmp/sar.data3.txt

Answer

AKS picture AKS · Jul 1, 2014

sa* files seems to be binary files i.e. cat on one of the saXX file will not echo valid human readable words. The following can be used to see its human readable contents.

strings /var/log/sa/sa01 or saXX 

The file you might need is sarXX: you can try "LC_ALL=C ...." command as you mentioned above in place of just what I mentioned below.

for file in /var/log/sa/sar*; do sar -A -f "$file"  >> /tmp/sar.data3.txt; done

Now, the following command will show/have what you need.

cat /tmp/sar.data3.txt 

I didn't see all the options of SAR command, would recommend you to check if there is any which would support sar* or sar??