-
-
Save shanielh/b80c02d4164eeff1c0b979713bdce988 to your computer and use it in GitHub Desktop.
open-jfr.sh
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 | |
| mkdir -p /tmp/lock/ | |
| LOCKFILE="/tmp/lock/`basename $0`" | |
| LOCKFD=99 | |
| _lock() { flock -$1 $LOCKFD; } | |
| _no_more_locking() { _lock u; _lock xn && rm -f $LOCKFILE; } | |
| _prepare_locking() { eval "exec $LOCKFD>\"$LOCKFILE\""; trap _no_more_locking EXIT; } | |
| _prepare_locking | |
| exlock() { _lock x; } # obtain an exclusive lock | |
| unlock() { _lock u; } # drop a lock | |
| if [ "$#" -eq 0 ]; then | |
| echo "Usage: $0 <filename>" | |
| exit 1 | |
| fi | |
| converter_path="/tmp/converter.jar" | |
| exlock # Locking in order to wait for converter download. | |
| if ! [ -f "$converter_path" ]; then | |
| curl "https://github.com/jvm-profiling-tools/async-profiler/releases/download/v3.0/converter.jar" -L > $converter_path | |
| fi | |
| unlock | |
| path=$1 | |
| echo "$path.itimer.html" | |
| java -cp $converter_path jfr2flame --input $path --output $path.itimer.html | |
| echo "$path.lock.html" | |
| java -cp $converter_path jfr2flame --input $path --output $path.lock.html --lock | |
| echo "$path.alloc.html" | |
| java -cp $converter_path jfr2flame --input $path --output $path.alloc.html --alloc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment