Sindbad~EG File Manager

Current Path : /lib/python3.6/site-packages/sos/report/plugins/__pycache__/
Upload File :
Current File : //lib/python3.6/site-packages/sos/report/plugins/__pycache__/sar.cpython-36.opt-1.pyc

3

�f��@srddlmZddlZddlZddlmZmZmZmZm	Z	Gdd�de�Z
Gdd�de
e�ZGdd	�d	e
ee�ZdS)
�)�datetimeN)�Plugin�RedHatPlugin�DebianPlugin�UbuntuPlugin�	PluginOptc@sDeZdZdZdZdZdZdZdZe	dd	d
d�gZ
dd
�Zdd�ZdS)�SaraN
    The sar plugin is designed to collect system performance data as recorded
    by sysstat.

    The raw binary data, i.e. the 'saX' files, will be collected and for files
    a week old or younger, this plugin will capture human-readable conversions
    of those files provided by the 'sar' command locally available, if the
    local sysstat installation has not already created a converted copy (e.g.
    for the current day-of data being collected at the time of report
    generation).

    Using the 'all_sar' plugin option will not only cause the plugin to capture
    _all_ 'saX' files present on the host, but further perform the 'sar'
    conversion on all files, not just those produced within the last week.

    Converted 'sar' files will be written to the sos_commands/sar/, and not
    to the /var/log/ path that sysstat writes to.

    Note that this conversion is done because it is unlikely that the same
    version of sysstat that produces the 'saX' files will be the same version
    available on a given analyst's workstation, and this conversion is version
    sensitive.
    zSystem Activity Reporter�sar�system�performance�sysstatz/var/log/sa�all_sarFz"gather all system activity records)�defaultZdescc
Cs�|j|j|jd�|jd�rdnddd�y|j|j�}Wn$tk
r\|jd|j�dSXtjd�}x�|D]x}|j	|�rn|j|j|�}d|d	d�}||kr�|jd�r�|j
|�r�qnd
|}|j||�d|}|j|d|�qnWdS)
N�*r
rF)Z	sizelimitZtailitzsar: could not list %szsa[\d]+r	�zsar -A -f %szsadf -x -- -A %sz%s.xml)Z
add_copy_specZ	path_join�sa_pathZ
get_option�listdir�OSError�	_log_warn�re�compile�match�is_older_than_7daysZadd_cmd_output)�selfZdir_listZsa_regexZfnameZsa_data_pathZsar_filenameZsar_cmdZsadf_cmd�r�/usr/lib/python3.6/sar.py�setup5s*



z	Sar.setupcCsjy0tj|�j}tj�tj|�}|jdkr.dSWn4tk
rd}z|jd||f�WYdd}~XnXdS)z  Is the file older than 7 days? �FzGCould not determine age of '%s' - skipping converting to sar format: %sNT)	�os�stat�st_mtime�dtZtodayZ
fromtimestampZdays�	Exceptionr)rZsarfileZ_ftimeZ_age�errrrrrSs
zSar.is_older_than_7daysN)r
r)r)
�__name__�
__module__�__qualname__�__doc__Z
short_descZplugin_nameZprofilesZpackagesrrZoption_listrrrrrrrs
rc@seZdZdZdS)�	RedHatSarz/var/log/saN)r$r%r&rrrrrr(asr(c@seZdZdZdS)�	DebianSarz/var/log/sysstatN)r$r%r&rrrrrr)fsr))
rr!rrZsos.report.pluginsrrrrrrr(r)rrrr�<module>	sQ

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists