zoukankan      html  css  js  c++  java
  • dump Java 程序和服务器相关信息

    #!/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
  • 相关阅读:
    js(一)
    css (一)
    html
    Spring MVC(四)
    Spring MVC(三)
    Spring MVC(二)
    Spring MVC(一)
    Druid应用
    C3P0使用
    jdbc(二)
  • 原文地址:https://www.cnblogs.com/tonyauto/p/11131784.html
Copyright © 2011-2022 走看看