-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdump-stack3
37 lines (29 loc) · 863 Bytes
/
dump-stack3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#!/bin/bash
#
# Create a dump of webtop tomcat instance
#
NOW=$(date +%s)
OUT_LOG_FILE="/tmp/webtop-$NOW".log
OUT_DUMP_FILE="/tmp/webtop-$NOW".dump
OUT_STAT_FILE="/tmp/webtop-stat-$NOW".txt
which jstack &>/dev/null
# Install required dependcies
if [ $? -gt 0 ]; then
yum install sysstat java-1.8.0-openjdk-devel -y
fi
if [ $? -gt 0 ]; then
echo "Can't install unzip"
exit 1
fi
echo "Dumping status ..."
tomcat_pid=$(systemctl -p MainPID show tomcat8@webtop | cut -d'=' -f 2)
pidstat -p $tomcat_pid -t > $OUT_STAT_FILE
jstack -F -l $tomcat_pid > $OUT_LOG_FILE
echo >> $OUT_LOG_FILE
su - tomcat -s /bin/bash -c "jmap -dump:live,format=b,file=$OUT_DUMP_FILE $tomcat_pid"
gzip $OUT_DUMP_FILE
echo "Dumping pids ..."
echo >> $OUT_LOG_FILE
ps -T u -p $tomcat_pid >> $OUT_LOG_FILE
echo "Status log: $OUT_LOG_FILE"
echo "Heap dump: $OUT_DUMP_FILE.gz"