### parameter description ### # 1 ./tmp/dump is save dump file dir. # 2 /usr/local/java/jdk1.8.0_05 is java_home. # 3 23554 is java-pid. # 4 -F force jvm dum, optional.
is_no_null(){ if [ -z $1 ];then return 0; else return 1; fi }
is_valid_number(){ is_no_null $1 if [ $? -eq 0 ];then return 0; fi
if [ $1 -gt 0 ] 2>/dev/null ;then return 1; else return 0; fi }
echo_blank_line(){ echo }
valid_param(){ if [ ! -d ${RESULT_DIRECTORY} ]; then mkdir -p ${RESULT_DIRECTORY} run_log "tip: Create RESULT_DIRECTORY=${RESULT_DIRECTORY}" fi run_log "tip: RESULT_DIRECTORY=${RESULT_DIRECTORY}"
is_no_null ${SNAPSHOT_BASE_DIRECTORY} if [ $? -eq 0 ];then run_log "Param 1 SNAPSHOT_BASE_DIRECTORY is no exist and exit ,such as /tmp/dump" exit 1; else run_log "tip: SNAPSHOT_BASE_DIRECTORY=${SNAPSHOT_BASE_DIRECTORY}" fi
if [ -d "${JAVA_HOME}" ];then run_log "tip: JAVA HOME: ${JAVA_HOME}" else run_log "Param2 JAVA_HOME is no exist and exit ,such as /usr/local/java/jdk1.8.0_05" exit 2; fi
is_valid_number ${PID} if [ $? -eq 0 ];then run_log "Param3 PID is invalid and exit" exit 3; fi } valid_param run_log "RESULT_DIRECTORY=${RESULT_DIRECTORY}"
# 8 times interval 1s declare jvm_static_frequency="1000 8" # jvm real time statistics information jvm_dump jinfo "${PID}" jvm_dump jstat "-gcutil ${PID}${jvm_static_frequency}""jstat-gcutil"
machine_dump_pipeline "top-100-high-thread" top "-H -b -n 1 -p ${PID}""head -n 100" chown ${PID_USER}:${PID_USER}${RESULT_DIRECTORY} # topH have must together with jstack jvm_dump jstack "${JVM_FORCE_OPTS}${PID}"
# statistics all kinds of tcp status cat ${RESULT_DIRECTORY}/machine_netstat*.dump | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}' > ${RESULT_DIRECTORY}/machine_netstat_status_statistics.dump