Last active
December 10, 2015 09:39
-
-
Save avdgaag/4415801 to your computer and use it in GitHub Desktop.
Shell one-liner to create a histogram from a log file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export COL=$COLUMNS; awk -F '[ ()]|ms' '/\[CatalogItem\] Retrieved/ { c[int($8 / $6 / 100) * 100 + 50] += $6 } END { for(l in c) { print l, c[l] } }' production.log | awk 'BEGIN { max = 0 } { if($2 > max) max = $2; c[$1] = $2 } END { for(l in c) { printf("%5d %d\n", l, c[l] / max * (ENVIRON["COL"] - 7)) } }' | awk '{ r = ""; s = $2; while(s-- > 0) { r = r "#" }; printf("%6d %s\n", $1, r); }' | sort -n |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment