관리-도구
편집 파일: coredump.cpython-39.pyc
a -�_g� � @ s: d dl Z d dlZd dlmZmZmZ G dd� dee�ZdS )� N)�Plugin�IndependentPlugin� PluginOptc @ sD e Zd ZdZdZdZdZdZedddd �ed ddd �gZ d d� 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 filesZcoredump)�system�debug)zsystemd-udevzsystemd-coredump�dumps� znumber of dump files to collect)�defaultZdesc� executable� zEonly collect info and dump output for executables matching this regexc C s� | � g d�� | �d�}|d dkr(d S d}|d �� dd � D �]�}|�� }|d }|d }| �d � }r~t�||tj�s~q@| �d |� ��}|d dkr�q@|d } || �d�k r@t�d| tj�} z�| � � d � � }t�|�j d kr�| �d|� d�� W q@| j |ddd� | �| jd | �� d|� d| �|�� ��}tj�| j�� |�} tj�| |�}|�ddd�}| j�||� |d7 }W q@ t�y� Y q@ t�y� } z"| �d|� d|� �� W Y d }~q@d }~0 0 q@d S )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 --reverse�statusr �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� splitlines�splitZ get_option�re�search�I�M�groups�strip�os�stat�st_sizeZ _log_infoZ path_joinZcommons�nameZ_mangle_command�path�join�archiveZget_archive_path�relpath�replaceZadd_link�AttributeError� Exception)�selfZ coredump_listZcores_collected�lineZcdump�pidZexeZregexZcinfo�resZcoreZ core_pathZplugpathZarcpathZlinkpath�err� r, �?/usr/lib/python3.9/site-packages/sos/report/plugins/coredump.py�setup9 sX ����zCoredump.setupN)�__name__� __module__�__qualname__�__doc__Z short_descZplugin_nameZprofilesZpackagesr Zoption_listr. r, r, r, r- r s ��r )r r Zsos.report.pluginsr r r r r, r, r, r- �<module> s