forked from momokind/orasql
-
Notifications
You must be signed in to change notification settings - Fork 0
/
heapdump_analyzer.sh
42 lines (40 loc) · 1.78 KB
/
heapdump_analyzer.sh
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
#!/bin/ksh
################################################################################
## ## File name: heapdump_analyzer
## Purpose: Script for aggregating Oracle heapdump chunk sizes
## ## Author: Tanel Poder ## Copyright: (c) http://www.tanelpoder.com
## ## Usage: 1) Take a heapdump ( read http://www.juliandyke.com )
## ## 2) run ./heapdump_analyzer <heapdump tracefile name>
## For example: ./heapdump_analyzer ORCL_ora_4345.trc
## ## Other: Only take heapdumps when you know what you¡¯re doing!
## Taking a heapdump on shared pool (when bit 2 in heapdump event
## level is enabled) can hang your database for a while as it
## holds shared pool latches for a long time if your shared pool
## is big and heavily active.
## ## Private memory heapdumps are safer as only the dumped process is
## affected.
## ## ################################################################################
if [ $1 == "-t" ]; then
EXCLUDE='dummy_nonexistent_12345'
shift
else
EXCLUDE='Total heap size$'
fi
echo
echo " ¡ª Heapdump Analyzer v1.00 by Tanel Poder ( http://www.tanelpoder.com )"
echo
echo " Total_size #Chunks Chunk_size, From_heap, Chunk_type, Alloc_reason"
echo " ¡ª¡ª¡ª- ¡ª¡ª- ¡ª¡ª¡ª¡ª ¡ª¡ª¡ª¡ª¡ª¨C ¡ª¡ª¡ª¡ª¡ª¨C ¡ª¡ª¡ª¡ª¡ª¨C"
cat $1 | awk '
/^HEAP DUMP heap name= / { split($0,ht,"\""); HTYPE=ht[2]; doPrintOut = 1; }
/Chunk/{ if ( doPrintOut == 1 )
{
split($0,sf,"\"");
printf "%10d , %16s, %16s, %16s\n", $4, HTYPE, $5, sf[2];
}
}
/Total heap size/ {
printf "%10d , %16s, %16s, %16s\n", $5, HTYPE, "TOTAL", "Total heap size";
doPrintOut=0;
}' | grep -v "$EXCLUDE" | sort -n | uniq -c | awk '{ printf "%12d %s\n", $1*$2, $0 }' | sort -nr
echo