
    ([Qh                     @    d dl Z d dlZd dlmZmZmZ  G d dee      Zy)    N)PluginIndependentPlugin	PluginOptc                   R    e Zd ZdZdZdZdZdZ eddd	       ed
dd	      gZ	d Z
y)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 filescoredump)systemdebug)zsystemd-udevzsystemd-coredumpdumps   znumber of dump files to collect)defaultdesc
executable zEonly collect info and dump output for executables matching this regexc                    | j                  g d       | j                  d      }|d   dk7  ry d}|d   j                         dd  D ]  }|j                         }|d   }|d   }| j	                  d	      x}r&t        j                  ||t
        j                        sW| j                  d
|       }|d   dk7  rt|d   }	|| j	                  d      k  st        j                  d|	t
        j                        }
	 |
j                         d   j                         }t        j                  |      j                  dkD  r| j                  d| d       | j                  |dd       | j                  | j                   d   | j#                         d| d| j%                  |             }t        j&                  j)                  | j*                  j-                         |      }t        j&                  j/                  ||      }|j1                  ddd      }| j*                  j3                  ||       |dz  } y # t4        $ r Y t6        $ r"}| j                  d| d|        Y d }~&d }~ww xY w)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-coredumpzcoredumpctl list --reversestatusr   output      r   zcoredumpctl info r   z(^\s*Storage:(.*)(\(present\)))i  zSkipping core dump file z due to sizeF   )tailit	sizelimitcmddir	coredump__z../r   zCould not collect coredump for z : )add_copy_speccollect_cmd_output
splitlinessplit
get_optionresearchIMgroupsstriposstatst_size	_log_info	path_joincommonsname_mangle_commandpathjoinarchiveget_archive_pathrelpathreplaceadd_linkAttributeError	Exception)selfcoredump_listcores_collectedlinecdumppidexeregexcinforescore	core_pathplugpatharcpathlinkpatherrs                   =/usr/lib/python3/dist-packages/sos/report/plugins/coredump.pysetupzCoredump.setup9   sU    
 	 //0LM"a'!(+668< -	DJJLE(C)C55u5yyRTT2++.?u,EFEX!#/C!99yy!CS"$$O  $a 0 6 6 8I wwy)11I=6ykN !&&y#&N#~~X.		#C5$*>*>s*C)DE H !ggll4<<+H+H+J+46G!wwwAH'//r1=HLL))(H=#q(OM-	N &   NN9#c#G s&   :AH;C#H;;	I1I1I,,I1N)__name__
__module____qualname____doc__
short_descplugin_nameprofilespackagesr   option_listrJ        rI   r   r      sJ    6 GJK"H3H 	'1+LM,.	0K;rU   r   )r(   r"   sos.report.pluginsr   r   r   r   rT   rU   rI   <module>rW      s$    
 	 C Cdv( drU   