#!/bin/bash jps -lm read -p "enter java pid: " pid port=$(netstat -ntlp | grep $pid | awk '{printf $4}' | cut -d':' -f4) read -p "pid: ${pid}, http port: ${port}, continue? (Y/N): " confirm && [[ $confirm == [yY] || $confirm == [yY][eE][sS] ]] || exit 1 # pause_url="http://localhost:${port}/actuator/pause " # echo "try pause application from ${pause_url}." # curl -XPOST $pause_url # echo '' # pause_url="http://localhost:${port}/sba/pause " # echo "try pause application from ${pause_url}." # curl -XPOST $pause_url dir=$(mktemp -d) echo "files will save to ${dir}." cd $dir echo "try dump server memory info." free -h > free.dat echo "try dump server cpu info." top -c -b -n 1 > top.dat echo "try dump process thread cpu info." top -c -b -n 1 -Hp $pid > top_thread.dat echo "try dump process thread stack info." jstack $pid > threads.dat echo "try dump process heap info." jmap -dump:format=b,file=./heap.hprof $pid echo "try compress hprof file." tar zcvf heap.hprof.tar.gz ./heap.hprof