File: //lib/python3.6/site-packages/sos/report/plugins/__pycache__/logs.cpython-36.pyc
3
��'j� � @ sh d dl Z d dlZd dlZd dlmZmZmZmZ G dd� de�ZG dd� dee�Z G dd� dee�Z
dS ) � N)�Plugin� PluginOpt�IndependentPlugin� CosPluginc @ s( e Zd ZdZdZdZdd� Zdd � Zd
S )�LogsBasezSystem logs�logs�system�hardware�storagec sJ d}d|g}g }� j |��rt� j|�ddd���}|j� }x�tjd|tjtjB d�D ]�}yP|d }|jd �r�t j
|j� d
jd��}|r�|t
j
|�7 }n|t
j
|�7 }W qT tk
r� } z� jd| � �� W Y d d } ~ X qTX qTW x0|j� D ]$}
|
jd
�r�|t
j
|
j� d
�7 }q�W W d Q R X x>|D ]6}� j � j|���s<�q"� j|�}|� jd|�7 }�q"W x<|D ]4}|jd��r~|d
d � }� j|��rb� j|� �qbW � jddddddddddddg� � jd� � jdddd� t� fdd �d0D ��}
|
�rF� jd#��rF� jd$d%gd&d'� � jd(d)d*� � jd+d,d*� � jd-��rF� jd.d/g� d S )1Nz/etc/rsyslog.confz/etc/syslog.conf�rzUTF-8)�encodingz-(include\((\s*)?file=([\"'`]([^'\"]*)[\"'`])))�pattern�string�flags� zecho � z $`zError parsing include(): z$IncludeConfigz^\S+\s+(-?\/.*$)\s+�-z/var/log/auth.log*z/var/log/boot.logz/var/log/dist-upgradez/var/log/installerz/var/log/kern.log*z/var/log/messages*z/var/log/secure*z/var/log/syslog*z
/var/log/udevz/etc/rsyslog.dzjournalctl --disk-usagez/var/logT�s)� recursiveZ
extra_optsc 3 s | ]}� j � j|d ��V qdS )zlog/journal/N)�path_exists� path_join)�.0�p)�self� �/usr/lib/python3.6/logs.py� <genexpr>V s z!LogsBase.setup.<locals>.<genexpr>�/var�/runzsystemd-journaldZjournal_fullZjournal_all�d )�tagsZpriority�thisZjournal_since_boot)Zbootr ZlastZjournal_last_boot�all_logsz/var/log/journal/*z/run/log/journal/*)r r )r �openr �read�re�findall�I�M�
startswith�os�getenv�split�strip�glob� ExceptionZ
_log_debug�
splitlinesZdo_regex_find_allZpath_isfileZ
add_copy_spec�add_cmd_outputZadd_dir_listing�anyZ
is_service�add_journal�
get_option)r ZrsyslogZconfsr ZconfZcontent�matchZ_entZenvc�err�line�config�iZjournalr )r r �setup st
&
$
zLogsBase.setupc C s | j ddd� d S )Nz
/etc/rsyslog*z (ActionLibdbiPassword |pwd=)(.*)z\1[********])Zdo_path_regex_sub)r r r r �postprocc s zLogsBase.postprocN)r r r
)�__name__�
__module__�__qualname__Z
short_desc�plugin_name�profilesr: r; r r r r r s
Mr c @ s e Zd ZdZdZdZdS )�IndependentLogsa�
This plugin will collect logs traditionally considered to be "system" logs,
meaning those such as /var/log/messages, rsyslog, and journals that are
not limited to unit-specific entries.
Note that the --since option will apply to journal collections by this
plugin as well as the typical application to log files. Most users can
expect typical journal collections to include the "full" journal, as well
as journals limited to this boot and the previous boot.
r r r r
N)r r r
)r<