Skip to content

#174: Support CSV output from pidstat.#175

Open
tst-ppenev wants to merge 5 commits intosysstat:masterfrom
tst-ppenev:#174-pidstat-csv-output
Open

#174: Support CSV output from pidstat.#175
tst-ppenev wants to merge 5 commits intosysstat:masterfrom
tst-ppenev:#174-pidstat-csv-output

Conversation

@tst-ppenev
Copy link

  • Added a --csv <file_path> option to pidstat for enabling CSV output to a file.
  • Added a P_O_CSV flag that can be added to pidflag to indicate CSV should be output.
  • Added csv_write_header and csv_write_stats functions to pidstat.c for outputting CSV.
  • Added helper functions efprintf and csv_efprintf_s to common.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.

* Bug fix: The 'bytes written', 'bytes read' and 'write bytes cancelled'
  statistics that were output to CSV were calculated improperly, reporting the
  cumulative number of bytes since process start, rather than the number of
  bytes for each sample interval.

* Slight refactor to output CSV stats for children, or tasks, based on the
  `-T` command line option.
@tst-dmendyke
Copy link

Builds and executes OK

@soyuka
Copy link

soyuka commented Aug 14, 2020

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support CSV Output from pidstat

3 participants