2016/09/01
KAICHO: s_naray[at]yahoo[dot]co[dot]jp
¦not the plane mail address to avoid SPAM

sar2csv - convert tool from text-sar-files to a csv-file

¡Abstract

sar2csv is a tool which generates a csv(comma separated values)-file from text-sar-files(generated by "sar -A") for Linux.

If you have binary sar files, sadf command which is provided by sysstat package is so useful to do same as this. ksar is another great tool which generates a graph from sar binary files.

However, this tool is still useful for the unfortunate case you do not have binary sar files but only have text one.

¡download

package name SRPM package RPM package(for RHEL/CentOS/OracleLinux 5/6/7)
sar2csv sar2csv-0.3-1.src.rpm sar2csv-0.3-1.noarch.rpm

¡How to install

This is mainly for RHEL5/6/7 including RHEL clone distoributions(ex. CentOS, Scientific Linux, Oracle Linux).

Just install sar2csv package like:
 # rpm -Uvh sar2csv-0.3-1.noarch.rpm

You may need perl module "Time::ParseDate" before installing sar2csv. The module can be installed from CPAN by running command "cpan Time:ParseDate", or install the module by installing appropriate rpm package below which includes it.

Distribution PackageName example where you can get
EL5 perl-Time-ParseDate External Package
EL6 perl-Time-modules Standard Package
EL7 perl-Time-ParseDate External Package

¡How to use

If you need csv file which is generated by all existent sar files on /var/log/sa/, just run "sar2csv /var/log/sa", Then you can get sar-XXXX.csv where XXXX is random charactors. For example:

# sar2csv /var/log/sa
Processing sar file "/var/log/sa/sar25"...
Processing sar file "/var/log/sa/sar26"...
Processing sar file "/var/log/sa/sar27"...
Processing sar file "/var/log/sa/sar28"...
Processing sar file "/var/log/sa/sar29"...
Processing sar file "/var/log/sa/sar30"...
Processing sar file "/var/log/sa/sar31"...
Generating .csv file: "sar-84lt.csv"
Done.
#

detailed command line syntax:

usage:  sar2csv [options] sar_datadirs_or_sar_files
description:
        This script generates a csv file from sar text files(output of
        'sar -A -f /var/log/sa/sa01').
options:
        -o <output_csv_file>
        --output <output_csv_file>
                This specifies the csv file which is generated by this
                command. default = "sar-XXXX.csv"
                XXXX will be filled with unique characters not to overwrite
                existing files.
        --nonamecheck
                This specifies "do not check filename". By default, this
                script check filename whether it is "sar[0-9][0-9]" to
                decide if it is a valid sar file. However, with this
                option, this script just try to analyse any files as a
                sar file.

¡CSV file example

here(4MB) is the CSV file which is generated by sar2csv. The server logged the sar files has 4 CPUs and several block devices, you can see the data for each cpu/block-device are separatedly corrected.

¡License

WTFPL.

¡Support

in a support bbs or e-mail.