Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions puppet-top-api-calls.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,23 +49,26 @@ if [[ $graph && $borrow ]]; then
unset graph
fi

perl_command=(perl -ne '/^\S+ \S+ \S+ \[[^\]]+\] "[A-Z]+ [^ "]+? HTTP\/[0-9.]+" [0-9]{3} [0-9]+|- "[^"]*" "[^"]*"/ && print')

for file in "$@"; do
printf 'Processing: %s\n' "$file" >&2

case "${file##*.}" in
gz)
read_cmd=(gunzip -c)
read_cmd=("gunzip" "-c" "--" "$file")
;;
*)
read_cmd=(cat)
# UUOC, but it makes setting up read_cmd easier
read_cmd=("cat" "--" "$file")
;;
esac

case "${file##*/}" in
puppetserver-access*)
if [[ $borrow ]]; then duration_field=0; else duration_field=2; fi

"${read_cmd[@]}" "$file" \
"${read_cmd[@]}" | "${perl_command[@]}" \
| gawk -v n="$duration_field" \
'BEGIN { print "date,path,duration" }
{
Expand Down