Last active
February 23, 2023 01:43
-
-
Save MiPnamic/8c43ee2201a785524c39 to your computer and use it in GitHub Desktop.
Check average Memory usage of PHP-FPM processes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Quick 1-liner
AVG=$(ps --no-headers -o "rss,cmd" -C php-fpm | awk '{ sum+=$1 } END { printf ("%d%s\n", sum/NR/1024,"M") }'); QTY=$(ps -ylC php-fpm --sort:rss | tail -n +2 | wc -l); echo "$AVG on $QTY processes";
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
You're totally right! I'm updating the code, thank you