Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Log PID and path of process causing high CPU usage (php-fpm)
#!/bin/bash
# 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"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment