Created
June 12, 2017 12:38
-
-
Save OriPekelman/c92d32f8eb50023d363281a8e250efc6 to your computer and use it in GitHub Desktop.
Get php memory usage stats (column 5) from nginx logs
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
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