a >h@s:ddlZddlZddlmZmZmZGdddeeZdS)N)PluginIndependentPlugin PluginOptc@sDeZdZdZdZdZdZdZedddd ed d d d gZ d dZ dS)Coredumpaa This plugin collects from the systemd-coredump service, which is leveraged via the coredumpctl command. Beyond basic configuration of the service, the plugin will also attempt to collect information on available coredumps. For any coredumps reported by coredumpctl for which the core is present, this plugin will collect that coredump file. The number of dump files collects is controlled by the `dumps` option, defaulting to 3. Note that core collection is performed based on the most recent cores generated. The summary information provided by `coredumpctl info` is also collected. The coredump files will be at their canonical location in the sos archive, usually under var/lib/systemd/coredump. Symlinks are dropped in the plugin directory to assist in identifying which coredump aligns to which entry in the provided `coredumpctl list` output collection. Users may leverage the `executable` option to control which coredumps the plugin will collect. This option takes a case-insensitive python regex string. If provided, only coredump entries for which the EXE field in `coredumpctl list` output matches will be collected. The dump files collected are compressed, and users should be aware that when inflated these files can be orders of magnitude larger than their collected sizes. z3systemd-coredump related information and dump filesZcoredump)systemdebug)z systemd-udevzsystemd-coredumpdumpsznumber of dump files to collect)defaultZdesc executablezEonly collect info and dump output for executables matching this regexc Cs|gd|d}|ddkr(dSd}|dddD]}|}|d}|d}|d }r~t||tjs~q@|d |}|ddkrq@|d} ||d kr@td | tj} z| d } t | j d kr|d| dWq@|j| ddd||jd|d|d||} t j|j| } t j| | }|ddd}|j|| |d7}Wq@tyYq@ty}z"|d|d|WYd}~q@d}~00q@dS)N)z/etc/systemd/coredump.confz/etc/systemd/coredump.conf.d/z/run/systemd/coredump.conf.d/z!/usr/lib/systemd/coredump.conf.d/z!/usr/lib/systemd/systemd-coredumpzcoredumpctl list --reversestatusroutputr zcoredumpctl info rz(^\s*Storage:(.*)(\(present\)))i zSkipping core dump file z due to sizeF)ZtailitZ sizelimitZcmddirZ coredump__z../r zCould not collect coredump for z : )Z add_copy_specZcollect_cmd_output splitlinessplitZ get_optionresearchIMgroupsstriposstatst_sizeZ _log_infoZ path_joinZcommonsnameZ_mangle_commandpathjoinarchiveZget_archive_pathrelpathreplaceZadd_linkAttributeError Exception)selfZ coredump_listZcores_collectedlineZcdumppidZexeZregexZcinforesZcoreZ core_pathZplugpathZarcpathZlinkpatherrr,?/usr/lib/python3.9/site-packages/sos/report/plugins/coredump.pysetup9sX     zCoredump.setupN) __name__ __module__ __qualname____doc__Z short_descZ plugin_nameZprofilesZpackagesrZ option_listr.r,r,r,r-rs r)rrZsos.report.pluginsrrrrr,r,r,r- s