After reading the post on
Understanding memory usage on Linux, I wanted a simple method to count the private bytes taken eg. by apache or php processes. Writing this is really not a big deal, but might be helpful for newbies ...
Eg. count the private bytes used by the PHP5 CGI processes:
memtotal=0
memcount=0
for pid in `ps -C php5-cgi -o pid=`; do
mem=$(pmap -d ${pid} | grep 'writeable/private' | sed -e 's/.*writeable\/private: *\([0-9]*\)K.*/\1/')
memtotal=$((memtotal+mem))
memcount=$((memcount+1))
done
echo -e "Total: ${memtotal}\nCount: ${memcount}"
You can put this into a shellscript (maybe modify it a bit so you can supply an arbitrary process name as a parameter) or run it as a one-liner (originally it was a one-liner, but I've split it into multiple lines for readability).
Recent comments
6 days 16 hours ago
1 week 15 hours ago
1 week 16 hours ago
1 week 1 day ago
1 week 1 day ago
1 week 5 days ago
1 week 5 days ago
3 weeks 3 days ago
3 weeks 3 days ago
3 weeks 5 days ago