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
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??
You can use the find command to aggregate the files and concatenate them into your output file with something similar to:
find /var/log/sa -type f -name "sa*" \
-exec LC_ALL=C sar -A -f '{}' >> /tmp/sar.data3.txt \;
What you are attempting to do looks to be failing due to sar
not accepting multiple input files with the -f option. In the future, you may consider using the -o
option to prepare files containing the data you want in records that can later be output with the -f
option
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With