A shell utility for adding Scarf analytics to any shell or bash script.
You'll need a Scarf account and a File Package created. Enable Event Collection Only
.
Read more here: https://docs.scarf.sh
Populate a few global SCARF_
prefixed configuration variables, import the scarf.sh
script from wherever you'd like to bundle it, and call immediately invoke the setup_scarf_telemetry
function.
Scarf will send a small payload right before your script exits.
# Your Scarf Gateway URL
SCARF_BASE_URL="https://avi.gateway.scarf.sh/bash-test"
# The version of your package, if any
SCARF_PACKAGE_VERSION="0.1"
# Source the scarf.sh script
source ./scarf.sh
# Initialize it
setup_scarf_telemetry
# Write your script as usual
- The version of your script
- The platform your script is run on
- The elapsed time of your script
- The exit code
export SCARF_ANALYTICS=false
- Requires
curl
on the system - Telemetry is best-effort based. It will silently and quickly time out if it can't connect to Scarf or complete the request quickly enough.