Skip to content

Instantly share code, notes, and snippets.

@phpdave
Last active April 20, 2017 15:55
Show Gist options
  • Select an option

  • Save phpdave/8ea588268f2b586c90fc4af9504f2f90 to your computer and use it in GitHub Desktop.

Select an option

Save phpdave/8ea588268f2b586c90fc4af9504f2f90 to your computer and use it in GitHub Desktop.

Revisions

  1. phpdave revised this gist Apr 20, 2017. 1 changed file with 17 additions and 1 deletion.
    18 changes: 17 additions & 1 deletion ApacheResourcesUsage.sh
    Original file line number Diff line number Diff line change
    @@ -1,7 +1,23 @@
    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 ";}'
    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')
  2. phpdave revised this gist Apr 20, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ApacheResourcesUsage.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    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";}'
  3. phpdave revised this gist Apr 20, 2017. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions ApacheResourcesUsage.sh
    Original file line number Diff line number Diff line change
    @@ -1,3 +1,5 @@
    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 ";}'
  4. phpdave revised this gist Apr 20, 2017. No changes.
  5. phpdave created this gist Apr 20, 2017.
    3 changes: 3 additions & 0 deletions ApacheResourcesUsage.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,3 @@
    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 ";}'