Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@itxx00
Last active March 28, 2019 09:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itxx00/80268f45cad0caadf48842987a287e1f to your computer and use it in GitHub Desktop.
Save itxx00/80268f45cad0caadf48842987a287e1f to your computer and use it in GitHub Desktop.
get_nn_stack.sh
$ cat get_nn_stack.sh
#!/bin/bash
pid=$(ps ax|grep namenode.NameNode|grep -v grep|awk '{print $1}')
topinfo=$(top -H -p $pid -b -n 3|grep -A1 'PID USER'|tail -1|awk '{print $1,$9}')
thread=$(echo $topinfo|awk '{print $1}')
cpu=$(echo $topinfo|awk '{print $2}')
echo $cpu
if [[ $(python -c "print $cpu > 70") = True ]]; then
echo "thread $thread cpu usage over 70%"
else
echo "no cpu usage issue"
exit
fi
nid=$(python -c "print '0x%x' % $thread")
echo $nid
jstack $pid >/tmp/$pid.stack || jstack -F $pid >/tmp/$pid.stack
grep -A30 "nid=$nid" /tmp/$pid.stack
grep -A30 "Thread $thread" /tmp/$pid.stack
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment