Skip to content

Instantly share code, notes, and snippets.

@spot62
Created July 31, 2019 08:45
Show Gist options
  • Save spot62/a866a4627b6d254ccd4f20a30f43cc82 to your computer and use it in GitHub Desktop.
Save spot62/a866a4627b6d254ccd4f20a30f43cc82 to your computer and use it in GitHub Desktop.
Java threads profiler
#!/bin/bash
# https://habr.com/ru/post/153135/
#
PID=$(top -n1 | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' ')
NID=$(printf '%x' $(top -n1 -H | grep -m1 java | perl -pe 's/\e\[?.*?[\@-~] ?//g' | cut -f1 -d' '))
jstack $PID | grep -A500 $NID | grep -m1 '^$' -B 500
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment