| Server IP : www.new.bangkokfinder.com / Your IP : 172.71.124.81 Web Server : nginx/1.20.1 System : Linux new 4.15.0-159-generic #167-Ubuntu SMP Tue Sep 21 08:55:05 UTC 2021 x86_64 User : bangkokfinder ( 1000) PHP Version : 7.4.33 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_get_handler,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority,pcntl_async_signals,pcntl_unshare, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /usr/sbin/ |
Upload File : |
#!/bin/sh
#
# Script to do a stack trace of a Bareos daemon/program
# and create a core-file for postmortem debugging.
#
# We attempt to attach to running program
#
# Arguments to this script are
# $1 = path to executable
# $2 = main pid of running program to be traced back.
# $3 = working directory
#
PNAME="`basename $1`"
WD="$3"
GCORE="GCORE-NOTFOUND"
GDB="GDB-NOTFOUND"
DBX="DBX-NOTFOUND"
MDB="MDB-NOTFOUND"
#
# Try to generate a core dump for postmortem analyzing.
#
POSTMORTEM="NONE"
if [ ! -z "${GCORE}" -a -x "${GCORE}" ]; then
POSTMORTEM="${WD}/${PNAME}.core"
${GCORE} -o ${POSTMORTEM} $2 > /dev/null 2>&1
POSTMORTEM="${POSTMORTEM}.$2"
echo "Created ${POSTMORTEM} for doing postmortem debugging" > ${WD}/bareos.$2.traceback
else
which gcore > /dev/null 2>&1 && GCORE="`which gcore`" || GCORE=''
if [ ! -z "${GCORE}" -a -x "${GCORE}" ]; then
POSTMORTEM="${WD}/${PNAME}.core"
${GCORE} -o ${POSTMORTEM} $2 > /dev/null 2>&1
POSTMORTEM="${POSTMORTEM}.$2"
echo "Created ${POSTMORTEM} for doing postmortem debugging" > ${WD}/bareos.$2.traceback
fi
fi
#
# Try to find out what debugger is available on this platform.
#
if [ ! -z "${DBX}" -a -x "${DBX}" ]; then
DEBUGGER="DBX"
elif [ ! -z "${GDB}" -a -x "${GDB}" ]; then
DEBUGGER="GDB"
elif [ ! -z "${MDB}" -a -x "${MDB}" ]; then
DEBUGGER="MDB"
else
#
# If we fail to find the configured debugger do a last try to find it on the PATH.
#
which gdb > /dev/null 2>&1 && GDB="`which gdb`" || GDB=''
which dbx > /dev/null 2>&1 && DBX="`which dbx`" || DBX=''
which mdb > /dev/null 2>&1 && MDB="`which mdb`" || MDB=''
if [ ! -z "${DBX}" -a -x "${DBX}" ]; then
DEBUGGER="DBX"
elif [ ! -z "${GDB}" -a -x "${GDB}" ]; then
DEBUGGER="GDB"
elif [ ! -z "${MDB}" -a -x "${MDB}" ]; then
DEBUGGER="MDB"
else
DEBUGGER="NONE"
fi
fi
#
# Try to run a debugger on the crashing program or the generated postmortem dump for getting a strack trace.
#
case ${DEBUGGER} in
DBX)
if [ ${POSTMORTEM} != NONE -a -s ${POSTMORTEM} ]; then
${DBX} $1 ${POSTMORTEM} < /usr/lib/bareos/scripts/btraceback.dbx >> ${WD}/bareos.$2.traceback 2>&1
else
${DBX} $1 $2 < /usr/lib/bareos/scripts/btraceback.dbx >> ${WD}/bareos.$2.traceback 2>&1
fi
;;
GDB)
if [ ${POSTMORTEM} != NONE -a -s ${POSTMORTEM} ]; then
${GDB} -quiet -batch -x /usr/lib/bareos/scripts/btraceback.gdb $1 ${POSTMORTEM} >> ${WD}/bareos.$2.traceback 2>&1
else
${GDB} -quiet -batch -x /usr/lib/bareos/scripts/btraceback.gdb $1 $2 >> ${WD}/bareos.$2.traceback 2>&1
fi
;;
MDB)
if [ ${POSTMORTEM} != NONE -a -s ${POSTMORTEM} ]; then
${MDB} -u $1 ${POSTMORTEM} < /usr/lib/bareos/scripts/btraceback.mdb >> ${WD}/bareos.$2.traceback 2>&1
else
${MDB} -u -p $2 < /usr/lib/bareos/scripts/btraceback.mdb >> ${WD}/bareos.$2.traceback 2>&1
fi
;;
NONE)
echo "No debugger available on this platform," \
" please install one to get proper stack traces" >> ${WD}/bareos.$2.traceback
;;
esac
#
# Send the stack trace info to someone for analyzing or at least letting someone know we crashed.
#
PNAME="${PNAME} on `hostname`"
cat ${WD}/bareos.$2.traceback | \
/usr/sbin/bsmtp -h localhost -f root -s "Bareos ${DEBUGGER} traceback of ${PNAME}" root