📄 ast_grab_core
字号:
#!/bin/sh# $Id: ast_grab_core 9991 2006-02-14 19:14:15Z kpfleming $# 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/tmpHOSTNAME=`hostname`ADMINEMAIL="root@localhost"#the following should be improvedif [ -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}'`fiecho Snarfing asterisk core, this could take a few seconds dependingecho on how much memory is in use.echoecho \*\*\* 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 quitEOFecho Snarfed! ${DUMPDIR}/asterisk_${DATE}.core.${PID}echoecho 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 << EOFset prompt \necho --------------------------------------------------------------------------------\necho INFO THREADinfo threadecho --------------------------------------------------------------------------------\necho THREAD APPLY ALL BTthread apply all btecho --------------------------------------------------------------------------------\necho THREAD APPLY ALL BT FULLthread apply all bt fullquitEOFecho 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.echoecho Reproducible deadlocks should be posted with a full backtrace and instructionsecho to reproduce the issue at http://bugs.digium.com/ Thanks!
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -