Snapshot Generation

Generating a Snapshot

You can generate the snapshot with a call to /opt/backtrace/bin/ptrace. The most basic form of this call is /opt/backtrace/bin/ptrace <pid>, but in practice you will want to include flags --application=, --kv=, and -O to specify the output location.

Submitting a Snapshot to Coroner

The basic format for submitting snapshots to coroner is:

coroner put project_name token_name /path/to/snapshot.btt

If using a self-signed certificate on the coroner server, pass the -k flag to coroner put:

coroner put -k project_name token_name /path/to/snapshot.btt

For more information, see Submitting Traces to Coroner

Script to Generate & Submit Snapshot

You will need to customize this script to populate application, dc, version, btt_prefix, and btt. Also, verify the path to coroner.cf.

In addition, you should add variables for any additional KVs that you add to your project and include them in the call to ptrace.

#!/bin/bash

export LD_LIBRARY_PATH="/opt/backtrace/lib64:/opt/backtrace/lib:$LD_LIBRARY_PATH:/usr/local/lib:/usr/lib:/usr/lib64:/lib:/usr/local/lib64/"
export PATH="/opt/backtrace/bin:$PATH”

HOSTNAME=`hostname`
APPLICATION=”application”
DC=”datacenter_name”
VERSION=”version”
BTT_PREFIX="/var/backtrace/${APPLICATION}"
BTT="${BTT_PREFIX}/${APPLICATION}"

KV="dc:${DC},version:${VERSION}"
# Make core directory
mkdir -p ${BTT_PREFIX}
if [ $? -ne 0 ] ; then
   echo "Failed to create ${BTT_PREFIX}"
   exit 1
fi

PTRACE=/opt/backtrace/bin/ptrace
CORONER=/opt/backtrace/bin/coroner
CORONER_CF=/etc/coronerd/coroner.cf

if [ -f $CORONER_CF ] ; then
       FILE=`$PTRACE --application=${APPLICATION} --kv=${KV} -O ${BTT} ${1}`
       RT="$?"

       if test "$RT" = "0" && test -f "$FILE"; then
               # Send the trace to the coroner database. The -u option will take
               # care of clean-up.
               ${CORONER} -c ${CORONER_CF} put -u ${APPLICATION} ${APPLICATION} ${FILE}
       else
               echo "Unknown crash condition"
       fi
fi