Created
August 16, 2013 10:02
-
-
Save suziewong/6248672 to your computer and use it in GitHub Desktop.
如何使用Shell缉拿问题进程
http://huoding.com/2013/01/30/225
This file contains hidden or 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 | |
LOAD=$(awk '{print $1}' /proc/loadavg) | |
CPUNUM=$(grep -c processor /proc/cpuinfo) | |
if [ $(echo "$LOAD > $CPUNUM" | bc) = 1 ]; then | |
RESULT=$(ps -eo pcpu,pmem,user,args | awk '$1 > 0' | sort -nr) | |
if [ -n "$RESULT" ]; then | |
echo "$RESULT" > /var/log/ps.$(date +"%Y%m%d%H%M") | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment