Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[snap] Add more items to collect #3382

Merged
merged 1 commit into from
Oct 15, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 50 additions & 1 deletion sos/report/plugins/snap.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@

from sos.report.plugins import Plugin, IndependentPlugin

import re


class Snap(Plugin, IndependentPlugin):

Expand All @@ -23,8 +25,55 @@ def setup(self):
self.add_cmd_output("snap list --all", root_symlink="installed-snaps")
self.add_cmd_output([
"snap --version",
"snap changes"
TurboTurtle marked this conversation as resolved.
Show resolved Hide resolved
"snap version",
"snap whoami",
"snap model --verbose",
"snap model --serial --verbose",
"snap services",
"snap connections",
"snap changes --abs-time",
"snap validate",
"snap debug state --abs-time --changes /var/lib/snapd/state.json",
"snap debug stacktraces",
"snap get system -d",
])

all_pkgs = self.policy.package_manager.packages

for pkg_name in all_pkgs:
pkg = self.policy.package_manager.pkg_by_name(pkg_name)
if pkg['pkg_manager'] == 'snap':
self.add_cmd_output(f"snap connections {pkg['name']}")

self.add_cmd_output("snap debug connectivity", timeout=10)

# If we have gadget snaps, then we collect more files, this is
# typically defined in the Notes column
snap_list = self.exec_cmd('snap list')

if snap_list['status'] == 0:
output = snap_list['output']

for line in output.splitlines()[1:]:
if line == "":
continue
snap_pkg = line.split()
if re.match(r".*gadget.*$", snap_pkg[5]):
self.add_copy_spec([
f"/snap/{snap_pkg[0]}/current/meta/gadget.yaml",
])

snap_changes = self.collect_cmd_output('snap changes')

if snap_changes['status'] == 0:
output = snap_changes['output']

for line in output.splitlines()[1:]:
if line == "":
continue
change = line.split()
change_id, change_status = change[0], change[1]
if change_status == "Doing" or change_status == "Error":
self.add_cmd_output(f"snap tasks {change_id} --abs-time")

# vim: set et ts=4 sw=4 :