Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active April 20, 2017 15:55
Show Gist options
  • Save phpdave/8ea588268f2b586c90fc4af9504f2f90 to your computer and use it in GitHub Desktop.
Save phpdave/8ea588268f2b586c90fc4af9504f2f90 to your computer and use it in GitHub Desktop.
Apache Performance monitoring memory usage.
echo Start $(date '+%Y %b %d %H:%M:%S') $HOSTNAME
ps aux | awk '{print $3;}' | awk '{total += ($1) ;} END {print total " % of CPU Used by All Processes";}'
ps aux | awk '{print $4;}' | awk '{total += ($1) ;} END {print total " % of Memory used by ALL Processes";}'
ps aux | grep 'httpd' | awk '{print $3;}' | awk '{total += ($1) ;} END {print total " % of CPU Used by Apache Processes";}'
ps aux | grep 'httpd' | awk '{print $4;}' | awk '{total += ($1) ;} END {print total " % of Memory used by Apache Processes";}'
ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{total += ($1) ;} END {print total " MB used by Apache Processes";}'
ps aux | grep 'httpd' | awk '{print $6/1024;}' | awk '{avg += ($1 - avg) / NR;} END {print avg " MB used on average per Apache process";}'
ps -C httpd --no-headers | wc -l | awk '{print $0 " apache processes ";}'
echo '---CPU and IO Usage sar -P ALL 1 5 | grep average---'
#sar 1 5
sar -P ALL 1 5 | grep 'Average'
echo '---Memory Usage sar -r 1 5 | grep average---'
sar -r 1 5 | grep -w 'Average\|kbmemfree'
echo '---Swap Space Used---'
sar -S 1 5 | grep -w 'Average\|kbswpused'
echo '---Content Switches---'
sar -w 1 5
echo '---Run Queue and Load Average---'
sar -q 1 3
echo '---Network Stats---'
sar -n ALL
echo End $(date '+%Y %b %d %H:%M:%S')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment