Bash Utility scripts¶
This section describes the bash utilities that are compatible with DFTracer logs
Handling .pfw files¶
The DFTracer format with extension .pfw is uncompressed file which can be viewed using the following utilities.
vim : Edit .pfw files
cat, head, or tail: view portion of the pfw files
Handling .pfw.gz files¶
The DFtracer compressed format with .pfw extension can be first decompressed using gzip and then piped to the above .pfw utilities.
gzip -c -d `echo *.gz` | head
Extracting JSON data¶
Once the uncompressed data is parsed. The JSON utility jq can be used to parse args.
In each case we have to remove the first [ which has been added to support perfetto ui.
For uncompressed files
cat *.pfw | grep -i "[^#[]" | jq -c '.'
For compressed files
gzip -c -d `echo *.gz` | grep -i "[^#[]" | jq -c '.'
We can extract specific fields from these JSON lines as follows
jq -c ‘.name’: extracts all the names of events
jq -c ‘.cat’: extracts all the category of events
jq -c ‘.args.hostname’: extracts the fields from extra args like hostname in this case.
Useful querying using jq¶
Extract unique functions with their counts from traces.
cat *.pfw | grep -i "[^#[]" | jq -c '.name' | sort | uniq -c
Extract unique categories with their counts from traces.
cat *.pfw | grep -i "[^#[]" | jq -c '.cat' | sort | uniq -c
Extract unique process id and thread id combination with their counts from traces.
cat *.pfw | grep -i "[^#[]" | jq -c '"\(.pid) \(.tid)"' | sort | uniq -c
Extract min timestamp
cat *.pfw | grep -i "[^#[]" | jq -c '.ts | tonumber' | sort -n | tail -1
Extract max timestamp
cat *.pfw | grep -i "[^#[]" | jq -c '.ts | tonumber' | sort -n | tail -n 1
For more commands on jq refer to JQ Manual.