HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //usr/lib/python3/dist-packages/sos/report/plugins/__pycache__/ceph_mon.cpython-38.pyc
U

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 monZceph_mon)ZstorageZvirtZ	containerZceph)zceph-(.*-)?mon.*)z/var/lib/ceph/mon/*z/var/lib/ceph/*/mon*�%/var/snap/microceph/common/data/mon/*rcCs�|��|_|jj�d�}|sP|�ddd��|�ddddg�|�d	d
dg�n"|�dd
ddg�|�dddg�|jddd�|�ddddddddddd d!d"d#d$d%d&d'd(d)d*d+d,g�|�	d-�}|d.d/k�r|d0�
�D]*}|�d1�r�|��d/}|�d2|���q�d3d.d4d5d6d7d8d9d:d;d<d=d>d?d@dAdBdCdDdEg}|jdFdGdHdI�|jdJdGdKdI�|jdLdM�|�
�D�dGdN�|�dOdM�|D��|jdPdM�|D�dGdN�dS)QNZ	microcephZ	ceph_confZceph_mon_log)z.*/ceph.confz$/var/log/ceph/(.*/)?ceph-.*mon.*.logz/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*.logz'/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 reportZceph_report)�tagsz
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 dumpz	device lsZdfz	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-prettyZjson_outputZceph_health_detail)�subdirrz"ceph osd tree --format json-prettyZ
ceph_osd_treecSsg|]}d|�d��qS)zceph tell mon.z mon_status�)�.0Zmidr
r
�=/usr/lib/python3/dist-packages/sos/report/plugins/ceph_mon.py�
<listcomp>�sz!CephMON.setup.<locals>.<listcomp>)rcSsg|]}d|���qS)�ceph r
�r�cmdr
r
rr�scSsg|]}d|�d��qS)rz --format json-prettyr
rr
r
rr�s)�get_ceph_version�ceph_versionZpolicyZpackage_managerZpkg_by_nameZ
add_file_tagsZadd_forbidden_pathZ
add_copy_specZadd_cmd_outputZcollect_cmd_output�
splitlines�endswith�split�get_ceph_ids)�selfZ
microceph_pkgZcrashesZcrashlnZcidZ	ceph_cmdsr
r
r�setup,s�
��	����

�����z
CephMON.setupc
Cs||�d�}|ddkrnz$|d��d}t|�d�d�WStk
rl}z|�d|���W5d}~XYnX|�d�dS)	Nzceph --versionr	rr
��.z"Could not determine ceph version: z?Failed to find ceph version, command collection will be limited)�exec_cmdr�int�	Exception�
_log_debugZ
_log_error)rZverZ_ver�errr
r
rr�s
"�zCephMON.get_ceph_versionc	
Cs*g}|jdks|jdkr�|�d�}|ddkr�|d��D]b}|��}|r:|d�d�r:z |�d�}|�||d	�Wq:ttfk
r�|�	d
�Yq:Xq:n�|jdk�r&|�d�}|ddk�r&z,t
�d
|d�}|�|�
�d	�d��Wn4tk
�r$}z|�d|���W5d}~XYnX|S)N��zps -u ceph -o argsr	rr
zceph-monz--id�zUnable to find ceph IDs�zceph statusz!(\s*mon: .* quorum) (.*) (\(.*\))�,zid determination failed: )rrrrr�index�append�
IndexError�
ValueErrorZ	_log_warn�re�search�extend�groupsr r!)	rZceph_ids�outZprocs�procZid_indexZstatsZretr"r
r
rr�s.


�"zCephMON.get_ceph_idscCs||jdkr>dddddg}|D]}d|�d�}|�d	|d
�qn0ddd
dddg}dd�|��d�}|�d	|d�|�d	�dS)Nr&�keyZusernameZpasswordZ_secretzrbd/mirror/peer/.*z(((.*)(z\\\": ))((\\\"(.*?)\\\")(.*)))rz\2\"******\"\8ZAPI_PASSWORDz
API_USER.*z
API_.*_KEYz((\".*(�|z)\":) \")(.*)(\".*)z\1*******\5)rZdo_cmd_output_sub�joinZdo_cmd_private_sub)r�keysr2Zcregr
r
r�postproc�s8
�
��	�zCephMON.postprocN)�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofilesZ
containers�filesrrrrr6r
r
r
rrsw
r)r,Zsos.report.pluginsrrrrr
r
r
r�<module>	s