3
'j @ s: d dl Z d dlZd dlmZmZmZ G dd deeZdS ) N)PluginIndependentPlugin PluginOptc @ sD e Zd ZdZdZdZdZdZedd d
dedd
ddgZ dd Z
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 filesZcoredumpsystemdebugsystemd-udevsystemd-coredumpdumps znumber of dump files to collect)defaultZdesc
executable zEonly collect info and dump output for executables matching this regexc C s | j dddddg | jd}|d dkr.d S d}x|d j d
d D ]}|j }|d }|d }| jd
rtj| jd
|tjsqJ| jd| }|d dkrqJ|d }|| jdk rJtjd|tj} y| j d
j
}
tj|
j
dkr| jd|
d wJ| j |
ddd | j| jd | j d| d| j| }tjj| jj |
}tjj||}
|
jddd
}
| jj|
| |d
7 }W qJ tk
r Y qJ tk
r } z| jd| d| W Y d d }~X qJX qJW d S )Nz/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 --reverseZstatusr output r
zcoredumpctl info r
z(^\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_collectedlineZcdumppidZexeZcinforesZcoreZ core_pathZplugpathZarcpathZlinkpatherr r. /usr/lib/python3.6/coredump.pysetup9 sZ
zCoredump.setupN)r r )r r )__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesZpackagesr Zoption_listr0 r. r. r. r/ r s
r )r r Zsos.report.pluginsr r r r r. r. r. r/