o
    O6ufå  ã                   @   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 osdÚceph_osd)ÚstorageÚvirtÚ	containerÚ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¡}g d¢‰ |s<d}|  ddi¡ |  g d¢¡ |  g d	¢¡ |  d
dg¡ |r;|  ddg¡ nd}|  g d¢¡ |  ddg¡ |rT|  dg¡ |  ‡ fdd„|  |¡D ƒ¡ d S )NÚall_logsÚ Ú	microceph)zbluestore bluefs availableÚdump_reservationszbluefs statszbluestore bluefs device infozconfig diffzconfig showzcounter dumpzcounter schemaÚdump_blocked_opsÚdump_blocklistÚdump_historic_ops_by_durationÚdump_historic_slow_opsÚdump_mempoolsÚdump_op_pq_stateÚdump_ops_in_flightÚdump_osd_networkÚdump_pgstate_historyÚdump_recovery_reservationsÚdump_scrubsÚdump_watchersÚget_mapped_poolsÚlist_devicesÚlist_unfoundzlog dumpÚobjecter_requestsÚopsz	perf dumpzperf histogram dumpzperf schemaÚstatusÚversionz/var/run/cephz(/var/log/ceph/(.*/)?ceph-(.*-)?osd.*.logÚceph_osd_log)z/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/run)z'/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©Úcmdsr%   ú=/usr/lib/python3/dist-packages/sos/report/plugins/ceph_osd.pyÚ
<listcomp>…   s    þÿÿz!CephOSD.setup.<locals>.<listcomp>)	Ú
get_optionÚpolicyÚpackage_managerÚpkg_by_nameÚadd_file_tagsÚadd_forbidden_pathÚadd_copy_specÚadd_cmd_outputÚ	get_socks)Úselfr   Ú	directoryÚmicroceph_pkgr%   r)   r+   Úsetup'   sD   
$ÿ
þþ€þÿþzCephOSD.setupc                 C   sL   g }t  |¡D ]\}}}|D ]}| d¡r"d|v 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.asokÚosd)ÚosÚwalkÚendswithÚappendÚ	path_join)r6   r7   Úceph_socketsÚrdirÚ_ÚfilesÚfiler%   r%   r+   r5   Š   s   €þzCephOSD.get_socksN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__Ú
short_descÚplugin_nameÚprofilesÚ
containersrC   r9   r5   r%   r%   r%   r+   r      s    cr   )r;   Úsos.report.pluginsr   r   r   r   r%   r%   r%   r+   Ú<module>   s   
