Skip to content

Instantly share code, notes, and snippets.

@anonymouse64
Last active March 23, 2022 13:00
Show Gist options
  • Save anonymouse64/77baa3b78572c125c71f5712d1c8a1e1 to your computer and use it in GitHub Desktop.
Save anonymouse64/77baa3b78572c125c71f5712d1c8a1e1 to your computer and use it in GitHub Desktop.
[DEPRECATED] Basic debugging information for snap devices
#!/bin/bash
##############################################################################
##############################################################################
#
# THIS IS DEPRECATED - PLEASE USE THE NEW HOME FOR THIS SCRIPT:
# https://github.com/snapcore/snapd/blob/master/debug-tools/snap-debug-info.sh
#
##############################################################################
##############################################################################
h1(){ echo -e "\n==================== $@ ===================="; }
h2(){ echo -e "\n========== $@ =========="; }
h3(){ echo -e "\n===== $@ ====="; }
h1 "SNAP VERSION"; snap version
h1 "SNAP WHOAMI"; snap whoami
h1 "SNAP MODEL"; snap model --verbose
h1 "SNAP MODEL SERIAL"; snap model --serial --verbose
h1 "SNAP LIST"; snap list
h1 "SNAP SERVICES"; snap services
h1 "SNAP CONNECTIONS"; snap connections
h1 "PER-SNAP CONNECTIONS"
for sn in $(snap list | awk 'NR>1 {print $1}'); do
h2 "PER-SNAP $sn CONNECTIONS"
snap connections $sn
done
h1 "SNAP CHANGES"
snap changes
h1 "GADGET SNAP GADGET.YAML"
cat /snap/$(snap list | awk '($6 ~ /.*gadget.*$/) {print $1}')/current/meta/gadget.yaml
h1 "SNAP CHANGES (in Doing)"
# print off the output of snap tasks <chg> for every chg that is in Doing state
for chg in $(snap changes | tail -n +2 | grep -Po '(?:[0-9]+\s+Doing)' | awk '{print $1}'); do
h3 "tasks for $chg"
snap tasks $chg
done
h1 "SNAP CHANGES (in Error)"
# same as above, just for Error instead of Doing
for chg in $(snap changes | tail -n +2 | grep -Po '(?:[0-9]+\s+Error)' | awk '{print $1}'); do
h3 "tasks for $chg"
snap tasks $chg
done
# sudo needed for these commands
h1 "OFFLINE SNAP CHANGES"; sudo snap debug state --changes /var/lib/snapd/state.json
h1 "SNAPD STACKTRACE"; sudo snap debug stacktraces
h1 "SNAP SYSTEM CONFIG"; sudo snap get system -d
h1 "SNAPD JOURNAL"; sudo journalctl --no-pager -u snapd
h1 "SNAPD.SERVICE STATUS"; sudo systemctl --no-pager status snapd
h1 "UPTIME"; uptime
h1 "DATE (IN UTC)"; date --utc
h1 "DISK SPACE"; df -h
h1 "DENIED MESSAGES"; sudo journalctl --no-pager | grep DENIED
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment