Skip to content
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
43 changes: 31 additions & 12 deletions sos/report/plugins/juju.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import pwd
import json
import re
from sos.report.plugins import Plugin, UbuntuPlugin, PluginOpt


Expand Down Expand Up @@ -76,25 +77,34 @@ class Juju(Plugin, UbuntuPlugin):
),
]

agent_name = ""

def setup(self):
# Juju service names are not consistent through deployments,
# so we need to use a wildcard to get the correct service names.
for service in self.get_service_names("juju*"):
self.add_journal(service)
self.add_service_status(service)

self.add_cmd_output([
'juju_engine_report',
'juju_goroutines',
'juju_heap_profile',
'juju_leases',

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You stop collecting this, is it intentional?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The juju_leases alias doesn't exist anymore, plus it was very complex to bring it here in sos.

As this portion didn't work, it doesn't make much of a difference to actually remove it.

'juju_metrics',
'juju_pubsub_report',
'juju_presence_report',
'juju_statepool_report',
'juju_statetracker_report',
'juju_unit_status',
])
juju_agent_cmds = {
'juju_engine_report': 'depengine',
'juju_goroutines': 'debug/pprof/goroutine?debug=1',
'juju_heap_profile': 'debug/pprof/heap?debug=1',
'juju_metrics': 'metrics',
'juju_pubsub_report': 'pubsub',
'juju_presence_report': 'presence',
'juju_statepool_report': 'statepool',
'juju_statetracker_report': ('debug/pprof/juju/state/tracker?'
'debug=1'),
'juju_unit_status': 'units?action=status',
}

if self.path_exists("/var/lib/juju/agents"):
for cmd, agent_cmd in juju_agent_cmds.items():
self.add_cmd_output(
self._juju_agent(agent_cmd),
suggest_filename=cmd
)

# Get agent configs for each agent.
self.add_copy_spec("/var/lib/juju/agents/*/agent.conf")
Expand Down Expand Up @@ -186,6 +196,15 @@ def setup(self):
)
self.add_cmd_output(command, runas=juju_user)

def _juju_agent(self, command):
if self.agent_name == "":
for dir_name in self.listdir("/var/lib/juju/agents"):
if re.search('machine-*|controller-*|application-*', dir_name):
self.agent_name = dir_name
break

return f"juju-introspect --agent={self.agent_name} {command}"

def postproc(self):
agents_path = "/var/lib/juju/agents/*"
protect_keys = [
Expand Down
Loading