Linux : How to show Apache memory usage and average process size

By | September 12, 2020

Here is an easy way to output in a single command the Apache memory usage and average process size :

ps -ylC apache2 | awk '{x += $8;y += 1} END {print "Apache Memory Usage (MB): "x/1024; print "Average Proccess Size (MB): "x/((y-1)*1024)}'

This is particularly useful when you need to calculate proper process, max clients, etc. settings.