]> git.ipfire.org Git - thirdparty/bacula.git/commitdiff
Fix org#2587 Improve btraceback output
authorEric Bollengier <eric@baculasystems.com>
Wed, 6 Jan 2021 14:48:29 +0000 (15:48 +0100)
committerEric Bollengier <eric@baculasystems.com>
Thu, 24 Mar 2022 08:02:58 +0000 (09:02 +0100)
Reported by Carsten

At Debian we had bug reports because of the emails that btraceback sends.
Apparently the users were confused because of a lack of explanation in the email.

bacula/scripts/btraceback.in

index f922aa90e4c05e9074ebb6a424f4b143c59cfc63..532c8972603be698f3115cd59eb8957d9ee860a8 100755 (executable)
@@ -34,6 +34,12 @@ WD="$3"
 if [ "$WD" = "" ]; then
     WD=/tmp
 fi
+
+# Start constructing message. Point to log files for better user
+# experience, append backtrace or message about missing debugger later
+echo "Check the log files for more information." > ${WD}/bacula.$2.traceback
+echo "" >> ${WD}/bacula.$2.traceback
+
 case `uname -s` in
 SunOS)
    #
@@ -57,14 +63,17 @@ SunOS)
    elif [ ! -z "${MDB}" ]; then
       ${MDB} -u -p $2 < @scriptdir@/btraceback.mdb >> ${WD}/bacula.$2.traceback 2>&1
    fi
-   PNAME="${PNAME} on `hostname`"
-   cat ${WD}/bacula.$2.traceback \
-    | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula DBX traceback of ${PNAME}" @dump_email@
    ;;
 *)
-   gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >> ${WD}/bacula.$2.traceback 2>&1
-   PNAME="${PNAME} on `hostname`"
-   cat ${WD}/bacula.$2.traceback \
-    | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula GDB traceback of ${PNAME}" @dump_email@
+    which gdb > /dev/null 2>&1 && GDB=`which gdb` || GDB=''
+    if  [ ! -z "${GDB}" ]; then
+        gdb -quiet -batch -x @scriptdir@/btraceback.gdb $1 $2 >> ${WD}/bacula.$2.traceback 2>&1
+    else
+        echo "Please install a debugger (gdb) to receive a traceback." >> ${WD}/bacula.$2.traceback 2>&1
+    fi
    ;;
 esac
+
+PNAME="${PNAME} on `hostname`"
+cat ${WD}/bacula.$2.traceback \
+    | @sbindir@/bsmtp -h @smtp_host@ -f @dump_email@ -s "Bacula traceback. Process crashed ${PNAME}" @dump_email@