a Ö>ïh'ã@s4ddlZddlmZmZmZGdd„deeeƒZdS)éN)ÚPluginÚ RedHatPluginÚ UbuntuPluginc@sHeZdZdZdZdZdZdZdZdZ dd „Z d d „Z d d „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//. 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)ZstorageZvirtÚ containerZceph)zceph-(.*-)?mon.*)z/var/lib/ceph/mon/*z/var/lib/ceph/*/mon*ú%/var/snap/microceph/common/data/mon/*rcCs¦| d¡}| ¡|_|jj d¡}|sr| dddœ¡| gd¢¡|sV| dg¡n | dg¡| d d g¡n:| gd ¢¡|s’| d g¡n | d g¡| ddg¡|j dddd|  gd¢¡|  d¡}|ddkr|d  ¡D]*}|  d¡rî|  ¡d}|  d|›¡qîgd¢}|j dddd|j d dd!d| ¡D](}|j d"|›d#d"|›d$gdd%qJ|  d&d'„|Dƒ¡|j d(d'„|Dƒddd)dS)*NÚall_logsZ microcephZ ceph_confZ 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*rz"/var/snap/microceph/current/conf/*z ceph reportZ ceph_reportF)ÚtagsÚstderr) z!ceph config generate-minimal-confzceph config logúceph config-key dumpú 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 listr ÚstatusrÚoutputÚ*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 ls detailzosd statzpg dumpzpg statr ztime-sync-statusz'ceph health detail --format json-prettyZ json_outputZceph_health_detail)Úsubdirr z"ceph osd tree --format json-prettyZ ceph_osd_treezceph tell mon.z mon_statusz sessions)rcSsg|]}d|›‘qS)úceph ©©Ú.0Úcmdrrú?/usr/lib/python3.9/site-packages/sos/report/plugins/ceph_mon.pyÚ ¸óz!CephMON.setup..cSsg|]}d|›d‘qS)rz --format json-prettyrrrrrr¼r)rr )Z get_optionÚget_ceph_versionÚ ceph_versionZpolicyZpackage_managerZ pkg_by_nameZ add_file_tagsZadd_forbidden_pathZ add_copy_specZadd_cmd_outputZcollect_cmd_outputÚ splitlinesÚendswithÚsplitÚ get_ceph_ids)ÚselfrZ microceph_pkgZcrashesZcrashlnZcidZ ceph_cmdsZmidrrrÚsetup,s|  þ ÿÿþÿÿþ&   þþ   þý  ýz CephMON.setupc Cs~| d¡}|ddkrpz$|d ¡d}t| d¡dƒWStyn}z| d|›¡WYd}~n d}~00| d ¡dS) z% Get the versions of running daemons zceph --versionr rréÚ.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}|jdvr”| d¡}|ddkr’|d ¡D]`}| ¡}|r0|d d¡r0z | d¡}| ||d¡Wq0ttfyŽ|  d ¡Yq00q0nˆ|jd kr| d ¡}|ddkrz,t   d |d¡}|  |  ¡d d ¡¡Wn6ty}z| d|›¡WYd}~n d}~00|S)z! Get the IDs of the Ceph daemons )éézps -u ceph -o argsr rrzceph-monz--idézUnable to find ceph IDséz ceph statusz!(\s*mon: .* quorum) (.*) (\(.*\))ú,zid determination failed: N)rr#rrrÚindexÚappendÚ IndexErrorÚ ValueErrorZ _log_warnÚreÚsearchÚextendÚgroupsr%r&) rZceph_idsÚoutZprocsÚprocZid_indexZstatsÚretr'rrrrÐs.      ÿ&zCephMON.get_ceph_idscCsn|jdkr8gd¢}|D]}d|›d}| d|d¡qn(gd¢}dd  |¡›d }| d|d ¡| d¡dS) Nr+)ÚkeyÚusernameÚpasswordÚ_secretúrbd/mirror/peer/.*z(((.*)(z\\\": ))((\\\"(.*?)\\\")(.*)))r z\2\"******\"\8)Z API_PASSWORDz API_USER.*z API_.*_KEYr8r;r<z((\".*(ú|z)\":) \")(.*)(\".*)z \1*******\5)rZdo_cmd_output_subÚjoinZdo_cmd_private_sub)rÚkeysr8ZcregrrrÚpostprocñs   ÿ ÿzCephMON.postprocN)Ú__name__Ú __module__Ú __qualname__Ú__doc__Z short_descZ plugin_nameZprofilesZ containersÚfilesrr rrr@rrrrrs!r)r1Zsos.report.pluginsrrrrrrrrÚ s