
    -_g                     :    d dl Z d dlmZmZmZ  G d deee      Zy)    N)PluginRedHatPluginUbuntuPluginc                   0    e Zd ZdZdZdZdZdZdZd Z	d Z
y	)
CephMGRa?  
    This plugin is for capturing information from Ceph mgr nodes. While the
    majority of this plugin should be version-agnostic, several collections are
    dependent upon the version of Ceph installed. Versions that correlate to
    RHCS 4 or RHCS 5 are explicitly handled for differences such as those
    pertaining to log locations on the host filesystem.

    Note that while this plugin will activate based on the presence of Ceph
    containers, commands are run directly on the host as those containers are
    often not configured to successfully run the `ceph` commands collected by
    this plugin. These commands are majorily `ceph daemon` commands that will
    reference discovered admin sockets under /var/run/ceph.

    Users may expect to see several collections twice - once in standard output
    from the `ceph` command, and again in JSON format. The latter of which will
    be placed in the `json_output/` subdirectory within this plugin's directory
    in the report archive. These JSON formatted collections are intended to
    aid in automated analysis.
    zCEPH mgrceph_mgr)storagevirt	containerceph)z/var/lib/ceph/mgr/*z/var/lib/ceph/*/mgr*z%/var/snap/microceph/common/data/mgr/*)zceph-(.*-)?mgr.*c                 R   | j                  d      }| j                  j                  j                  d      }g d}| j	                  d      }|d   dk(  r|g dz  }g d}d	}|scd
}| j                  ddi       | j                  g d       |s| j                  dg       n| j                  dg       | j                  g d       nNd}| j                  ddi       | j                  dg       |s| j                  dg       n| j                  dg       | j                  |D cg c]  }d| 	 c}       | j                  |D cg c]  }d| d
 c}d       | j                  | j                  |      D cg c]  }|D ]
  }d| d|   c}}       y c c}w c c}w c c}}w )Nall_logs	microceph)zbalancer evalzbalancer statuszbalancer status detailzhealthcheck history lszlog last cephadmzmgr dumpzmgr metadatazmgr module lszmgr serviceszmgr statzmgr versionszceph orch statusstatusr   )zorch host lszorch device lszorch lszorch ls --exportzorch pszorch status --detailzorch upgrade status)zconfig diffzconfig showzcounter dumpzcounter schema
dump_cachedump_mempoolsdump_osd_networkmds_requestsmds_sessionsobjecter_requestsz	perf dumpzperf histogram dumpzperf histogram schemazperf schemar   version z/var/run/cephz"/var/log/ceph/(.*/)?ceph-mgr.*.logceph_mgr_log)z/etc/ceph/*keyring*z/var/lib/ceph/**/*keyring*z/var/lib/ceph/**/osd*z/var/lib/ceph/**/mon*z/var/lib/ceph/**/tmp/*mnt*z/etc/ceph/*bindpass*z/var/log/ceph/**/ceph-mgr*.logz/var/log/ceph/**/ceph-mgr*.log*)z/var/lib/ceph/**/mgr*z/var/lib/ceph/**/bootstrap-mgr/z/run/ceph/**/ceph-mgr*z/var/snap/microceph/current/runz./var/snap/microceph/common/logs/ceph-mgr.*.logz'/var/snap/microceph/common/**/*keyring*z-/var/snap/microceph/common/logs/ceph-mgr*.logz./var/snap/microceph/common/logs/ceph-mgr*.log*zceph z --format json-prettyjson_output)subdirzceph daemon  )

get_optionpolicypackage_managerpkg_by_nameexec_cmdadd_file_tagsadd_forbidden_pathadd_copy_specadd_cmd_output	get_socks)	selfr   microceph_pkgceph_mgr_cmdsorch_configuredcmds	directorycmdms	            =/usr/lib/python3/dist-packages/sos/report/plugins/ceph_mgr.pysetupzCephMGR.setup-   s   ??:.33??L
 --(:;8$)  M
& 	'I4n   ## 	% 	 ""4$  ""5$      :I@  
 ##9%  ""C$  ""D$  	&34suSE]4	6 	;HICuSE./I  	 	

 	.2nnY.G)* 1#Qse$$ 	
 5 Js   #FF:F#
c                     g }t        j                  |      D ]R  \  }}}|D ]G  }|j                  d      s|j                  d      s'|j	                  | j                  ||             I T |S )z
        Find any available admin sockets under /var/run/ceph (or subdirs for
        later versions of Ceph) which can be used for ceph daemon commands
        zceph-mgrz.asok)oswalk
startswithendswithappend	path_join)r'   r,   ceph_socketsrdir_filesfiles          r/   r&   zCephMGR.get_socks   sr    
  ggi0 	DND!U D??:.4==3I ''tT(BCD	D     N)__name__
__module____qualname____doc__
short_descplugin_nameprofilesr;   
containersr0   r&    r=   r/   r   r      s0    ( JK7H6E&Js
j
r=   r   )r2   sos.report.pluginsr   r   r   r   rF   r=   r/   <module>rH      s"    
 A A\flL \r=   