Skip to content

Instantly share code, notes, and snippets.

Created February 28, 2018 11:39
What would you like to do?
Log PID and path of process causing high CPU usage (php-fpm)
# very specific need
top_process=$(ps -eo pid,cmd,%cpu --sort=-%cpu | head -n2 | tail -n1)
if [[ $top_process == *sometest* ]]; then
PATHTOPROCESS=$(echo $top_process| awk '{print $1}' | xargs lsof -p | grep public_html)
logger -it HIGHCPU "Process $top_process in $PATHTOPROCESS"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment