From 487d9e768e0a636617c85d5a4c5fea0c9ba50370 Mon Sep 17 00:00:00 2001 From: mcw-work Date: Wed, 21 May 2025 07:51:33 +0100 Subject: [PATCH 1/3] Fix script name in Readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index fb604b3..7cc42c2 100644 --- a/README.md +++ b/README.md @@ -181,4 +181,4 @@ _Note: some scripts may require python3-requests deb (or PyPI requests) in order ### Debugging - **Tutorial**: Collect a large amount of SnapD and core system information that could be useful when debugging a system with Canonical Support - - [**remove-user.py**](./debugging/snap-debug-info.sh) + - [**snap-debug-info.py**](./debugging/snap-debug-info.sh) From c12bed0e535b7fa4148526b63b1c8918153caab9 Mon Sep 17 00:00:00 2001 From: mcw-work Date: Mon, 2 Jun 2025 13:32:37 +0100 Subject: [PATCH 2/3] Added handling for SnapD not responding plus a few small typos. --- debugging/snap-debug-info.sh | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/debugging/snap-debug-info.sh b/debugging/snap-debug-info.sh index 58a6c8e..a98e82f 100644 --- a/debugging/snap-debug-info.sh +++ b/debugging/snap-debug-info.sh @@ -8,7 +8,7 @@ # be able to extract logs using the journalctl command. This is because the journalctl # command does not support the log format used by Core 24. # -# If you are using Core 24, you can resovle this by using a Landscape client track +# If you are using Core 24, you can resolve this by using a Landscape client track # that is based on Core 24. @@ -41,7 +41,7 @@ echo "=================================" journalctl -u snapd --no-pager | grep "DENIED" echo "" -echo "\nSNAPD PROCESS INFORMATION:" +echo "SNAPD PROCESS INFORMATION:" echo "=================================" ps -ax | grep snapd @@ -51,10 +51,10 @@ ps -ax | grep snapd python3 << END import socket import pprint -import subprocess import json from http.client import HTTPResponse from io import BytesIO +import errno BASE_URL = "http://localhost/v2" SNAPD_SOCKET = "/run/snapd.socket" @@ -74,7 +74,13 @@ def print_services(apps, indent=0): def make_API_call(method, path): sock = socket.socket(family=socket.AF_UNIX) - sock.connect(SNAPD_SOCKET) + try: + sock.connect(SNAPD_SOCKET) + except socket.error as e: + if e.errno in (errno.ECONNREFUSED, errno.ENOENT, errno.ETIMEDOUT): + raise Exception(f"Could not connect to snapd socket: {e}") + else: + raise url = BASE_URL + path response = HTTPResponse(sock, method=method, url=url) @@ -145,4 +151,4 @@ print("\nValidation Sets Information:") print("=================================") pprint.pprint(make_API_call("GET", "/validation-sets")) -END +END \ No newline at end of file From d460918ea5774c01df1b1e7e7a059fd0f6052297 Mon Sep 17 00:00:00 2001 From: mcw-work <111986660+mcw-work@users.noreply.github.com> Date: Mon, 2 Jun 2025 20:03:09 +0100 Subject: [PATCH 3/3] Update snap-debug-info.sh Changed to OSError --- debugging/snap-debug-info.sh | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/debugging/snap-debug-info.sh b/debugging/snap-debug-info.sh index a98e82f..dda0e33 100644 --- a/debugging/snap-debug-info.sh +++ b/debugging/snap-debug-info.sh @@ -76,7 +76,7 @@ def make_API_call(method, path): sock = socket.socket(family=socket.AF_UNIX) try: sock.connect(SNAPD_SOCKET) - except socket.error as e: + except OSError as e: if e.errno in (errno.ECONNREFUSED, errno.ENOENT, errno.ETIMEDOUT): raise Exception(f"Could not connect to snapd socket: {e}") else: @@ -151,4 +151,4 @@ print("\nValidation Sets Information:") print("=================================") pprint.pprint(make_API_call("GET", "/validation-sets")) -END \ No newline at end of file +END