U
    -_g;                     @   sL   d dl mZmZmZmZmZmZ G dd deeeeZG dd deeZdS )    )PluginRedHatPluginDebianPluginUbuntuPlugin	CosPlugin	PluginOptc                   @   sT   e Zd ZdZdZdZdZedddded	dd
deddddgZdd Z	dd Z
dS )Filesysa  Collects general information about the local filesystem(s) and mount
    points as well as optional information about EXT filesystems. Note that
    information specific filesystems such as XFS or ZFS is not collected by
    this plugin, as there are specific plugins for those filesystem types.

    This plugin will collect /etc/fstab as well as mount information within
    /proc/, and is responsible for the 'mount' and 'df' symlinks that appear
    in an sos archive's root.
    zLocal file systemsZfilesys)ZstoragelsofFz%collect information on all open files)defaultZdescdumpe2fszdump filesystem infofragz'collect filesystem fragmentation statusc                 C   s   |  ddddddddd	d
g
 | jdddd | jdddd | dddg | dddddddg | dr| jdddd d}| d rd!}d}d"}| ||D ]<}| jd#| d$| d%d& | d'r| jd(| d)d* qd S )+Nz	/proc/fs/z/proc/mountsz/proc/filesystemsz/proc/self/mountsz/proc/self/mountinfoz/proc/self/mountstatsz/proc/[0-9]*/mountinfoz	/etc/mtab
/etc/fstabz/run/mount/utabzmount -lZmount)root_symlinktagszdf -al -x autofsZdfZdf__alzdf -aliT -x autofsZfindmntZlslocksz/proc/fs/cifsz/proc/fs/ldiskfsz/proc/fs/lustrez/proc/fs/nfsdz/proc/fs/nfsfsz/proc/fs/panfsz/proc/fs/xfsr	   zlsof -b +M -n -l -P2   )r   priorityz-hr    z^(/dev/\S+).+ext[234]\s+z	dumpe2fs  Z
dumpe2fs_h)r   r   ze2freefrag d   )r   )Zadd_copy_specadd_cmd_outputZadd_forbidden_pathZ
get_optionZdo_regex_find_all)selfZdumpe2fs_optsZmountsZext_fs_regexZdev r   </usr/lib/python3/dist-packages/sos/report/plugins/filesys.pysetup%   s^    


zFilesys.setupc                 C   s$   |  ddd d}| d|d d S )Nr   z(password=)[^,\s]*z
\1********z](lsof: (avoiding (.*?)|WARNING: can't stat\(\) (.*?))|Output information may be incomplete.)
r	   r   )Zdo_file_subZdo_cmd_output_sub)r   Zregexr   r   r   postproc\   s    zFilesys.postprocN)__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesr   Zoption_listr   r   r   r   r   r   r      s   
7r   c                       s   e Zd Z fddZ  ZS )RedHatFilesysc                    s   t    | d d S )Nzls -ldZ /tmp)superr   r   )r   	__class__r   r   r   m   s    
zRedHatFilesys.setup)r   r   r   r   __classcell__r   r   r!   r   r   k   s   r   N)	Zsos.report.pluginsr   r   r   r   r   r   r   r   r   r   r   r   <module>	   s    ^