o
G%@i @ sB d dl Z d dlZd dlZd dlmZmZmZ G dd deeZdS ) N)PluginUbuntuPlugin PluginOptc @ sx e Zd ZdZdZdZdZdZedde dd ed
de
dd ed
de
dd edde
dd gZdZdd Z
dd Zdd ZdS )Jujua3 The Juju plugin is aimed at collecting Juju-related logs,
configurations, and controller/model state(s).
Logs and agent configuration information (/var/log/juju and /var/lib/juju)
is collected by default since these are useful for troubleshooting.
The Juju state collection is disabled by default and can be enabled with
the 'juju-state' option. Collecting Juju state is safe in theory, but it
does act on the live controller(s)/model(s) and is therefore optional.
The default Juju state collection collects all controllers and models that
the 'juju-user' (default=ubuntu) has access to.
Specific controllers or models can be collected using the 'controllers'
and 'models' options.
Important: the string list is whitespace delimited, not colon delimited
(sos plugin standard). This is due to the underlying Juju CLI accepting
specific models in the format 'controller:model' and whitespaces are not
allowed in either controller and model names.
Example: models="controller_a:model_x controller_b:model_y"
zJuju orchestration tooljuju)virtsysmgmt)
/var/log/juju
juju-stateFz Include Juju state in the report)defaultval_typedesc juju-userubuntuzJuju client user.controllers z[Collect Juju state for specified controllers. Uses a whitespace delimited list.modelszVCollect Juju state for specified models. Uses a whitespace delimited list.c
C sH | dD ]}| | | | qdddddddd d
d }| dr6| D ]\}}| j| ||d
q'| d | jddgdd | dr[| g d |
d |
d n| d | dsgd S | d}zt| W n t
y | d| d Y d S w | dr| dr| d d S | jd|d }|d! d"krt| dd#}|r|d$hkr|}ntt|d% d }ni }| dr| dd#D ]} d&| d'}
| j|
|d qd S |D ]7}| jd(| d'|d }|d! d"kr!t|d% d }
|
D ]} | d) }d&| d*| d'}
| j|
|d q qd S )+Nzjuju* depenginezdebug/pprof/goroutine?debug=1zdebug/pprof/heap?debug=1metricspubsubpresence statepoolz&debug/pprof/juju/state/tracker?debug=1zunits?action=status) juju_engine_reportjuju_goroutinesjuju_heap_profilejuju_metricsjuju_pubsub_reportjuju_presence_reportjuju_statepool_reportjuju_statetracker_reportjuju_unit_status/var/lib/juju/agents)suggest_filenamez!/var/lib/juju/agents/*/agent.confz/var/log/juju*z/var/lib/juju*T) recursiveall_logs)r z
/var/lib/jujuz/var/lib/juju/**/.*z/var/lib/juju/kvmz/var/lib/juju/toolsz/var/log/juju/*.logr
r zUser "z4" does not exist, will not collect Juju information.r r zWOptions: controllers, models are mutually exclusive. Will not collect Juju information.zjuju controllers --format=json)runasstatusr r outputzjuju status -m z --format=jsonzjuju models --all -c z
short-name:)get_service_namesadd_journaladd_service_statuspath_existsitemsadd_cmd_output_juju_agent
add_copy_specadd_dir_listing
get_optionadd_forbidden_pathpwdgetpwnamKeyError _log_warncollect_cmd_outputsetsplitjsonloadskeysexec_cmd)selfservicejuju_agent_cmdscmd agent_cmd juju_usercontrollers_jsondesired_controllersr modelcommand
controllermodels_jsonr
short_name rM 9/usr/lib/python3/dist-packages/sos/report/plugins/juju.pysetupR s
z
Juju.setupc C sB | j dkr| dD ]
}td|r|| _ nq
d| j d| S )Nr r! z$machine-*|controller-*|application-*zjuju-introspect --agent=r' )
agent_namelistdirresearch)r@ rI dir_namerM rM rN r0 s
zJuju._juju_agentc C sV d}g d}dd | d}d}| ||| | ddd | | | d
d S )Nz/var/lib/juju/agents/*)sharedsecretapipasswordoldpassword
statepasswordz(^\s*(|z
)\s*:\s*)(.*)z\1*********z,/var/log/juju/unit-nova-compute-(.*).log(.*)zauth\(key=(.*)\)zauth(key=******)zjuju controllers)joindo_path_regex_subdo_file_private_subdo_cmd_private_sub)r@ agents_pathprotect_keys
keys_regex sub_regexrM rM rN postproc s
z
Juju.postprocN)__name__
__module____qualname____doc__
short_descplugin_nameprofilesfilesr boolstroption_listrP rO r0 rb rM rM rM rN r sF u r )r5 r<