Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/ceph_mon.cpython-36.pyc

3

�f�%�@s4ddlZddlmZmZmZGdd�deee�ZdS)�N)�Plugin�RedHatPlugin�UbuntuPluginc@sHeZdZdZdZdZdZdZdZdZ	d
d�Z
dd�Zdd�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�storage�virt�	container�ceph�ceph-(.*-)?mon.*�/var/lib/ceph/mon/*�/var/lib/ceph/*/mon*�%/var/snap/microceph/common/data/mon/*rcCs�|jd�}|j�|_|jjjd�}|sv|jddd��|jdddd	g�|sZ|jd
g�n|jdg�|jdd
g�n>|jddddg�|s�|jdg�n|jdg�|jddg�|j	ddd�|j	dddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0g�|j
d1�}|d2d3k�rTx>|d4j�D].}|jd5��r"|j
�d3}|j	d6|����q"Wd7d8d9d:d;d<d=d>d?d@dAdBdCdDdEdFdGdHd2dIg}|j	dJdKdLdM�|j	dNdKdOdM�|j	dPdQ�|j�D�dKdR�|j	dSdQ�|D��|j	dTdQ�|D�dKdR�dS)UN�all_logsZ	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/var/log/ceph/**/*ceph-mon*.logz /var/log/ceph/**/*ceph-mon*.log*z/run/ceph/**/ceph-mon*z/var/lib/ceph/**/kv_backendz'/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*z%/var/snap/microceph/common/data/mon/*z"/var/snap/microceph/current/conf/*zceph reportZceph_report)�tagszceph config dumpz!ceph config generate-minimal-confzceph config logzceph 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 detailZdfzfs dumpzfs lszmds statzmon dumpzosd blocked-byzosd df treezosd dfzosd dumpzosd numa-statuszosd perfzosd pool autoscale-statuszosd pool ls detailzosd statzpg dumpzpg statztime-sync-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�)�.0Zmidrr�/usr/lib/python3.6/ceph_mon.py�
<listcomp>�sz!CephMON.setup.<locals>.<listcomp>)rcSsg|]}d|���qS)zceph r)r�cmdrrrr�scSsg|]}d|�d��qS)zceph z --format json-prettyr)rrrrrr�s)Z
get_option�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)�selfrZ
microceph_pkgZcrashesZcrashlnZcidZ	ceph_cmdsrrr�setup,s�






z
CephMON.setupcCsz|jd�}|ddkrly"|dj�d}t|jd�d�Stk
rj}z|jd|���WYdd}~XnX|jd	�dS)
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_debugZ
_log_error)rZverZ_ver�errrrrr�s
"zCephMON.get_ceph_versionc	Cs$g}|jdkr�|jd�}|ddkr�x�|dj�D]b}|j�}|r2|djd�r2y |jd�}|j||d	�Wq2ttfk
r�|j	d
�Yq2Xq2Wn�|jdk�r |jd�}|ddk�r y,t
jd
|d�}|j|j
�d	jd��Wn4tk
�r}z|jd|���WYdd}~XnX|S)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))rr#rrr�index�append�
IndexError�
ValueErrorZ	_log_warn�re�search�extend�groupsr%r&)	rZceph_ids�outZprocs�procZid_indexZstats�retr'rrrr�s,




"zCephMON.get_ceph_idscCs�|jdkrBdddddg}xX|D]}d|�d�}|jd	|d
�qWn0ddd
dddg}ddj|��d�}|jd	|d�|jd	�dS)Nr+�keyZusernameZpasswordZ_secretzrbd/mirror/peer/.*z(((.*)(z\\\": ))((\\\"(.*?)\\\")(.*)))zceph config-key dumpz\2\"******\"\8ZAPI_PASSWORDz
API_USER.*z
API_.*_KEYz((\".*(�|z)\":) \")(.*)(\".*)z\1*******\5)rZdo_cmd_output_sub�joinZdo_cmd_private_sub)r�keysr8Zcregrrr�postproc�s(


zCephMON.postprocN)rrrr	)r
)rrr
)�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofilesZ
containers�filesrr rrr<rrrrrs	!r)r1Zsos.report.pluginsrrrrrrrr�<module>	s

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists