sysstat
sysstat copied to clipboard
#174: Support CSV output from `pidstat`.
- Added a
--csv <file_path>
option topidstat
for enabling CSV output to a file. - Added a
P_O_CSV
flag that can be added topidflag
to indicate CSV should be output. - Added
csv_write_header
andcsv_write_stats
functions topidstat.c
for outputting CSV. - Added helper functions
efprintf
andcsv_efprintf_s
tocommon.c
for writing a formatted string to a file stream with error reporting, and for writing a CSV string quoted according to RFC 4180 respectively.
Fixes #174.
Builds and executes OK
btw it's really easy to transform a pidstat output to csv using https://github.com/shenwei356/csvtk. Execute this script with as first argument the result of pidstat
. For example:
pidstat -h -H -p SELF 1 10 > stat.txt
bash to-csv.sh stat.txt
With to-csv.sh
containing:
#!/bin/bash
temp=${1/txt/temp}
csv=${1/txt/csv}
head -n 3 $1 | tail -n 1 | sed 's/# //' > $temp
sed '1d' $1 >> $temp
csvtk space2tab $temp > $csv
rm $temp