Skip to content

Instantly share code, notes, and snippets.

@jjtroberts
Forked from MiPnamic/average_php.sh
Created August 9, 2021 20:19
Show Gist options
  • Save jjtroberts/7e4a6f100753269dc3531a9179ba172d to your computer and use it in GitHub Desktop.
Save jjtroberts/7e4a6f100753269dc3531a9179ba172d to your computer and use it in GitHub Desktop.
Check average Memory usage of PHP-FPM processes
#!/bin/bash
echo "Average php-fpm process memory usage:"
PHPFPM="php-fpm" # it could be just php-fpm or php-fpm-X.X (eg. php-fpm-7.1) depending on configuration
AVG=$(ps --no-headers -o "rss,cmd" -C $PHPFPM | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }')
QTY=$(ps -ylC $PHPFPM --sort:rss | tail -n +2 | wc -l)
echo "$AVG on $QTY processes"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment