Skip to content

Instantly share code, notes, and snippets.

@ecoleman
Created November 16, 2011 18:34
Show Gist options
  • Save ecoleman/1370915 to your computer and use it in GitHub Desktop.
Save ecoleman/1370915 to your computer and use it in GitHub Desktop.
#!/bin/bash
echo "This is intended as a guideline only!"
if [ -e /etc/debian_version ]; then
APACHE="apache2"
RC_COMMAND="/etc/init.d/$APACHE"
elif [ -e /etc/redhat-release ]; then
APACHE="httpd"
RC_COMMAND="/etc/init.d/$APACHE"
elif [ -e /etc/arch-release ]; then
APACHE="httpd"
RC_COMMAND="/etc/rc.d/$APACHE"
fi
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"
$RC_COMMAND stop &> /dev/null
MEM=`free -m |head -n 2 |tail -n 1 |awk '{free=($4); print free}'`
echo "Starting $APACHE again"
$RC_COMMAND start &> /dev/null
echo "MaxClients should be around" `expr $MEM / $RSS`
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment