Linux - How to find total httpd size, How to find total php-cgi size

How to find total httpd size

Here is how you can find out total httpd and php-cgi size:

ps -aylC php-cgi  | grep php-cgi | awk '{total += $8}END{size=  total / 1024;
printf "Total size in mb: %.2f\n", size}'

And for httpd:
ps -aylC httpd  | grep httpd | awk '{total += $8}END{size= total / 1024;
printf "Total size in mb: %.2f\n", size}'

This will help you to manage the high traffic on your apache server.

#!/bin/bash
APACHE="apache2"
# for RHEL/CentOS set it to httpd
#APACHE="httpd"
RSS=`ps -aylC $APACHE |grep "$APACHE" |awk '{print $8'} |sort -n |tail -n 1`
RSS=`expr $RSS / 1024`
echo "Stopping $APACHE to calculate free memory"
/etc/init.d/$APACHE stop &ampamp> /dev/null
MEM=`free -m |head -n 2 |tail -n 1 |awk '{free=($4); print free}'`
echo "Starting $APACHE again"
/etc/init.d/$APACHE start &> /dev/null
echo "MaxClients should be around" `expr $MEM / $RSS`

This will give you a good idea on finding the memory size used by apache.

The topic on Linux - How to find total httpd size is posted by - Math

Hope you have enjoyed, Linux - How to find total httpd sizeThanks for your time

Tech Bluff