收集jmap和jstack信息

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
38
39
40
41
42
43
#收集jmap信息

#!bin/sh
if [ $# -lt 2 ] ; then
echo "please input port and execute count parameter"
exit
fi
jmap_dir=/mnt/ray/jmap/
jstack_dir=/mnt/ray/jstack/
port=$1
count=$2
i=1
while(($i<$count))
do
filename=`date '+%Y-%m-%d_%H:%M:%S'`
sudo -u hive /usr/java/latest/bin/jmap -histo $port > $jmap_dir$filename"_"$port.jmap
sudo -u hive /usr/java/latest/bin/jmap -heap $port >> $jmap_dir$filename"_"$port.jmap
sudo -u hive /usr/java/latest/bin/jstack $port > $jstack_dir$filename"_"$port.jstack
i=$(($i+1))
sleep 1m
done


#收集jstack信息
#!bin/sh
jmap_dir=/mnt/ray/jmap/
jstack_dir=/mnt/ray/jstack/
count=$1
i=1
mkdir /mnt/ray/jmap/
mkdir /mnt/ray/jstack/
while(($i<$count))
do
for port in $(jps|grep CoarseGrainedExecutorBackend|awk '{print $1}')
do
filename=`date '+%Y-%m-%d_%H:%M:%S'`
sudo -u hive /usr/java/latest/bin/jmap -histo $port > $jmap_dir$filename"_"$port.jmap
sudo -u hive /usr/java/latest/bin/jmap -heap $port >> $jmap_dir$filename"_"$port.jmap
sudo -u hive /usr/java/latest/bin/jstack $port > $jstack_dir$filename"_"$port.jstack
i=$(($i+1))
sleep 1m
done
done
1
nohup sh jmap.sh 16019 &