Skip to content

Instantly share code, notes, and snippets.

@jacaetevha
Created October 3, 2013 04:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jacaetevha/6805107 to your computer and use it in GitHub Desktop.
Save jacaetevha/6805107 to your computer and use it in GitHub Desktop.
Parses a Heroku log (defaults to /var/log/heroku, but you can pass it a log file as the first argument to the script), then prints out the dyno, the error code, the count, and the percentage of the total.
#!/bin/bash
# ---------------
# Example output:
# ---------------
# Dyno Count % of Total
# app[web.1] 103 14.33%
# app[web.2] 140 19.47%
# app[web.3] 111 15.44%
# app[web.4] 111 15.44%
# app[web.5] 123 17.11%
# app[web.6] 131 18.22%
LOG=${1:-/var/log/heroku}
grep 'app\[web.' $LOG | grep 'Started' | awk 'BEGIN{printf "%10s %10s %11s\n", "Dyno", "Count", "% of Total"}{a[$5]++;total++}END{for(i in a){printf "%10s %10s %10.2f%%\n",i, a[i], a[i]/total*100;}}'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment