java process exception dump reference script

1. Purpose of the script

When the java process is alive, but there are serious exceptions, pseudo death, no response, etc., execute the dump.sh script, snapshot the current system and jvm information, and keep the problem site.

2. Script address

osc-java-dump.sh

3. Execute demo

# Upload dump.sh file
mkdir -p /data/sh/java
cd /data/sh/java
rz 

# Initialization script
dos2unix dump.sh
chmod +x dump.sh

# Normal execution
/data/sh/java/dump.sh /tmp/dump /usr/local/java/jdk1.8.0_05 23554
# If the process hung, add the - F parameter
/data/sh/java/dump.sh /tmp/dump /usr/local/java/jdk1.8.0_05 23554 -F
  • Parameter description
  1. /Absolute path of data / SH / Java / dump.sh dump script, required
  2. /The root path of the TMP / dump dump file. Note that under this path, the system will generate a time stamp folder [note]: type + /, required
  3. /Usr / local / Java / jdk1.8.0 ﹐ Java ﹐ home path, [note]: after jdk1.8.0 ﹐ type + /, required
  4. 23554 java(tomcat)-pid, required
  5. -F process hung yes, mandatory, not required

4. Implementation results and description

[root@test 2018-09-28_20_32_38_516053700]# ll
total 259472
-rw-r--r-- 1 root root      7980 Sep 28 20:32 jvm_jinfo_20-32-52-754854642.dump                     #gc configuration
-rw------- 1 root root 264130476 Sep 28 20:33 jvm_jmap_20-33-06-990069413.hprof                     #gc stack
-rw-r--r-- 1 root root     88240 Sep 28 20:32 jvm_jstack_20-32-55-852166558.dump                    #gc thread
-rw-r--r-- 1 root root       738 Sep 28 20:33 jvm_jstat-gcutil_20-32-59-442298526.dump              #gc recovery summary
-rw-r--r-- 1 root root       353 Sep 28 20:32 machine_free_20-32-39-141097263.dump                  #Memory summary
-rw-r--r-- 1 root root      1058 Sep 28 20:32 machine_iostat_20-32-44-198227715.dump                #io detail
-rw-r--r-- 1 root root     46445 Sep 28 20:32 machine_iotop_20-32-46-212382766.dump                 #iotop
-rw-r--r-- 1 root root     20711 Sep 28 20:32 machine_lsof_20-32-52-417439254.dump                  #File handle information
-rw-r--r-- 1 root root     97967 Sep 28 20:32 machine_mpstat_20-32-41-163178078.dump                #cpu Information
-rw-r--r-- 1 root root    518002 Sep 28 20:32 machine_netstat_20-32-51-662440984.dump               #network information
-rw-r--r-- 1 root root        80 Sep 28 20:33 machine_netstat_status_statistics.dump                #Network information statistics
-rw-r--r-- 1 root root    722294 Sep 28 20:32 machine_sar_20-32-52-619321528.dump                   #Various historical records
-rw-r--r-- 1 root root      8952 Sep 28 20:32 machine_top50_20-32-38-536098971.dump                 #top 50 lines
-rw-r--r-- 1 root root      8952 Sep 28 20:32 machine_top-50-high-thread_20-32-55-319789848.dump    #Threads with high cpu consumption in the process
-rw-r--r-- 1 root root       510 Sep 28 20:32 machine_vmstat_20-32-39-151829235.dump                #io memory
-rw-r--r-- 1 root root      4250 Sep 28 20:33 run.log

5. Script description

  • The script snapshot information consists of two parts: machine information and jvm information
    • Machine information, including:) real-time information and historical information [sar], part of the real-time information will intercept the three snapshot information during the execution of the script, with an interval of 1s; finally, the number of various states of tcp will be counted.
    • jvm information, including jinfo[jvm configuration information], jstack [thread and deadlock], jstat [real-time jvm garbage collection information] and jmap [heap and heap object information].

Tags: Java jvm snapshot network

Posted on Mon, 23 Dec 2019 07:03:15 -0800 by crickettdt