
    ~ g                         S SK J r  S SKrS SKrS SKJrJrJrJrJ	r	   " S S\5      r
 " S S\
\5      r " S S	\
\\5      rg)
    )datetimeN)PluginRedHatPluginDebianPluginUbuntuPlugin	PluginOptc                   J    \ rS rSrSrSrSrSrSrSr	\
" SS	S
S9/rS rS rSrg)Sar   a  
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.
zSystem Activity Reportersar)systemperformance)sysstat/var/log/saall-sarFz"gather all system activity records)defaultdescc                    U R                  U R                  U R                  S5      U R                  S5      (       a  SOS SS9   U R	                  U R                  5      n[        R                  " S5      nU H  nUR                  U5      (       d  M  U R                  U R                  U5      nSUS	S  -   nXQ;  aD  U R                  S5      (       d  U R                  U5      (       a  Mr  S
U 3nU R                  Xe5        SU 3nU R                  Xs S35        M     g ! [
         a!    U R                  SU R                   35         g f = f)N*r   r   F)	sizelimittailitzsar: could not list zsa[\d]+r      z
sar -A -f zsadf -x -- -A z.xml)add_copy_spec	path_joinsa_path
get_optionlistdirOSError	_log_warnrecompilematchis_older_than_7daysadd_cmd_output)selfdir_listsa_regexfnamesa_data_pathsar_filenamesar_cmdsadf_cmds           8/usr/lib/python3/dist-packages/sos/report/plugins/sar.pysetup	Sar.setup5   s1   4>>$,,<*.//)*D*DQ$"' 	 	)	||DLL1H ::j) E~~e$$#~~dllEB$uQRy0/??955//==  *<.9G''>+L>:##Htn=   	NN1$,,@A	s   D (E	E	c                     [         R                  " U5      R                  n[        R                  " 5       [        R
                  " U5      -
  nUR                  S::  a  g g! [         a!  nU R                  SU SU 35         SnAgSnAff = f)zIs the file older than 7 days?    FzCould not determine age of 'z'' - skipping converting to sar format: NT)	osstatst_mtimedttodayfromtimestampdays	Exceptionr   )r%   sarfile_ftime_ageerrs        r-   r#   Sar.is_older_than_7daysS   s    	HWWW%..F88: 0 0 88DyyA~  	  	HNN9' CAADG H H 		Hs   AA! !
B+BB N)__name__
__module____qualname____firstlineno____doc__
short_descplugin_nameprofilespackagesr   r   option_listr.   r#   __static_attributes__r?       r-   r
   r
      sB    0 ,JK(HHG)U;	=K
><rK   r
   c                       \ rS rSrSrSrg)	RedHatSara   r   r?   Nr@   rA   rB   rC   r   rJ   r?   rK   r-   rM   rM   a   s    GrK   rM   c                       \ rS rSrSrSrg)	DebianSarf   z/var/log/sysstatr?   NrO   r?   rK   r-   rQ   rQ   f   s     GrK   rQ   )r   r5   r2   r    sos.report.pluginsr   r   r   r   r   r
   rM   rQ   r?   rK   r-   <module>rT      sG    $ 	 	9 9N& Nb\ 
!\< !rK   