HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/ceph_mon.cpython-310.pyc
o

i��d�"�@s4ddlZddlmZmZmZGdd�deee�ZdS)�N)�Plugin�RedHatPlugin�UbuntuPluginc@sHeZdZdZdZdZdZdZdZdZ	dd	�Z
d
d�Zdd
�Zdd�Z
dS)�CephMONan
    This plugin serves to collect information on monitor nodes within a Ceph
    or microceph cluster. It is designed to collect from several versions of
    Ceph, including versions that serve as the basis for RHCS 4 and RHCS 5.

    Older versions of Ceph will have collections from locations such as
    /var/log/ceph, whereas newer versions (as of this plugin's latest update)
    will have collections from /var/log/ceph/<fsid>/. This plugin attempts to
    account for this where possible across the host's filesystem.

    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.
    zCEPH mon�ceph_mon)�storage�virt�	container�ceph)zceph-(.*-)?mon.*)z/var/lib/ceph/mon/*z/var/lib/ceph/*/mon*�%/var/snap/microceph/common/data/mon/*rcCsD|��|_|jj�d�}|s%|�ddd��|�gd��|�gd��n|�gd��|�gd��|jd	d
d�|�gd��|�	d
�}|ddkrh|d�
�D]}|�d�rg|��d}|�d|���qRgd�}|jdddd�|jdddd�|jdd�|�
�D�dd�|�dd�|D��|jdd�|D�dd�dS)N�	microceph�	ceph_conf�ceph_mon_log)z.*/ceph.confz$/var/log/ceph/(.*/)?ceph-.*mon.*.log)z/etc/ceph/*keyring*z/var/lib/ceph/**/*keyring*z/var/lib/ceph/**/tmp/*mnt*z/etc/ceph/*bindpass*)z/run/ceph/**/ceph-mon*z/var/lib/ceph/**/kv_backendz/var/log/ceph/**/*ceph-mon*.log)z'/var/snap/microceph/common/**/*keyring*z(/var/snap/microceph/current/**/*keyring*z./var/snap/microceph/common/data/mon/*/store.dbz"/var/snap/microceph/common/state/*)rz./var/snap/microceph/common/logs/*ceph-mon*.logz"/var/snap/microceph/current/conf/*zceph report�ceph_report)�tags)z
ceph mon statzceph quorum_statuszceph-disk listz
ceph versionsz
ceph featuresz
ceph insightszceph crash statzceph config dumpzceph config logz!ceph config generate-minimal-conf�ceph config-key dumpzceph osd metadataz ceph osd erasure-code-profile lszceph osd crush dumpzceph osd crush show-tunablesz!ceph osd crush tree --show-shadowz
ceph mgr dumpzceph mgr metadatazceph mgr module lszceph mgr serviceszceph mgr versionsz!ceph log last 10000 debug clusterzceph log last 10000 debug auditz
ceph crash ls�statusr�output�*zceph crash info )zmon dumprz	device ls�dfz	df detailzfs lszfs dumpzpg dumpzpg statztime-sync-statuszosd statzosd df treezosd dumpzosd dfzosd perfzosd blocked-byzosd pool ls detailzosd pool autoscale-statuszmds statzosd numa-statusz'ceph health detail --format json-pretty�json_output�ceph_health_detail)�subdirrz"ceph osd tree --format json-pretty�
ceph_osd_treecS�g|]}d|�d��qS)zceph tell mon.z mon_status�)�.0�midrr�=/usr/lib/python3/dist-packages/sos/report/plugins/ceph_mon.py�
<listcomp>��z!CephMON.setup.<locals>.<listcomp>)rcSsg|]}d|���qS)�ceph r�r�cmdrrrr�scSr)r!z --format json-prettyrr"rrrr�r )�get_ceph_version�ceph_version�policy�package_manager�pkg_by_name�
add_file_tags�add_forbidden_path�
add_copy_spec�add_cmd_output�collect_cmd_output�
splitlines�endswith�split�get_ceph_ids)�self�
microceph_pkg�crashes�crashln�cid�	ceph_cmdsrrr�setup,sL
�	

����
�z
CephMON.setupc
Cs~|�d�}|ddkr8z|d��d}t|�d�d�WSty7}z|�d|���WYd}~nd}~ww|�d�dS)	Nzceph --versionrrr��.z"Could not determine ceph version: z?Failed to find ceph version, command collection will be limited)�exec_cmdr0�int�	Exception�
_log_debug�
_log_error)r2�ver�_ver�errrrrr$�s
���zCephMON.get_ceph_versionc	
Cs*g}|jdks|jdkrP|�d�}|ddkrN|d��D]0}|��}|rM|d�d�rMz|�d�}|�||d	�WqttfyL|�	d
�Yqwq|S|jdkr�|�d�}|ddkr�zt
�d
|d�}|�|�
�d	�d��W|Sty�}z|�d|���WYd}~|Sd}~ww|S)N��zps -u ceph -o argsrrrzceph-monz--id�zUnable to find ceph IDs�zceph statusz!(\s*mon: .* quorum) (.*) (\(.*\))�,zid determination failed: )r%r;r.r0r/�index�append�
IndexError�
ValueError�	_log_warn�re�search�extend�groupsr=r>)	r2�ceph_ids�out�procs�proc�id_index�stats�retrBrrrr1�s<

��
�
����zCephMON.get_ceph_idscCsn|jdkrgd�}|D]}d|�d�}|�d|d�qngd�}dd	�|��d
�}|�d|d�|�d�dS)NrF)�key�username�password�_secret�rbd/mirror/peer/.*z(((.*)(z\\\": ))((\\\"(.*?)\\\")(.*)))rz\2\"******\"\8)�API_PASSWORDz
API_USER.*z
API_.*_KEYrXr[r\z((\".*(�|z)\":) \")(.*)(\".*)z\1*******\5)r%�do_cmd_output_sub�join�do_cmd_private_sub)r2�keysrX�cregrrr�postproc�s

��	�zCephMON.postprocN)�__name__�
__module__�__qualname__�__doc__�
short_desc�plugin_name�profiles�
containers�filesr%r8r$r1rdrrrrrsw
r)rM�sos.report.pluginsrrrrrrrr�<module>s