Skip to content

Instantly share code, notes, and snippets.

@pfmiles
Created November 6, 2012 03:14
Show Gist options
  • Save pfmiles/4022336 to your computer and use it in GitHub Desktop.
Save pfmiles/4022336 to your computer and use it in GitHub Desktop.
crontab根据load阀值自动记录jstack结果的脚本
#!/bin/sh
waterMark=10
pid=`/usr/alibaba/java/bin/jps|grep AvatarEngine|cut -d ' ' -f 1`
curLoad=`cat /proc/loadavg |cut -d ' ' -f 1`
file="/tmp/$pid-`date +%Y-%m-%d-%H-%M-%S`-stack$curLoad.log"
if [ 1 == `echo "$curLoad > $waterMark"|bc` ];then
/usr/alibaba/java/bin/jstack $pid > $file
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment