|
10 | 10 |
|
11 | 11 | import pwd |
12 | 12 | import json |
| 13 | +import re |
13 | 14 | from sos.report.plugins import Plugin, UbuntuPlugin, PluginOpt |
14 | 15 |
|
15 | 16 |
|
@@ -76,25 +77,34 @@ class Juju(Plugin, UbuntuPlugin): |
76 | 77 | ), |
77 | 78 | ] |
78 | 79 |
|
| 80 | + agent_name = "" |
| 81 | + |
79 | 82 | def setup(self): |
80 | 83 | # Juju service names are not consistent through deployments, |
81 | 84 | # so we need to use a wildcard to get the correct service names. |
82 | 85 | for service in self.get_service_names("juju*"): |
83 | 86 | self.add_journal(service) |
84 | 87 | self.add_service_status(service) |
85 | 88 |
|
86 | | - self.add_cmd_output([ |
87 | | - 'juju_engine_report', |
88 | | - 'juju_goroutines', |
89 | | - 'juju_heap_profile', |
90 | | - 'juju_leases', |
91 | | - 'juju_metrics', |
92 | | - 'juju_pubsub_report', |
93 | | - 'juju_presence_report', |
94 | | - 'juju_statepool_report', |
95 | | - 'juju_statetracker_report', |
96 | | - 'juju_unit_status', |
97 | | - ]) |
| 89 | + juju_agent_cmds = { |
| 90 | + 'juju_engine_report': 'depengine', |
| 91 | + 'juju_goroutines': 'debug/pprof/goroutine?debug=1', |
| 92 | + 'juju_heap_profile': 'debug/pprof/heap?debug=1', |
| 93 | + 'juju_metrics': 'metrics', |
| 94 | + 'juju_pubsub_report': 'pubsub', |
| 95 | + 'juju_presence_report': 'presence', |
| 96 | + 'juju_statepool_report': 'statepool', |
| 97 | + 'juju_statetracker_report': ('debug/pprof/juju/state/tracker?' |
| 98 | + 'debug=1'), |
| 99 | + 'juju_unit_status': 'units?action=status', |
| 100 | + } |
| 101 | + |
| 102 | + if self.path_exists("/var/lib/juju/agents"): |
| 103 | + for cmd, agent_cmd in juju_agent_cmds.items(): |
| 104 | + self.add_cmd_output( |
| 105 | + self._juju_agent(agent_cmd), |
| 106 | + suggest_filename=cmd |
| 107 | + ) |
98 | 108 |
|
99 | 109 | # Get agent configs for each agent. |
100 | 110 | self.add_copy_spec("/var/lib/juju/agents/*/agent.conf") |
@@ -186,6 +196,15 @@ def setup(self): |
186 | 196 | ) |
187 | 197 | self.add_cmd_output(command, runas=juju_user) |
188 | 198 |
|
| 199 | + def _juju_agent(self, command): |
| 200 | + if self.agent_name == "": |
| 201 | + for dir_name in self.listdir("/var/lib/juju/agents"): |
| 202 | + if re.search('machine-*|controller-*|application-*', dir_name): |
| 203 | + self.agent_name = dir_name |
| 204 | + break |
| 205 | + |
| 206 | + return f"juju-introspect --agent={self.agent_name} {command}" |
| 207 | + |
189 | 208 | def postproc(self): |
190 | 209 | agents_path = "/var/lib/juju/agents/*" |
191 | 210 | protect_keys = [ |
|
0 commit comments