I'm trying to find out total memory used by all PHP processes on my CentOS server. After some grepping
and awking
this is my final command.
ps -e | grep php | awk '{print $1}' | xargs pmap | grep total | awk '{print $2}' | sed 's/K//' | awk '{SUM += $1} END {print SUM/1024}'
Now, theoretically this should be working, as I took the total ram output in K, summed it then divided and that's my MB's. Problem is that's returning
12493.5
That's 12GB! There is no way they are using 12GB as the server only has 4GB.
EDIT: According to the manpage of pmap
the -x
switch shows extended information.
http://linux.die.net/man/1/pmap
There is a column in this view called Dirty. Is this the right column? When I awk out on the Dirty column I get:
1294.1
That would make more sense to me. But I don't know if the Dirty column is the right one or not.