HEX
Server: Apache/2.4.58 (Ubuntu)
System: Linux ip-172-26-0-120 6.17.0-1009-aws #9~24.04.2-Ubuntu SMP Fri Mar 6 23:50:29 UTC 2026 x86_64
User: ubuntu (1000)
PHP: 8.3.6
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/sos/report/plugins/__pycache__/ceph_mon.cpython-312.pyc
�

O6uf�%��:�ddlZddlmZmZmZGd�deee�Zy)�N)�Plugin�RedHatPlugin�UbuntuPluginc�@�eZdZdZdZdZdZdZdZdZ	d�Z
d	�Zd
�Zd�Z
y)
�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/*rc��|jd�}|j�|_|jjjd�}|sb|j
ddd��|jgd��|s|jdg�n|jdg�|jd	d
g�nM|jgd��|s|jdg�n|jd
g�|jddg�|jdd��|jgd��|jd�}|ddk(rQ|dj�D];}|jd�s�|j�d}|jd|����=gd�}|jddd��|jddd ��|j|j�D�cgc]}d!|�d"���
c}d�#�|j|D�cgc]}d$|����	c}�|j|D�cgc]}d$|�d%���
c}d�#�ycc}wcc}wcc}w)&N�all_logs�	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/var/log/ceph/**/*ceph-mon*.logz /var/log/ceph/**/*ceph-mon*.log*z/run/ceph/**/ceph-mon*z/var/lib/ceph/**/kv_backend)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/*z./var/snap/microceph/common/logs/*ceph-mon*.logz//var/snap/microceph/common/logs/*ceph-mon*.log*r
z"/var/snap/microceph/current/conf/*zceph report�ceph_report)�tags)zceph config dumpz!ceph config generate-minimal-confzceph config log�ceph config-key dumpzceph crash statz
ceph featureszceph health detailz
ceph insightszceph log last 10000 debug auditz!ceph log last 10000 debug clusterz
ceph mgr dumpzceph mgr metadatazceph mgr module lszceph mgr serviceszceph mgr versionsz
ceph mon statzceph osd crush dumpzceph osd crush show-tunablesz!ceph osd crush tree --show-shadowz ceph osd erasure-code-profile lszceph osd metadatazceph quorum_statusz
ceph versionszceph-disk listz
ceph crash ls�statusr�output�*zceph crash info )z	device lsz	df detail�dfzfs dumpzfs lszmds statzmon dumpzosd blocked-byzosd df treezosd dfzosd dumpzosd numa-statuszosd perfzosd pool autoscale-statuszosd pool ls detailzosd statzpg dumpzpg statrztime-sync-statusz'ceph health detail --format json-pretty�json_output�ceph_health_detail)�subdirrz"ceph osd tree --format json-pretty�
ceph_osd_treezceph tell mon.z mon_status)rzceph z --format json-pretty)�
get_option�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)	�selfr�
microceph_pkg�crashes�crashln�cid�	ceph_cmds�mid�cmds	         �=/usr/lib/python3/dist-packages/sos/report/plugins/ceph_mon.py�setupz
CephMON.setup,s����?�?�:�.�� �1�1�3������3�3�?�?��L�
����� +�8F� �
�

�#�#�%�
���"�"�5�$���"�"�6�$��
���(�-� �
�
�#�#�%�
���"�"�D�$���"�"�E�$��
���7�4� �
�
	
���M�
��>����
�	�<�)�)�/�:���8���!�"�8�,�7�7�9�
B���#�#�C�(�!�-�-�/�!�,�C��'�'�*:�3�%�(@�A�
B�

�	�.	
���E�#0�!5�	�	7�	
���@�#0�!0�	�	2�	
���:>�:K�:K�:M�N�3�~�c�U�+�
.�N� �	�	
�
	
���i�@�s�u�S�E�]�@�A�	
���;D�E�C�u�S�E�.�
/�E� �	�	
��
O��A��
Fs�
H4�;H9�
H>c��|jd�}|ddk(r4	|dj�d}t|jd�d�S|jd	�y#t$r}|j	d|���Yd}~�4d}~wwxYw)
z% Get the versions of running daemons zceph --versionrrr��.z"Could not determine ceph version: Nz?Failed to find ceph version, command collection will be limited)�exec_cmdr+�int�	Exception�
_log_debug�
_log_error)r-�ver�_ver�errs    r5rzCephMON.get_ceph_version�s����m�m�,�-���x�=�A��
L��8�}�*�*�,�Q�/���4�:�:�c�?�1�-�.�.�	
���M�	
����
L����"D�S�E� J�K�K��
L�s�2A � 	B�)B�Bc��g}|jdvr�|jd�}|ddk(ri|dj�D]S}|j�}|s�|dj	d�s�+	|jd�}|j
||dz��U|S|jd
k\rf|jd�}|ddk(rM	tjd|d�}|j|j�djd
��|S|S#ttf$r|jd	�Y��wxYw#t$r}|jd|���Yd}~|Sd}~wwxYw)z! Get the IDs of the Ceph daemons )��zps -u ceph -o argsrrrzceph-monz--id�zUnable to find ceph IDs�zceph statusz!(\s*mon: .* quorum) (.*) (\(.*\))�,zid determination failed: N)r r:r)r+r*�index�append�
IndexError�
ValueError�	_log_warn�re�search�extend�groupsr<r=)	r-�ceph_ids�out�procs�proc�id_index�stats�retrAs	         r5r,zCephMON.get_ceph_ids�sg��������(��-�-� 4�5�C��8�}��!� ��]�5�5�7�F�E� �;�;�=�D���Q�� 0� 0�� <�F�'+�z�z�&�'9�H�$�O�O�D��A��,>�?�
F�(���
�
�"�
$��M�M�-�0�E��X��!�#�G��)�)�$H�$)�(�O�5�C��O�O�C�J�J�L��O�$9�$9�#�$>�?���x���!+�J�7�F� �N�N�+D�E�F��!�G��O�O�&?��u�$E�F�F����G�s+�)(D�>A
D2� D/�.D/�2	E�;E�Ec���|jdk\r%gd�}|D]}d|�d�}|jd|d��n,gd�}dd	j|��d
�}|jd|d�|jd�y)NrF)�key�username�password�_secret�rbd/mirror/peer/.*z(((.*)(z\\\": ))((\\\"(.*?)\\\")(.*)))rz\2\"******\"\8)�API_PASSWORDz
API_USER.*z
API_.*_KEYrYr\r]z((\".*(�|z)\":) \")(.*)(\".*)z\1*******\5)r �do_cmd_output_sub�join�do_cmd_private_sub)r-�keysrY�cregs    r5�postproczCephMON.postproc�s�������"��D��
��!�#��&D�E���&�&�.��6G��
��D��c�h�h�t�n�-�-@�A�D��"�"�*�D�.�
�	
��� 6�7�N)�__name__�
__module__�__qualname__�__doc__�
short_desc�plugin_name�profiles�
containers�filesr r6rr,re�rfr5rrsB���"�J��K�7�H�'�J�
6�E��L�F
�P
��B!8rfr)rM�sos.report.pluginsrrrrrprfr5�<module>rrs"��
�A�A�w8�f�l�L�w8rf