3 ܓi'@s4ddlZddlmZmZmZGdddeeeZdS)N)Plugin RedHatPlugin UbuntuPluginc@sHeZdZdZdZdZdZdZdZd Z d dZ ddZ ddZ ddZ 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//. 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_monstoragevirt containercephceph-(.*-)?mon.*/var/lib/ceph/mon/*/var/lib/ceph/*/mon*%/var/snap/microceph/common/data/mon/*rc!Cs$|jd}|j|_|jjjd}|sv|jddd|jdddd g|sZ|jd gn |jd g|jd d gn>|jddddg|s|jdgn |jdg|jddg|j dddd|j ddddddd d!d"d#d$d%d&d'd(d)d*d+d,d-d.d/d0d1d2d3d4d5d6d7d8d9g |j d}|d:d;krfx>|d<j D].}|j d=r4|j d;}|j d>|q4Wd?d@dAdBdCdDdEdFdGdHdIdJdKdLdMdNdOdPdQdRdSdTdUd:dVg}|j dWdXdYdZ|j d[dXd\dZx4|jD](}|j d]|d^d]|d_gdXd`qW|j dadb|D|j dcdb|DdXddddS)eNall_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/*z ceph reportZ ceph_reportF)tagsstderrz!ceph config generate-minimal-confzceph config logzceph config-key dumpz ceph crash lszceph 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 mon features lsz ceph node lszceph osd crush class lszceph osd crush dumpzceph osd crush rule lszceph osd crush show-tunablesz!ceph osd crush tree --show-shadowz ceph osd erasure-code-profile lszceph osd metadatazceph osd utilizationzceph telemetry channel lszceph telemetry collection lszceph telemetry lszceph quorum_statusz ceph versionszceph-disk liststatusroutput*zceph crash info z config dumpz device lsz df detailZdfzfs dumpzfs lsz fs statuszmds statzmon dumpzosd blocked-byzosd blocklist lsz osd df treezosd dfzosd dumpzosd numa-statuszosd perfzosd pool autoscale-statuszosd pool availability-statuszosd pool ls detailzosd statzpg dumpz pg dump_stuckzpg statztime-sync-statusz'ceph health detail --format json-prettyZ json_outputZceph_health_detail)subdirrz"ceph osd tree --format json-prettyZ ceph_osd_treezceph tell mon.z mon_statusz sessions)rcSsg|]}d|qS)zceph ).0cmdrr/usr/lib/python3.6/ceph_mon.py sz!CephMON.setup..cSsg|]}d|dqS)zceph z --format json-prettyr)rrrrrrs)rr)Z get_optionget_ceph_version ceph_versionZpolicyZpackage_managerZ pkg_by_nameZ add_file_tagsZadd_forbidden_pathZ add_copy_specZadd_cmd_outputZcollect_cmd_output splitlinesendswithsplit get_ceph_ids)selfrZ microceph_pkgZcrashesZcrashlnZcidZ ceph_cmdsZmidrrrsetup,s            z CephMON.setupcCsz|jd}|ddkrly"|djd}t|jddStk 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_cmdrint Exception _log_debugZ _log_error)r ZverZ_vererrrrrrs  "zCephMON.get_ceph_versionc Cs$g}|jdkr|jd}|ddkrx|djD]b}|j}|r2|djdr2y |jd}|j||d Wq2ttfk r|j d Yq2Xq2Wn|jd kr |jd }|ddkr y,t j d |d}|j |j d jdWn4tk r}z|jd|WYdd}~XnX|S)z! Get the IDs of the Ceph daemons zps -u ceph -o argsrrrzceph-monz--idzUnable to find ceph IDsz ceph statusz!(\s*mon: .* quorum) (.*) (\(.*\)),zid determination failed: N)r)r*)rr$rrrindexappend IndexError ValueErrorZ _log_warnresearchextendgroupsr&r') r Zceph_idsoutZprocsprocZid_indexZstatsretr(rrrrs,       "zCephMON.get_ceph_idscCs|jdkrBdddddg}xX|D]}d|d}|jd |d qWn0d d 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_subjoinZdo_cmd_private_sub)r keysr9Zcregrrrpostprocs(    zCephMON.postprocN)rrrr )r )r r r )__name__ __module__ __qualname____doc__Z short_descZ plugin_nameZprofilesZ containersfilesrr!rrr=rrrrrs!r)r2Zsos.report.pluginsrrrrrrrr s