Skip to content

Instantly share code, notes, and snippets.

@aemneina
Created February 7, 2019 05:26
Show Gist options
  • Save aemneina/c3847c285d82f2fef78ebb01969377a7 to your computer and use it in GitHub Desktop.
Save aemneina/c3847c285d82f2fef78ebb01969377a7 to your computer and use it in GitHub Desktop.
memory dump for rancher server
#!/bin/bash
# Create temp directory
TMPDIR=$(mktemp -d)
cd /tmp/debug
curl localhost:6060/debug/pprof/goroutine -o $TMPDIR/goroutine
curl localhost:6060/debug/pprof/heap -o $TMPDIR/heap
curl localhost:6060/debug/pprof/threadcreate -o $TMPDIR/threadcreate
curl localhost:6060/debug/pprof/block -o $TMPDIR/block
curl localhost:6060/debug/pprof/mutex -o $TMPDIR/mutex
FILENAME="$(hostname)-$(date +'%Y-%m-%d_%H_%M_%S').tar"
tar cf /tmp/$FILENAME -C ${TMPDIR}/ .
if $(command -v gzip >/dev/null 2>&1); then
gzip /tmp/${FILENAME}
FILENAME="${FILENAME}.gz"
fi
echo "Created /tmp/${FILENAME}"
echo "You can now remove ${TMPDIR}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment