diff options
author | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-15 05:07:14 +0000 |
---|---|---|
committer | kpfleming <kpfleming@f38db490-d61c-443f-a65b-d21fe96a405b> | 2005-05-15 05:07:14 +0000 |
commit | 9bc8a6439f7e53f4d782d7bb64feacdc769d801b (patch) | |
tree | 34b6de6b9f74ecebd05c32465c92f6a8693f727d /contrib | |
parent | c8c9acf5055a542f23d2b89215624600fbae895c (diff) |
add script for grabbing core dump from running Asterisk process (bug #4174)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@5671 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'contrib')
-rwxr-xr-x | contrib/scripts/ast_grab_core | 64 |
1 files changed, 64 insertions, 0 deletions
diff --git a/contrib/scripts/ast_grab_core b/contrib/scripts/ast_grab_core new file mode 100755 index 000000000..8f405ebdd --- /dev/null +++ b/contrib/scripts/ast_grab_core @@ -0,0 +1,64 @@ +#!/bin/sh +# $Id$ +# lame quickie script to snarf a core of a hung asterisk process. +# bugs to ast_grab_core, blinky-lights.org (derrick daugherty) + +DATE=`date +%Y%m%d%H%M` +DUMPDIR=/var/tmp +HOSTNAME=`hostname` +ADMINEMAIL="root@localhost" + +#the following should be improved +if [ -e /etc/asterisk/asterisk.conf ]; then + RUNDIR=`awk -F"=>" '/astrundir/ {print $2}' /etc/asterisk/asterisk.conf` + PID=`cat ${RUNDIR}/asterisk.pid` +elif [ -e /var/run/asterisk.pid ] ; then + PID=`cat /var/run/asterisk.pid` +else + echo Could not find an asterisk.conf definition for astrundir, using \'ps\' + echo to try and determine process ID. This is not reliable. + PID=`ps auxwf|grep asterisk|grep vv|head -1|awk '{print $2}'` +fi + +echo Snarfing asterisk core, this could take a few seconds depending +echo on how much memory is in use. +echo +echo \*\*\* WARNING \*\*\* If the system is not already locked this will cause the +echo \*\*\* WARNING \*\*\* process to STOP while memory is dumped to disk. +echo + +/usr/bin/gdb > /dev/null << EOF + attach ${PID} + gcore ${DUMPDIR}/asterisk_${DATE}.core.${PID} + detach + quit +EOF + +echo Snarfed! ${DUMPDIR}/asterisk_${DATE}.core.${PID} +echo + + +echo Trying for a backtrace of the captured core. +/usr/bin/gdb /usr/sbin/asterisk ${DUMPDIR}/asterisk_${DATE}.core.${PID} > /tmp/gdb_dump.${PID} 2> /dev/null << EOF +set prompt \n +echo --------------------------------------------------------------------------------\n +echo INFO THREAD +info thread +echo --------------------------------------------------------------------------------\n +echo THREAD APPLY ALL BT +thread apply all bt +echo --------------------------------------------------------------------------------\n +echo THREAD APPLY ALL BT FULL +thread apply all bt full +quit +EOF +echo Done trying for a bt. + + +echo Notifying admins of the core. +/usr/bin/mail -s "${HOSTNAME} core dumped at ${DUMPDIR}/asterisk_${DATE}.core.${PID}" ${ADMINEMAIL} < /tmp/gdb_dump.${PID} +/bin/rm /tmp/gdb_dump.${PID} +echo Done. +echo +echo Reproducible deadlocks should be posted with a full backtrace and instructions +echo to reproduce the issue at http://bugs.digium.com/ Thanks! |