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 via curl/https is:

curl --data-binary @/path/to/snapshot.btt https://yourcompany.sp.backtrace.io:6098/post?token=your_submission_token

Script to Generate & Submit Snapshot

You will need to customize this script to populate:

#!/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"

# Customize these for your endpoint and application
ENDPOINT="https://yourcompany.sp.backtrace.io:6098"
APPLICATION="yourapp"
TOKEN="yourtoken" # your submission token

# Gather your KVs here
DC="datacenter_name"
VERSION="version"
KV="dc:${DC},version:${VERSION}"

BTT_PREFIX="/var/backtrace/${APPLICATION}"
BTT="${BTT_PREFIX}/${APPLICATION}"
PTRACE=/opt/backtrace/bin/ptrace
# Make core directory
mkdir -p ${BTT_PREFIX}
if [ $? -ne 0 ] ; then
   echo "Failed to create ${BTT_PREFIX}"
   exit 1
fi

FILE=`$PTRACE --load= --application=${APPLICATION} --kv=${KV} -O ${BTT} ${1}`
RT="$?"

if test "$RT" = "0" && test -f "$FILE"; then
      curl --data-binary @${FILE} ${ENDPOINT}/post?token=${TOKEN}
      rm -f ${FILE}
else
      echo "Unknown crash condition"
fi
Did this answer your question?