3
ܓi @ sr d dl m Z d dlZd dlZd dlmZmZmZmZm Z G dd deZ
G dd de
eZG dd d e
eeZdS )
)datetimeN)PluginRedHatPluginDebianPluginUbuntuPlugin PluginOptc @ sD e Zd ZdZdZdZdZdZdZe dd d
dgZ
dd
Zdd ZdS )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 Reportersarsystemperformancesysstatz/var/log/sazall-sarFz"gather all system activity records)defaultZdescc
C s | j | j| jd| jdrdnd dd y| j| j}W n& tk
r^ | jd| j d S X tjd}x|D ]~}|j |rp| j| j|}d|d d }||kr| jd r| j
|rqpd
| }| j|| d| }| j|| d qpW d S )
N*zall-sarr F)Z sizelimitZtailitzsar: could not list zsa[\d]+r z
sar -A -f zsadf -x -- -A z.xml)Z
add_copy_specZ path_joinsa_pathZ
get_optionlistdirOSError _log_warnrecompilematchis_older_than_7daysZadd_cmd_output)selfZdir_listZsa_regexZfnameZsa_data_pathZsar_filenameZsar_cmdZsadf_cmd r /usr/lib/python3.6/sar.pysetup5 s*
z Sar.setupc C sn y0t j|j}tj tj| }|jdkr.dS W n8 tk
rh } z| jd| d| W Y dd}~X nX dS )z Is the file older than 7 days? FzCould not determine age of 'z'' - skipping converting to sar format: NT) osstatst_mtimedtZtodayZ
fromtimestampZdays Exceptionr )r ZsarfileZ_ftimeZ_ageerrr r r r S s
(zSar.is_older_than_7daysN)r
r )r )
__name__
__module____qualname____doc__Z
short_descZplugin_nameZprofilesZpackagesr r Zoption_listr r r r r r r s
r c @ s e Zd ZdZdS ) RedHatSarz/var/log/saN)r# r$ r% r r r r r r' a s r' c @ s e Zd ZdZdS ) DebianSarz/var/log/sysstatN)r# r$ r% r r r r r r( f s r( )
r r r r Zsos.report.pluginsr r r r r r r' r( r r r r