Skip to content

Instantly share code, notes, and snippets.

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 OriPekelman/c92d32f8eb50023d363281a8e250efc6 to your computer and use it in GitHub Desktop.
Save OriPekelman/c92d32f8eb50023d363281a8e250efc6 to your computer and use it in GitHub Desktop.
Get php memory usage stats (column 5) from nginx logs
cat /var/log/php.access.log| awk '{print $6}' | sort -n | awk ' BEGIN { c = 0; sum = 0; min = 0; max =0 } {c++; a[c] = $1; sum += $1;} END { ave = sum / c; if( (c % 2) == 1 ) { median = a[ int(c/2) ]; } else { median = ( a[c/2] + a[c/2-1] ) / 2; min=a[0]; max = a[c-1]; } OFS="\t"; print "Count", "Average", "Median", "Min", "Max"; print c, ave, median, min, max; }'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment