Getting a Proper Asterisk Backtrace
Â
This document is written to help users get a proper backtrace for Asterisk when trying to debug a issue.
Backtrace of a Running Asterisk instance
From the Linux CLI we need to first get the Asterisk process ID so we can attach to asterisk.
Â
Process ID
[root@localhost ~]# ps aux | grep asterisk
root      847 0.0 0.0  6260  240 ?       S   Jan17  0:00 /bin/sh /usr/sbin/safe_asterisk -U asterisk -G asterisk -g
asterisk  851 0.4 1.7 123008 45676 ?       Sl  Jan17 326:29 /usr/sbin/asterisk -f -U asterisk -G asterisk -g -vvvg -c |
In our example above the Asterisk process ID we need is 851 as that is the actual Asterisk process. You do not want the process ID of the Safe Asterisk script which is 847.
Â
Now we will run the actual back trace.
Executing Backtrace
[root@localhost ~]# gdb -ex "thread apply all bt" --batch /usr/sbin/asterisk 851 > /tmp/backtrace-threads.txt |
Replace the 851 with your actual process ID.Â
Â
The backtrace file will now be in the /tmp directory called backtrace-threads.txt
Finding Backtrace
[root@localhost ~]# cd /tmp/
[root@localhost tmp]# ls
backtrace-threads.txt freepbx_debug.log |