-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgenXMScores.sh
164 lines (127 loc) · 5.12 KB
/
genXMScores.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
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
#!/bin/bash
starttime=`date +"%Y-%m-%d_%H-%M-%S"`
coredir="xmscores-$starttime"
. /etc/init.d/functions
LOG="genXMScores.log"
STARTTIME=`date +"%y-%m-%d_%H-%m-%s"`
echo $STARTTIME > $LOG
echo `hostname` >> $LOG
# Use step(), try(), and next() to perform a series of commands and print
# [ OK ] or [FAILED] at the end. The step as a whole fails if any individual
# command fails.
#
step() {
echo -n -e "$@"
echo -e "\n\nSTEP - $@">> $LOG
STEP_OK=0
[[ -w /tmp ]] && echo $STEP_OK > /tmp/step.$$
}
try() {
# Check for `-b' argument to run command in the background.
local BG=
[[ $1 == -b ]] && { BG=1; shift; }
[[ $1 == -- ]] && { shift; }
# Run the command.
echo -e "$@" >> $LOG
if [[ -z $BG ]]; then
"$@" &>> $LOG
else
"$@" & &>> $LOG
fi
# Check if command failed and update $STEP_OK if so.
local EXIT_CODE=$?
if [[ $EXIT_CODE -ne 0 ]]; then
STEP_OK=$EXIT_CODE
[[ -w /tmp ]] && echo $STEP_OK > /tmp/step.$$
if [[ -n $LOG_STEPS ]]; then
local FILE=$(readlink -m "${BASH_SOURCE[1]}")
local LINE=${BASH_LINENO[0]}
echo "$FILE: line $LINE: Command \'$*\' failed with exit code $EXIT_CODE." >> "$LOG_STEPS"
fi
fi
return $EXIT_CODE
}
next() {
[[ -f /tmp/step.$$ ]] && { STEP_OK=$(< /tmp/step.$$); rm -f /tmp/step.$$; }
[[ $STEP_OK -eq 0 ]] && echo_success || echo_failure
echo
return $STEP_OK
}
setpass() {
echo -n "$@"
STEP_OK=0
[[ -w /tmp ]] && echo $STEP_OK > /tmp/step.$$
}
setfail() {
echo -n "$@"
STEP_OK=1
[[ -w /tmp ]] && echo $STEP_OK > /tmp/step.$$
}
genBT(){
echo Generated via btdumpscript.sh > $coredir/corebtinfo.log
echo Core List in dir - >> $coredir/corebtinfo.log
echo `ls -al ./$coredir/*_core.*` >> $coredir/corebtinfo.log
echo ------------------------------- >> $coredir/corebtinfo.log
for corefile in ./$coredir/*_core.*
do
echo ============================= NEXT {$corefile} ========================================== &>> $coredir/corebtinfo.log
exe= `file ${corefile} | grep -oE "'.*?'" | grep -oE "/.*?'" | rev | cut -c2- | rev` &>> $coredir/corebtinfo.log
echo ---------------------------------------------------------------------------- &>> $coredir/corebtinfo.log
echo `ls -al $corefile` &>> $coredir/corebtinfo.log
echo `file $corefile` &>> $coredir/corebtinfo.log
echo ---------------------------------------------------------------------------- &>> $coredir/corebtinfo.log
echo BT only &>> $coredir/corebtinfo.log
echo ---------------------------------------------------------------------------- &>> $coredir/corebtinfo.log
gdb --batch --quiet -ex "bt " -ex "quit" -core ${corefile} ${exe} &>> $coredir/corebtinfo.log
echo ---------------------------------------------------------------------------- &>> $coredir/corebtinfo.log
echo FULL trace on all threads &>> $coredir/corebtinfo.log
echo ---------------------------------------------------------------------------- &>> $coredir/corebtinfo.log
gdb --batch --quiet -ex "thread apply all bt full" -ex "quit" -core ${corefile} ${exe} &>> $coredir/corebtinfo.log
done
echo ============================= DONE ========================================== &>> $coredir/corebtinfo.log
}
logger "User has intiated generation of XMS process cores via genXMScores.sh"
step "Creating core output directory"
try mkdir $coredir
next
if [[ -x "./xmsinfo.sh" ]]
then
step "Obtaining XMSInfo"
try ./xmsinfo.sh $coredir/xmsinfo-$starttime.tgz &>/dev/null
next
fi
step "Generating Cores for XMS process"
#XMS Core processes
try gcore -o ./$coredir/xmserver_core_core `pidof xmserver`
try gcore -o ./$coredir/appmanager_core `pidof appmanager`
try gcore -o ./$coredir/broker_core `pidof broker`
try gcore -o ./$coredir/eventmanager_core `pidof eventmanager`
try gcore -o ./$coredir/nodecontroller_core `pidof nodecontroller`
next
#WebRTC process
step "Generating Cores for Webrtc process"
try gcore -o ./$coredir/rtcweb_core `pidof rtcweb`
next
#HMP Core process
step "Generating Cores for Media Cores (HMP) process"
try gcore -o ./$coredir/ssp_x86Linux_boot_core `pidof ssp_x86Linux_boot`
next
#XMS interface processes
step "Generating Cores for XMS Control Interface process"
try gcore -o ./$coredir/vxmlinterpreter_core `pidof vxmlinterpreter`
try gcore -o ./$coredir/xmsrest_core `pidof xmsrest`
try gcore -o ./$coredir/msml_main_core `pidof msmlserver`
try gcore -o ./$coredir/netann_core `pidof netann`
next
step "Gathering executable binaries"
#copy of the binaries
try tar cvzf ./$coredir/binaries.tgz /usr/dialogic/bin/ssp_x86Linux_boot /usr/bin/xmserver /usr/bin/appmanager /usr/bin/broker /usr/bin/eventmanager /usr/bin/nodecontroller /usr/bin/rtcweb /usr/bin/vxmlinterpreter /usr/bin/xmsrest /usr/bin/msmlserver /usr/bin/netann &> /dev/null
next
step "Generating Backtraces from cores"
genBT
setpass
next
echo "----------------------------------------------------------------" | tee -a $LOG
echo Cores available in $coredir | tee -a $LOG
echo "----------------------------------------------------------------" | tee -a $LOG
#TODO, put detect in for abrt logs or cores already available