U
    -Ø_g  ã                   @   s4   d dl Z d dlmZmZmZ G dd„ deeeƒZdS )é    N)ÚPluginÚRedHatPluginÚUbuntuPluginc                   @   s4   e Zd ZdZdZdZdZdZdZdd„ Z	d	d
„ Z
dS )ÚCephOSDaâ  
    This plugin is for capturing information from Ceph OSD 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 majorly `ceph daemon` commands that will
    reference discovered admin sockets under /var/run/ceph.
    zCEPH osdZceph_osd)ZstorageZvirtZ	containerZceph)zceph-(.*-)?osd.*)z/var/lib/ceph/osd/*z/var/lib/ceph/*/osd*ú%/var/snap/microceph/common/data/osd/*c                     s  |   d¡}d}| jj d¡}dddddd	d
dddddddddddddddddddddd d!d"d#g ‰ |s¼d$}|  d%d&i¡ |  d'd(d)d*g¡ |  d+d,d-d.g¡ |  d/d0g¡ |rî|  d1d2g¡ n2d3}|  d4d5d6g¡ |  d7d8g¡ |rî|  d9g¡ |  ‡ fd:d;„|  |¡D ƒ¡ d S )<NÚall_logsÚ Z	microcephzbluestore bluefs availableZdump_reservationszbluefs statszbluestore allocator dump blockzbluestore bluefs device infozconfig diffzconfig showzcounter dumpzcounter schemaZdump_blocked_opsZdump_blocklistZdump_historic_ops_by_durationZdump_historic_slow_opsZdump_mempoolsZdump_op_pq_stateZdump_ops_in_flightZdump_osd_networkZdump_pgstate_historyZdump_recovery_reservationsZdump_scrubsZdump_watchersZget_mapped_poolsZlist_devicesZlist_unfoundzlog dumpZobjecter_requestsZopsz	perf dumpzperf histogram dumpzperf schemaZstatusÚversionz/var/run/cephz(/var/log/ceph/(.*/)?ceph-(.*-)?osd.*.logZceph_osd_logz/etc/ceph/*keyring*z/var/lib/ceph/**/*keyring*z/var/lib/ceph/**/tmp/*mnt*z/etc/ceph/*bindpass*z/run/ceph/**/ceph-osd*z/var/lib/ceph/**/kv_backendz/var/log/ceph/**/ceph-osd*.logz!/var/log/ceph/**/ceph-volume*.logzceph-disk listzceph-volume lvm listz/var/log/ceph/**/ceph-osd*.log*z"/var/log/ceph/**/ceph-volume*.log*z/var/snap/microceph/current/runz'/var/snap/microceph/common/**/*keyring*z(/var/snap/microceph/current/**/*keyring*z"/var/snap/microceph/common/state/*r   z./var/snap/microceph/common/logs/*ceph-osd*.logz//var/snap/microceph/common/logs/*ceph-osd*.log*c                    s&   g | ]}ˆ D ]}d |› d|› ‘qqS )zceph daemon ú © )Ú.0ÚiÚc©Zcmdsr   ú=/usr/lib/python3/dist-packages/sos/report/plugins/ceph_osd.pyÚ
<listcomp>†   s    ÿz!CephOSD.setup.<locals>.<listcomp>)	Z
get_optionZpolicyZpackage_managerZpkg_by_nameZadd_file_tagsZadd_forbidden_pathZadd_copy_specZadd_cmd_outputÚ	get_socks)Úselfr   Ú	directoryZmicroceph_pkgr   r   r   Úsetup'   s     
Þ% ÿú
üþþýþÿþzCephOSD.setupc                 C   sL   g }t  |¡D ]8\}}}|D ](}| d¡rd|kr| |  ||¡¡ qq|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.asokZosd)ÚosÚwalkÚendswithÚappendZ	path_join)r   r   Zceph_socketsZrdirÚ_ÚfilesÚfiler   r   r   r   ‹   s    zCephOSD.get_socksN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Z
short_descZplugin_nameZprofilesZ
containersr   r   r   r   r   r   r   r      s   dr   )r   Zsos.report.pluginsr   r   r   r   r   r   r   r   Ú<module>   s   