Skip to content

Instantly share code, notes, and snippets.

@PeterGrace
Forked from JCotton1123/parse-slow-log.sh
Created June 21, 2018 17:18
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 PeterGrace/3e8ea03adb5319d6d733dd58ae3381fb to your computer and use it in GitHub Desktop.
Save PeterGrace/3e8ea03adb5319d6d733dd58ae3381fb to your computer and use it in GitHub Desktop.
Parse php-fpm slow log
## Slow requests grouped by function call
cat /var/log/php-fpm/www-slow.log | grep -A 1 script_filename | \
grep -v script_filename | grep -v -e "--" | cut -c 22- | sort | uniq -c | sort -nr
## Slow requests grouped by minute
cat /var/log/php-fpm/www-slow.log | grep 'pool www' | \
cut -d' ' -f2 | sort | cut -d: -f1,2 | uniq -c
## Top 25 1 minute groups of slow requests
cat /var/log/php-fpm/www-slow.log | grep 'pool www' | cut -d' ' -f2 | \
sort | cut -d: -f1,2 | uniq -c | sort -nr | head -n 25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment