sysstat
sysstat copied to clipboard
#174: Support CSV output from `pidstat`.
- Added a
--csv <file_path>option topidstatfor enabling CSV output to a file. - Added a
P_O_CSVflag that can be added topidflagto indicate CSV should be output. - Added
csv_write_headerandcsv_write_statsfunctions topidstat.cfor outputting CSV. - Added helper functions
efprintfandcsv_efprintf_stocommon.cfor 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