Viewing File: /usr/lib/python2.7/site-packages/sos/plugins/__init__.pyo


Kjc@sedZddlmZddlmZmZmZmZmZm	Z	ddl
Z
ddlZddlZddl
Z
ddlmZddlZddlZddlZddlZddlmZmZddlmZyeWnek
reZnXdZd	Zd
ZdZdZd
Zej dej!Z"dZ#de$fdYZ%de$fdYZ&de$fdYZ'de$fdYZ(de(fdYZ)de(fdYZ*de(fdYZ+de$fdYZ,d e$fd!YZ-d"e$fd#YZ.d$e$fd%YZ/d&e$fd'YZ0e1d(Z2dS()s; This exports methods available for use by plugins for sos i(twith_statement(tsos_get_command_outputt
import_moduletgreptfileobjttailt
is_executableN(ttime(tziptfilter(tdatetimecCsDt|tjs@|jdr.|d7}ntj|}n|S(Ns\t (t
isinstancetsixt	text_typetendswithtu(ts((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_to_u&s

cCsNy5t|#}tj||jtjSWdQXWntk
rIgSXdS(s=Return a list of all non overlapping matches in the string(s)N(Rtretfindalltreadt	MULTILINEtAttributeError(tregextfnametf((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
regex_findall1s
&
cCsYtjdd|}tjdd|}tjdd|jd}|d|!}|S(	Ns^/(usr/|)(bin|sbin)/ts[^\w\-\.\/]+t_t/t.s ._-i(Rtsubtstrip(tcommandtname_maxtmangledname((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_mangle_command:s

cstfd|DS(Nc3s|]}|kVqdS(N((t.0tp(tpath(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>Cs(tany(R(t	path_list((R(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_path_in_path_listBscCsftjdftjdftjdftjdfg}x)|D]!}|d|jr=|dSq=WdS(s return a string indicating the type of special node represented by
    the stat buffer st (block, character, fifo, socket).
    sblock devicescharacter devices
named pipetsocketiiN(tstattS_ISBLKtS_ISCHRtS_ISFIFOtS_ISSOCKtst_mode(tstt_typestt((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_node_typeFs
cCs
|jdS(sCheck if a file appears to be compressed

    Return True if the file specified by path appears to be compressed,
    or False otherwise by testing the file name extension against a
    list of known file compression extentions.
    s.gzs.xzs.bzs.bz2(s.gzs.xzs.bzs.bz2(R(R(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_file_is_compressedUss-*BEGIN.*?-*ENDs
-----SCRUBBEDtSoSPredicatecBseZdZdZeZgZgZgZ	gZ
gZedddZdZ
dZdZdZdZdZd	Zd
ZdZdZd
ZdZdZdZdZegggggidZRS(sA class to implement collection predicates.

        A predicate gates the collection of data by an sos plugin. For any
        `add_cmd_output()`, `add_copy_spec()` or `add_journal()` call, the
        passed predicate will be evaulated and collection will proceed if
        the result is `True`, and not otherwise.

        Predicates may be used to control conditional data collection
        without the need for explicit conditional blocks in plugins.
    Rc	Csd}d|j}|j}|r?g|D]}||^q)n|}|ddj|7}|j}|rg|D]}	||	^qrn|}|ddj|7}|j}
|rg|
D]}||^qn|
}
|ddj|
7}g|jD]4}d|d||d|d	||d	f^q}
|d
dj|
7}|j}|rug|D]}||^q_n|}|ddj|7}|||S(sxReturn a string representation of this SoSPredicate with
            optional prefix, suffix and value quoting.
        s"%s"sdry_run=%s, skmods=[%s], t,sservices=[%s], spackages=[%s], s{ %s: %s, %s: %s }tcmdtoutputscmdoutputs=[%s], sarches=[%s](tdry_runtkmodstjointservicestpackagestcmd_outputstarch(tselftquotetprefixtsuffixtquotestpstrR=tkR?RtpkgsR't	cmdoutputt
cmdoutputstarchesta((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__strs$
	)	)	)A	)cCs
|jS(sReturn a string representation of this SoSPredicate.

            "dry_run=False, kmods=[], services=[], cmdoutputs=[]"
        (t_SoSPredicate__str(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__str__scCs|jdtddddS(sReturn a machine readable string representation of this
            SoSPredicate.

            "SoSPredicate(dry_run=False, kmods=[], services=[], cmdoutputs=[])"
        RDREs
SoSPredicate(RFt)(RPtTrue(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__repr__scCsG|dkrt|S|dkr,t|S|dkrCt|SdS(sHelper to simplify checking the state of the predicate's evaluations
        against the setting of the required state of that evaluation
        R)talltnoneN(R)RU(RCtitemstrequired((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_check_required_states

cCsH|j|}|dkr0|j|j|n|j|j|dS(sHelper to direct failed predicates to provide the proper messaging
        based on the required check type

            :param test:      The type of check we're doing, e.g. kmods, arch
            :param item:      The string of what failed
        RVN(RXt_failedtappendt
_forbidden(RCttesttitemt_req((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_failed_or_forbiddens
cCs|js|jjdr tSg}xI|jD]>}|jj|}|j||s0|jd|q0q0W|j||jdS(Ntallow_system_changesR=(	R=t_ownert
get_optionRStis_module_loadedR[R`RYRX(RCt_kmodstkmodtres((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_kmodss
cCsv|js
tSg}xI|jD]>}|jj|}|j||s|jd|qqW|j||jdS(NR?(R?RSRbtis_service_runningR[R`RYRX(RCt_svcstsvcRg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_servicess	
cCsv|js
tSg}xI|jD]>}|jj|}|j||s|jd|qqW|j||jdS(NR@(R@RSRbtis_installedR[R`RYRX(RCt_pkgstpkgRg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_packagess	
cCssd|ksd|krtSt|d}|ddkr@tSx,|djD]}|d|krQtSqQWtS(s*Does 'cmd' output contain string 'output'?R:R;tstatusi(tFalseRt
splitlinesRS(RCt
cmd_outputtresulttline((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_cmd_outputscCs|js
tSg}xX|jD]M}|j|}|j||s|jdd|d|dfqqW|j||jdS(NRAs%s: %sR:R;(RARSRwR[R`RYRX(RCt_cmdsR:Rg((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_eval_cmd_outputss	
 cCs|js
tS|jjj}ddj|j}|jddkrvtj||rr|j	dj
|tStStj||rtS|jdj
|tS(Ns(?:%s)t|RBRVtarchitecture(
RBRSRbtpolicytget_archR>RXRtmatchR\R[RrRZ(RCt_archR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_eval_archs	cCsod}d}x\|jjD]K\}}|s4qnt|}|||djd|Df7}qW|S(s\Return a string informing user what caused the predicate to fail
        evaluation
        Rsrequired %s missing: %s.s, css|]}|VqdS(N((R&tv((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>,s(RZRWtsetR>(RCtmsgt_substrtkeytval((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_report_failed"s+cCsod}d}x\|jjD]K\}}|s4qnt|}|||djd|Df7}qW|S(sxReturn a string informing the user that a forbidden condition exists
        which caused the predicate to fail
        Rsforbidden %s '%s' found.s, css|]}|VqdS(N((R&R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>9s(R\RWRR>(RCRRRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_report_forbidden/s+cCs+|j|jg}dj|jS(s}Used by `Plugin()` to obtain the error string based on if the reason
        was a failed check or a forbidden check
        R(RRR>tlstrip(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytreport_failure<scCsxt|j|j|j|j|j|jgs4tS|jow|j	ow|j
ow|jow|jow|jS(s#Predicate evaluation hook.
        (
R)R=R?R@RARBR<RSRhRlRpRyR(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__nonzero__CscCs
|jS(N(R(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__bool__Qsc		s4|_t|_t|_t|_t|_t|ts`|g}n|_|jjdj	B_	idd6dd6dd6dd6dd6_
j
jfdjDigd6gd6gd6gd6gd	6_
igd6gd6gd6gd6gd	6_d
S(s.Initialise a new SoSPredicate object.
        tcmdlineoptsR)R=R?R@RARBcs6i|],\}}|j|kr||qS((RX(R&RIR(RXRC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys
<dictcomp>fs		R{N(RbtlistR=R?R@RBRRAtcommonsR<RXtupdateRWRZR\(	RCtownerR<R=R?R@RARBRX((RXRCs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt__init__Vs&			 
N(t__name__t
__module__t__doc__tNoneRbRrR<R=R?R@RARBRPRQRTRYR`RhRlRpRwRyRRRRRRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR8cs4
"				
		
	
				
	
				t
SoSCommandcBs eZdZdZdZRS(sA class to represent a command to be collected.

    A SoSCommand() object is instantiated for each command handed to an
    _add_cmd_output() call, so that we no longer need to pass around a very
    long tuple to handle the parameters.

    Any option supported by _add_cmd_output() is passed to the SoSCommand
    object and converted to an attribute. SoSCommand.__dict__ is then passed to
    _get_command_output_now() for each command to be collected.
    cKs|jj|dS(N(t__dict__R(RCtkwargs((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRscCs&djdt|jjDS(sIReturn a human readable string representation of this SoSCommand
        s, css%|]\}}d||fVqdS(s%s=%rN((R&tparamR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>s(R>tsortedRRW(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRQs(RRRRRQ(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRts
	tPlugincBs7eZdZdZZeZdZd[Zd\Z	d]Z
d^Zd_ZdZZ
dZZd`ZdZdZdZeZdZZdZZdadd	defgZd
ZedZdZed
ZdZdZdZ dZ!dZ"dZ#dZ$dZ%dZ&dZ'dZ(dZ)dZ*dZ+dZ,dZ-dZ.dZ/edZd Z0edZd!Z1eeed"Z2d#d$Z3d%Z4d#d&Z5d'Z6d(Z7d)Z8d*Z9d+Z:d,Z;d-Z<d.Z=dZd/Z>d0Z?d1Z@d2ZAd3d4ZBd5dZd6ZCd7ZDdZdZedZd8ZEd9ZFdZdZeeedZdZedZdZdZeed:
ZGdZed;ZHd<ZId=ZJdZd>ZKd?ZLdZd@ZMdZeeeedZdZedZdZeedAZNdZeeeedZdZedZdZdZdBZOeeedZdZedZedCZPdDZQdEZRdFZSdGZTdZdZdZdZdZedZedZdZdZdZdHZUedIZVdJZWdKZXdLZYdMZZdNZ[dOZ\dPZ]dQZ^dRZ_dSZ`dTZadUZbdVZcdWZddXZedYZfRS(bsA This is the base class for sosreport plugins. Plugins should subclass
    this and set the class variables where applicable.

    plugin_name is a string returned by plugin.name(). If this is set to None
    (the default) class\_.__name__.tolower() will be returned. Be sure to set
    this if you are defining multiple plugins that do the same thing on
    different platforms.

    requires_root is a boolean that specifies whether or not sosreport should
    execute this plugin as a super user.

    version is a string representing the version of the plugin. This can be
    useful for post-collection tooling.

    packages (files) is an iterable of the names of packages (the paths
    of files) to check for before running this plugin. If any of these packages
    or files is found on the system, the default implementation of
    check_enabled will return True.

    profiles is an iterable of profile names that this plugin belongs to.
    Whenever any of the profiles is selected on the command line the plugin
    will be enabled (subject to normal check_enabled tests).
    tunversionedRi,ttimeoutsTimeout in seconds for plugintfastitpostprocs,Enable post-processing collected plugin datacCs[t|dtsg|_ng|_g|_t|_g|_d|_g|_	g|_
||_g|_t|_
g|_g|_|d|_|d|_d|jkr|jdntjd|_|jj|jxV|jD]K}|j	j|d|j
ji|dd	6|d
d6|dd
6qW|jt|dS(Ntoption_listRtsysrootR|tsoslogtsosiitdescitspeeditenabled(tgetattrRrRtcopied_filestexecuted_commandsRt	_env_varstalertstcustom_textt	opt_namest	opt_parmsRtforbidden_pathst
copy_pathstcopy_stringstcollect_cmdsRR|tloggingt	getLoggerRtextendt_default_plug_optsR[t
set_predicateR8(RCRtopt((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs0										

"cCsd}y|jd}t|jd}|dkrB|}nL|dk	ri|dkrit|}n%|dk	r|dkr|}ndSWntk
r|jSX|dk	r|dkr|S|jS(sReturns either the default plugin timeout value, the value as
        provided on the commandline via -k plugin.timeout=value, or the value
        of the global --plugin-timeout option.
        tplugin_timeoutRiN(RRctintt
ValueErrorR(RCt_timeouttopt_timeouttown_timeout((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs 		
cCs|jS(sV
        Checks to see if the plugin has hit its timeout.

        This is set when the sos.collect_plugin() method hits a timeout and
        terminates the thread. From there, a Popen() call can still continue to
        run, and we need to manually terminate it. Thus, check_timeout() should
        only be called in sos_get_command_output().

        Since sos_get_command_output() is not plugin aware, this method is
        handed to that call to use as a polling method, to avoid passing the
        entire plugin object.

        Returns True if timeout has been hit, else False.

        (t_timeout_hit(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
check_timeoutscCs|jr|jS|jjS(s^Returns the plugin's name as a string. This should return a
        lowercase string.
        (tplugin_nameRtlower(tcls((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytnames	cCsd|j|fS(Ns[plugin:%s] %s(R(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_format_msgscCs|jj|j|dS(N(RterrorR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_log_errorscCs|jj|j|dS(N(RtwarningR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_log_warnscCs|jj|j|dS(N(RtinfoR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_log_infoscCs|jj|j|dS(N(RtdebugR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_log_debugscCs6|dtjkr |d}ntjj|j|S(Nii(tostsepR(R>R(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytjoin_sysroot s
cCs7|js|S|j|jr3|t|jS|S(N(tuse_sysroott
startswithRtlen(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
strip_sysroot%s
cCs|jtjjtjkS(N(RRR(tabspathR(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR,scCs1|j|jjg}tjj||jkS(N(Rtarchivetget_tmp_dirRR(tcommonprefix(RCtpaths((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttmp_in_sysroot/scCs|jj|dk	S(s'Is the package $package_name installed?N(R|tpkg_by_nameR(RCtpackage_name((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRm3scCs|jjj|S(s+Does the service $name exist on the system?(R|tinit_systemt
is_service(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR7scCs|jjj|S(sIs the service $name enabled?(R|Rt
is_enabled(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytis_service_enabled;scCs|jjj|S(sIs the service $name disabled?(R|Rtis_disabled(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytis_service_disabled?scCs|jjj|S(s'Is the service $name currently running?(R|Rt
is_running(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRiCscCs|jjj|dS(s,Return the reported status for service $nameRq(R|Rtget_service_status(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRGscCs|jjj|S(s$Get all service names matching regex(R|Rtget_service_names(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRKscCs
||_dS(s<Set or clear the default predicate for this plugin.
        N(t	predicate(RCtpred((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyROscCs
||_dS(sSet or clear the default predicate for command collection
            for this plugin. If set, this predecate takes precedence
            over the `Plugin` default predicate for command and journal
            data collection.
        N(t
cmd_predicate(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytset_cmd_predicateTscCs3|dk	r|S|r,|jdk	r,|jS|jS(sqGet the current default `Plugin` or command predicate. If the
            `cmd` argument is `True`, the current command predicate is
            returned if set, otherwise the default `Plugin` predicate
            will be returned (which may be `None`).

            If no default predicate is set and a `pred` value is passed
            it will be returned.
        N(RRR(RCR:R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
get_predicate\s
	cCs2|jd|d|}|dk	r.t|StS(s1Test the current predicate and return its value.

            :param cmd: ``True`` if the predicate is gating a command or
                        ``False`` otherwise.
            :param pred: An optional predicate to override the current
                         ``Plugin`` or command predicate.
        R:RN(RRtboolRr(RCR:R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttest_predicateks
cCs:d||jf}|r)|d7}n|j|dS(sLog that a command was skipped due to predicate evaluation.

            Emit a warning message indicating that a command was skipped due
            to predicate evaluation. If ``kmods`` or ``services`` are ``True``
            then the list of expected kernel modules or services will be
            included in the log message. If ``allow_changes`` is ``True`` a
            message indicating that the missing data can be collected by using
            the "--allow-system-changes" command line option will be included.
        sskipped command '%s': %ss3 Use '--allow-system-changes' to enable collection.N(RR(RCRR:R=R?tchangesR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytlog_skipped_cmdxs
RcCsM|js
dS|jd||r4dt|fnt}|j|t|S(shRemove certificate and key output archived by sosreport. cmd
        is the command name from which output is collected (i.e. exlcuding
        parameters). Any matching instances are replaced with: '-----SCRUBBED'
        and this function does not take a regexp or substituting string.

        This function returns the number of replacements made.
        is1Scrubbing certs and keys for commands matching %ss%s %s(RRt
_cert_replacetdo_cmd_output_subt
_certmatch(RCR:Rtreplace((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_cmd_private_subs		c
Csd|d}t|dr&|jn|}|jd|||f|jsSdSd}yx|jD]}|ddkrqfn|ddkr|jd|d	qfntj|d
|rftjj	|j
d|d}|jd||jj|}	t
j|||	j\}
}|rF|jj|
|qFqfqfWWn:tk
r}d
}|j||d	|fd}nX|S(s_Apply a regexp substitution to command output archived by sosreport.
        cmd is the command name from which output is collected (i.e. excluding
        parameters). The regexp can be a string or a compiled re object. The
        substitution string, subst, is a string that replaces each occurrence
        of regexp in each file collected from cmd. Internally 'cmd' is treated
        as a glob with a leading and trailing '*' and each matching file from
        the current module's command list is subjected to the replacement.

        This function returns the number of replacements made.
        t*tpatterns4substituting '%s' for '%s' in commands matching '%s'itfiletbinarytyess6Cannot apply regex substitution to binary output: '%s'texeR:tcmddirsapplying substitution to '%s's-regex substitution failed for '%s' with: '%s'N(thasattrRRRRRtfnmatchRR(R>RRt	open_fileRtsubnRt
add_stringt	ExceptionR(
RCR:tregexptsubsttglobstrRtreplacementstcalledR(treadableRuteR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs8			 !
c	Cs|jd|tj|j}|r9dt|fnt}g|jD]}||drI|^qI}x7|D]/}|d}|sqrn|j|t|qrWdS(sScrub certificate/key/etc information from files collected by sos.

        Files matching the provided pathregex are searched for content that
        resembles certificate, ssh keys, or similar information. Any matches
        are replaced with "-----SCRUBBED $desc" where `desc` is a description
        of the specific type of content being replaced, e.g.
        "-----SCRUBBED RSA PRIVATE KEY" so that support representatives can
        at least be informed of what type of content it was originally.

        Positional arguments:
            :param pathregex: A string or regex of a filename to match against
            :param desc: A description of the replaced content
        s.Scrubbing certs and keys for paths matching %ss%s %stsrcpathtdstpathN(RRtcompileR~RRtdo_file_subR(	RCt	pathregexRR~RRt	file_listtiR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_file_private_subs	,

cCsWy|j|}t|dr*|jn|}|jd||jd|||f|sedS|jj|}|j}t|tj	s|j
dd}ntj|||\}}	|	r|jj
||nd}	Wnhttfk
rR}
|
jtjkr,d}|j||nd}|j|||
fd}	nX|	S(	sgApply a regexp substitution to a file archived by sosreport.
        srcpath is the path in the archive where the file can be found.  regexp
        can be a regexp string or a compiled re object.  subst is a string to
        replace each occurance of regexp in the content of srcpath.

        This function returns the number of replacements made.
        Rssubstituting scrpath '%s's"substituting '%s' for '%s' in '%s'itutf8tignores-file '%s' not collected, substitution skippeds-regex substitution failed for '%s' with: '%s'(t_get_dest_for_srcpathRRRRRRRR
tstring_typestdecodeRRRtOSErrortIOErrorterrnotENOENTR(RCR	RRR(RRtcontentRuRRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs0	

cCst|ds!tj|}n|j}g|jD]}||dr4|^q4}x%|D]}|j|d||q]WdS(szApply a regexp substituation to a set of files archived by
        sos. The set of files to be substituted is generated by matching
        collected file pathnames against pathexp which may be a regular
        expression string or compiled re object. The portion of the file
        to be replaced is specified via regexp and the replacement string
        is passed in subst.R~R	N(RRRR~RR(RCtpathexpRRR~RRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_path_regex_subs	,
cCs
t||S(N(R(RCRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdo_regex_find_allsc	Cstj|}tjjtjj||}tjj|}tjj|rtjjtjj|}tjj|d|}|j	r|t
tjtj}n|j
d||fn|}|j
d||tjj|f|j|}|jj||tjj|rB|j
d|dS|jji|d6|d6dd6|d	6ytj|Wn7tk
r}|jd
kr|j
d|dSnX|j
d||f||kr|j|n|j
d
|dS(Ntstarts&made link target '%s' relative as '%s's0copying link '%s' pointing to '%s' with isdir=%ss%link '%s' is a directory, skipping...R	R
Rtsymlinktpointstoi(s;link '%s' is part of a file system loop, skipping target...s#normalized link target '%s' as '%s's.link '%s' points to itself, skipping target...(RtreadlinkR(R>tdirnametnormpathtisabstrealpathtrelpathRRRtpardirRtisdirRRtadd_linkRR[R-RRt
_do_copy_path(	RCR	tlinkdesttdesttabsdesttrealdirtreldestR
R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_copy_symlinksF!					cCsyWxPtj|D]?}|jd||ftjj||}|j|qWWntk
r}|jtjkstj	rd}|j
d||fdS|jtjkrd}|jd||fdSnXdS(Ns!recursively adding '%s' from '%s'sPermission denieds_copy_dir: '%s' %ss)Too many levels of symbolic links copyings_copy_dir: %s '%s'(
RtlistdirRR(R>R*RRtEPERMtEACCESRtELOOPR(RCR	RR(RR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	_copy_dirRs 	cCsN|jr|j|}nx)|jD]}||dkr(|dSq(WdS(NR	R
(RRRR(RCR	tcopied((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRdscCst||jS(N(R+R(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_is_forbidden_pathlscCsStj|j}tj|j}|j}|jj||tj||dS(N(Rtmajortst_rdevtminorR2Rtadd_nodetmakedev(RCR(R3tdev_majtdev_mintmode((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_copy_nodeos	cCs|jr
dS|j|r1|jd|dS|s@|}n|jr^|j|}nytj|}Wn)ttfk
r|j	d|dSXt
j|jr|j
|dSt
j|jrtj|tjrtj|s
|jj|dS|j|dSt
j|jp<t
j|jsvt|}|jd||f|j||dS|jd||f|jd@s|jjd|n|jj|||jji|d6|d	6d
d6dS(sCopy file or directory to the destination tree. If a directory, then
        everything below it is recursively copied. A list of copied files are
        saved for use later in preparing a report.
        Nsskipping forbidden path '%s'Rsfailed to stat '%s's creating %s node at archive:'%s's!copying path '%s' to archive:'%s'i$R	R
tnoR(RR7RRRRtlstatRRRR-tS_ISLNKR2R0tS_ISDIRtaccesstR_OKR1Rtadd_dirR5tS_ISREGR6R@Rtadd_fileRR[(RCR	R,R3tntype((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR*vsJ		
'
$	
cCst|tjr|g}n|jrOg|D]}|j|^q1}nxI|D]A}|jd|x'tj|D]}|jj|q}WqVWdS(snSpecify a path, or list of paths, to not copy, even if it's
            part of a copy_specs[] entry.
        sadding forbidden path '%s'N(	RR
RRRRtglobRR[(RCt	forbiddenRtforbidR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_forbidden_paths%
cCs|j|jfS(s%return a list of all options selected(RR(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_all_optionsscCsxt|j|jD]i\}}||krt|d}|t|krq|tdkrq||}n||d<tSqWtS(smSet the named option to value. Ensure the original type
           of the option value is preserved.
        RN(RRRttypeRRSRr(RCt
optionnametvalueRtparmstdefaulttype((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
set_options"$
icCsyd	}||kr&t|jd|SxLt|j|jD]5\}}||kr<|d}|d
k	rq|Sq<q<W|S(sHReturns the first value that matches 'optionname' in parameters
        passed in via the command line or set via set_option or via the
        global_plugin_options dictionary, in that order.

        optionaname may be iterable, in which case the first option that
        matches any of the option names is returned.
        tall_logsRatlog_sizeRtsincetverifyRR(sall_logssallow_system_changesslog_sizesplugin_timeoutssinceRYN(RRRRRR(RCRQtdefaulttglobal_optionsRRSR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRcs
"
R9cCsg|j|}y?g|j|D]}|j^q"}ttd|SWntk
rb|SXdS(sTWill try to return the option as a list separated by the
        delimiter.
        N(RctsplitR!RR	RR(RCRQt	delimiterRZtoptionRtopt_list((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_option_as_lists(
cCs|jj|dS(N(RR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_add_copy_pathsscsd|jdr'|jdntjdtjd|jd|jd|s|jd||jd|fdS|dkr|jd}n|jd	rd}n|r|d9}n|stSt	|t
jr|g}nx|D]}|ot|stS|j
r=|j|}n|j|}t|dkrdqndfd
srttfd|}n|jddtd}t}	x|D]}
|
|jkr
|jd|
qn|j|
r0|jd|
qn|	rM|jd|
qnytj|
}Wn%tk
r|jd|
qnX||tj7}|r||krt}	|rt|
r|jd|
|
}|dtjkr|jtj}n|jtjjdd}
|jt |
||
tjj!dtjj"|
}tjj#|d|j$|
}|j%j&||
q|jd|
q|j'|
gqWqWdS(s-Add a file or glob but limit it to sizelimit megabytes. Collect
        files with mtime not older than maxage hours.
        If fname is a single file the file will be tailed to meet sizelimit.
        If the first file in a glob is too large it will be tailed to meet
        the sizelimit.
        RXs".*((\.(zip|gz|bz2|xz))|[-.][\d]+)$s^%s/*tetcRs,skipped copy spec '%s' due to predicate (%s)NRWRViicSs-ytjj|SWntk
r(dSXdS(Ni(RR(tgetmtimeR(R(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRc/s
cszj|dks*j|dk	r.tStj|}rU|ksrrvt|dkrvtStS(sp When --since is passed, or maxage is coming from the
                plugin, we need to filter out older files iN(tsearchRRSR
t
fromtimestampRRr(R(tfiletime(tconfigfile_patternRctlogarchive_patterntmaxageRX(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyttime_filter5scs
|S(N((R(Rj(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt<lambda>DsRtreversesskipping redundant file '%s'sskipping forbidden path '%s'sskipping '%s' over size limitsfailed to stat '%s's)collecting tail of '%s' due to size limitRs.tailedRtsos_stringsi((RRcRRRRRRRrRR
RRRt_expand_copy_specRR	tsortRSRRR7RR-RtST_SIZER7RRRR(tadd_string_as_fileRR&R"R>RRR)Ra(RCt	copyspecst	sizelimitRittailitRtcopyspectfilestcurrent_sizet
limit_reachedt_filetfilestatt	file_nametstrfiletrel_patht	link_path((RgRcRhRiRXRjs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
add_copy_specs		

	!

	!c	Ksd|kr|jdnd}t|}|jd|j|jdtd|r|jj||j	d|j
n:|j||j
dt|j
dt|jd|jdS(	s?Internal helper to add a single command to the collection list.Rspacked command: R:sadded cmd output '%s'R=R?RN(tpopRRRRQRRSRR[RR:RRR=R?R(RCRRtsoscmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_add_cmd_outputts!!c Cst|tjr|g}nt|dkrL|s<|rL|jdn|
dkrj|jd}
n|dkr|jdt}nxl|D]d}|j	d|d|d|d|d|d	|d
|d|d|	d
|
d|d|d|
d|qWdS(s:Run a program or a list of programs and collect the outputis.ambiguous filename or symlink for command listRWR:tsuggest_filenametroot_symlinkRtstderrtchroottrunattenvRRsRtsubdirRt
foregroundN(
RR
RRRRRcRRSR(RCtcmdsRRRRRRRRRsRRRRR:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_cmd_outputs
cCs_tjj|jjd|j}|rEtjj||}n|r[tj|n|S(s[Return a path into which this module should store collected
        command output
        tsos_commands(RR(R>RRRtmakedirs(RCRtmaketcmd_output_path((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_cmd_output_pathscGs
t||S(sReturns lines matched in fnames, where fnames can either be
        pathnames to files to grep through or open file objects to grep through
        line by line.
        (R(RCRtfnames((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	file_grepscCs|jj}t||S(N(RR#R%(RCRR#((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR%sc
CsX|j}|r0|d|jdd7}ntjj|jd|}|j|}tjjtjj|jj	||rEd}|jj
}xtrAd|}|}	|t|	t|kr|	|t|	t| }	n|	|}	tjjtjj|jj	||	s4|	}Pn|d7}qWntjj||S(s@The internal function to build up a filename based on a command.s/%sRiRis.%d(
RR\RR(R>RR%texistsRRR#RSR(
RCRRt
plugin_dirtoutdirtoutfntincR#RFtnewfn((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_make_command_filenames*	
!
cCsUt|ts|g}nx3|D]+}|jj||j|jgq"WdS(sAdd an environment variable to the list of to-be-collected env vars.

        Accepts either a single variable name or a list of names. Any value
        given will be added as provided to the method, as well as an upper-
        and lower- cased version.
        N(RRRRtupperR(RCRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_env_vars
cCs|r|jdnd}t|tjsC|jdd}n|jdtd|s|jd||jd|fdS|j	j
||f|jd	||fdS(
s6Add a string to the archive as a file named `filename`iRRRR:Rs,skipped string ...'%s' due to predicate (%s)Nsadded string ...'%s' as '%s'(RsRR
RRRRrRRRR[R(RCRtfilenameRtsummary((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRqs	cCs|jr
dS|s)|jdjdkr5|j}nd}t}t|d|d|d|d|d|d	|	d
|
d|jd|
	}|d
dkr|jd||fn|d
dks|d
dkr|r[|dkr[|jdjdkr[|j	d|j
d|ft|d|dtd|d|d	|	d
|
d|j}q[n|jd||d
d kr|Sn|jd|j
dt||f|r|j
||}n|j
||}|t|jdd}|	r|jj|d|n|jj|d||rI|jj||n|jji|d6|d6|	rodndd	6|rtjj|jj|nd|d<|S(!s-Execute a command and save the output to a file for inclusion in the
        report.

        Positional Arguments:
            :param cmd:                 The command to run

        Keyword Arguments:
            :param suggest_filename:    Filename to use when writing to the
                                        archive
            :param root_symlink:        Create a symlink in the archive root
            :param timeout:             Time in seconds to allow a cmd to run
            :param stderr:              Write stderr to stdout?
            :param chroot:              Perform chroot before running cmd?
            :param runat:               Run the command from this location,
                                        overriding chroot
            :param env:                 Dict of env vars to set for the cmd
            :param binary:              Is the output in binary?
            :param sizelimit:           Maximum size in MB of output to save
            :param subdir:              Subdir in plugin directory to save to
            :param changes:             Does this cmd potentially make a change
                                        on the system?

        :returns:       dict containing status, output, and filename in the
                        archive for the executed cmd

        NRtalwaysRRRtchdirRRRstpollerRRqi|s command '%s' timed out after %dsi~iRs5command '%s' not found in %s - re-trying in host rootis%could not run '%s': command not founds+collected output of '%s' in %s (changes=%s)RiR;R:RRRARR(i~i(RRRRRRRRRRR\RrRRRRt
add_binaryRR)RR[RR(R>tget_archive_path(RCR:RRRRRRRRRsRRRtrootRRuRtoutfn_strip((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_cmd_outputsR		 		"$
c

Cs|jdtd|sZ|jd||jdtd|fidd6dd6dd6S|j|d|d	|d
|d|d|d
|d|d|	d|
d|
S(s]Execute a command and save the output to a file for inclusion in the
        report.
        R:Rs-skipped cmd output '%s' due to predicate (%s)RqRR;RRRRRRRRRRsRN(RRSRRRR(
RCR:RRRRRRRRRsRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcollect_cmd_outputMs	 c
Cs|jdtd|s*idd6dd6S|sF|jdjdkrR|j}
nd}
t|d|d	|
d
|d|d|d
|	S(sExecute a command right now and return the output and status, but
        do not save the output within the archive.

        Use this method in a plugin's setup() if command output is needed to
        build subsequent commands added to a report via add_cmd_output().
        R:RRqRR;RRRRRRRRN(RRSRRRRR(RCR:RRRRRRRRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytexec_cmdds	cCs||jjkS(s?Return whether specified module as module_name is loaded or not(R|tkernel_mods(RCtmodule_name((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRd|scCs|jj|dS(spAdd an alert to the collection of alerts for this plugin. These
        will be displayed in the report
        N(RR[(RCtalertstring((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt	add_alertscCs|j|7_dS(svAppend text to the custom text that is included in the report. This
        is freeform and can include html.
        N(R(RCttext((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_custom_textscKsvt|tjr|g}n|jjj}|sD|jddSx+|D]#}|jdd||f|qKWdS(sHCollect service status information based on the InitSystem used.

        :param services: A string, or list of strings, specifying the services
                          to collect
        :param kwargs    Optional arguments to pass to _add_cmd_output
                         (timeout, predicate, suggest_filename,..)
        sFCannot add service output, policy does not define an InitSystem to useNR:s%s %s(RR
RR|Rt	query_cmdRR(RCR?Rtquerytservice((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_service_statuss

c

Csd}
d}d}d}d}d}d}d}d	}d
}|jd}|p]|jd}|sut||nd
}t|tjr|g}n|rx|D]}|
||7}
qWn|	r|
||	7}
n|
r|
|7}
n|r|
d7}
n|r?|dkrd}n|dkr.d}n|
||7}
n|rV|
||7}
n|rm|
||7}
n|r|
||7}
n|r|
||7}
n|jd|
|jd|
d|d|d|dS(s7Collect journald logs from one of more units.

        :param units: A string, or list of strings specifying the
                       systemd units for which journal entries will be
                       collected.

        :param boot: A string selecting a boot index using the
                      journalctl syntax. The special values 'this' and
                      'last' are also accepted.

        :param since: A string representation of the start time for
                       journal messages.

        :param until: A string representation of the end time for
                       journal messages.

        :param lines: The maximum number of lines to be collected.

        :param allfields: A bool. Include all journal fields
                           regardless of size or non-printable
                           characters.

        :param output: A journalctl output control string, for
                        example "verbose".

        :param timeout: An optional timeout in seconds.
        :param identifier: An optional message identifier.
        :param catalog: Bool. If True, augment lines with descriptions
                        from the system catalog.
        :param sizelimit: Limit to the size of output returned in MB.
                          Defaults to the value of --log-size.
        sjournalctl --no-pager s
 --unit %ss
 --boot %ss
 --since '%s's --until %ss --lines %ss --output %ss --identifier %ss
 --catalogidRVRWis --alltthisRtlasts-1scollecting journal: %sR:RRsRN(RctmaxRR
RRR(RCtunitstbootRXtuntiltlinest	allfieldsR;Rt
identifiertcatalogRsRtjournal_cmdtunit_opttboot_optt	since_optt	until_optt	lines_optt
output_opttidentifier_opttcatalog_opttjournal_sizeRVRWtunit((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_journalsR$


		cCswd}|r|d7}nt|tjr7|g}nx9|D]1}|jd||jdd||fq>WdS(sGCollect udevadm info output for a given device

        :param device: A string or list of strings of device names or sysfs
                       paths. E.G. either '/sys/class/scsi_host/host0' or
                       '/dev/sda' is valid.
        :param attrs: If True, run udevadm with the --attribute-walk option.
        sudevadm infos -ascollecting udev info for: %sR:s%s %sN(RR
RRR(RCtdevicetattrstudev_cmdtdev((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
add_udev_infos

cCs
tj|S(N(RK(RCRu((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRnscCs6x/|jD]$}|jd||j|q
WdS(Nscollecting path '%s'(RRR*(RCR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_copy_specsscCsSxL|jD]A}|jd|j|jd|j|j|jq
WdS(Nsunpacked command: scollecting output of '%s'(RRRQRR:RR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
_collect_cmdsscCsx|jD]\}}|jr#dSd}|ri|jd}t|tjsi|jdd}qin|jd||fy/|jj	|t
jjd|j
|Wq
tk
r}|jd||fq
Xq
WdS(NRiRRs!collecting string ...'%s' as '%s'Rmscould not add string '%s': %s(RRRsRR
RRRRRRR(R>RRR(RCtstringR{RR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt_collect_stringss$				cCsUt}|j|j|j|jt|f}|jd|dS(sCollect the data for a plugin.scollected plugin '%s' in %sN(RRRRRR(RCRtfields((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcollect1s	


cCs[yBt|dr(|jr(|jjSt|j|jjSWntk
rVdSXdS(s9 This function will return the description for the pluginRs<no description available>N(RRR!tsupert	__class__R(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_description:s

c
Cs[t|j|j|j|j|j|jgr0t|jtj	rW|jg|_nt|jtj	r~|jg|_nt|jtj	r|jg|_nt|jtj	r|jg|_nt|jtj	r|jg|_nt|t
rgt|_x|j
D]}g|jD]}|i|d6^q.}g|jD]}|i|d6^qU}g|jD]}|i|d6^q|}g|jD]}|i|d6^q}	|j||||	rt|jj|qqWtt|jdkS|j|j|j|j|jSt|t
rW|j
t|_ntS(sThis method will be used to verify that a plugin should execute
        given the condition of the underlying environment.

        The default implementation will return True if none of class.files,
        class.packages, nor class.commands is specified. If any of these is
        specified the plugin will check for the existence of any of the
        corresponding paths, packages or commands and return True if any
        are present.

        For SCLPlugin subclasses, it will check whether the plugin can be run
        for any of installed SCLs. If so, it will store names of these SCLs
        on the plugin class in addition to returning True.

        For plugins with more complex enablement checks this method may be
        overridden.
        tscl_namei(R)RvR@tcommandsRR?t
architecturesRR
Rt	SCLPluginRPt
_scls_matchedt	_get_sclst_check_plugin_triggersR[RRS(
RCtsclRRvR'R@tcRRR?((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
check_enabledCs@''''		
cstd|Dstfd|Dstd|DstfdjDstfd|DojS(Ncss!|]}tjj|VqdS(N(RR(R(R&R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>sc3s|]}j|VqdS(N(Rm(R&Ro(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>scss|]}t|VqdS(N(R(R&R:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>sc3s|]}j|VqdS(N(Rd(R&tmod(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>sc3s|]}j|VqdS(N(R(R&Rk(RC(s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pys	<genexpr>s(R)Rtcheck_is_architecture(RCRvR@RR?((RCs8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRscCsB|jdkrtSddj|j}tj||jjS(sChecks whether or not the system is running on an architecture that
        the plugin allows. If not architecture is set, assume plugin can run
        on all arches.
        s(?:%s)RzN(RRRSR>RR~R|R}(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRscCstS(swThis decides whether a plugin should be automatically loaded or
        only if manually specified in the command line.(RS(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytdefault_enabledscCs7x0|jD]%}|j|r
|j|q
q
WdS(sBased on the class attrs defined for plugin enablement, add a
        standardized set of collections before we call the plugin's own setup()
        method.
        N(R?RR(RCR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_default_collectionsscCs|jt|jdS(sCollect the list of files declared by the plugin. This method
        may be overridden to add further copy_specs, forbidden_paths, and
        external programs if required.
        N(RRRv(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytsetupscCst|ds|jr_t|drX|jrXg|jD]}|d^q<|_q_dSn|jj}|j|j}|r|j|ndS(Ntverify_packagesR@t$(RRR@R|tpackage_managertbuild_verify_commandR(RCR'tpmt
verify_cmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytsetup_verifys&cCsdS(sLPerform any postprocessing. To be replaced by a plugin if required.
        N((RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRsc	Cst}d}yZtj|}xD|D]<}t|d}|jj}||kr%t}q%q%WWntk
r|}tSX|S(saChecks if a named process is found in /proc/[0-9]*/cmdline.
        Returns either True or False.s/proc/[0-9]*/cmdlinetr(RrRKtopenRR!RSR(	RCtprocessRqt
cmd_line_globtcmd_line_pathsR(Rtcmd_lineR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytcheck_process_by_names
c	Csg}d}tj|}x~|D]v}yWt|dB}|jj}||krx|j|jddnWdQXWq"tk
r}q"q"Xq"W|S(slReturns PIDs of all processes with process name.
        If the process doesn't exist, returns an empty lists/proc/[0-9]*/cmdlineRRiN(RKRRR!R[R\R(	RCRtpidsRRR(RRR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytget_process_pidss
'N(((((((stimeoutsTimeout in seconds for pluginRi(gRRRRRRSt
requires_roottversionR@RvRRR?RRtprofilesRRtcmd_timeoutRrRRRRRtpropertyRRtclassmethodRRRRRRRRRRRmRRRRiRRRRRRRRRRRRRR0R5RR7R@R*RNRORURcR`RaRRRRRR%RRRqRRRRdRRRRRRnRRRRRRRRRRRRRRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs		"																				
	,	%			;				<				u	
		
				^								W									=		
				
		tRedHatPlugincBseZdZRS(s/Tagging class for Red Hat's Linux distributions(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRsRcBsSeZdZedZdZdZdZdZdZ	dZ
RS(sSuperclass for plugins operating on Software Collections (SCLs).

    Subclasses of this plugin class can specify class.files and class.packages
    using "%(scl_name)s" interpolation. The plugin invoking mechanism will try
    to match these against all found SCLs on the system. SCLs that do match
    class.files or class.packages are then accessible via self.scls_matched
    when the plugin is invoked.

    Additionally, this plugin class provides "add_cmd_output_scl" (run
    a command in context of given SCL), and "add_copy_spec_scl" and
    "add_copy_spec_limit_scl" (copy package from file system of given SCL).

    For example, you can implement a plugin that will list all global npm
    packages in every SCL that contains "npm" package:

    class SCLNpmPlugin(Plugin, SCLPlugin):
        packages = ("%(scl_name)s-npm",)

        def setup(self):
            for scl in self.scls_matched:
                self.add_cmd_output_scl(scl, "npm ls -g --json")
    cCs4tt|ds'gt|_nt|jS(NR(RRPR(RC((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytscls_matchedscCs3tdd}g|jD]}|j^qS(Nsscl -lR;(RRsR!(RCR;R((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRscCs|jj}y&td|djjd}Wn*tk
ra}|jd||fnXtjd}x-|j	dD]}d||||f}qWd|||f}|S(	sCwrapping command in "scl enable" call and adds proper PATH
        s/etc/scl/prefixes/%sRs
s*Failed to find prefix for SCL %s, using %stPATHt:s
%s/%s%s:%ssscl enable %s "PATH=%s %s"(
R|tget_default_scl_prefixRRtrstripRRRtenvironR\(RCRR:RERR(R'tscl_cmd((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytconvert_cmd_scls
	
cKsbt|tjr|g}ng}x'|D]}|j|j||q+W|j||dS(spSame as add_cmd_output, except that it wraps command in
        "scl enable" call and sets proper PATH.
        N(RR
RR[RR(RCRRRtscl_cmdsR:((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_cmd_output_scls
cCs\|jj}xFddgD]8}tjd|}|jd|||f|}qW|S(NRbtvars^/%s/s
/%s/%s/%s/(R|RRRR (RCRRut
scl_prefixtrootdirR'((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytconvert_copyspec_scl's
cCs_t|tjr|g}ng}x'|D]}|j|j||q+W|j|dS(s`Same as add_copy_spec, except that it prepends path to SCL root
        to "copyspecs".
        N(RR
RR[R
R(RCRRrt
scl_copyspecsRu((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_copy_spec_scl/s
cKs |j|j|||dS(seSame as add_copy_spec_limit, except that it prepends path to SCL
        root to "copyspec".
        N(tadd_copy_spec_limitR
(RCRRuR((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pytadd_copy_spec_limit_scl:s(RRRRRRRRR
RR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRs					tPowerKVMPlugincBseZdZRS(s$Tagging class for IBM PowerKVM Linux(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRDst
ZKVMPlugincBseZdZRS(s Tagging class for IBM ZKVM Linux(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRIstUbuntuPlugincBseZdZRS(sTagging class for Ubuntu Linux(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRNstDebianPlugincBseZdZRS(sTagging class for Debian Linux(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRSst
SuSEPlugincBseZdZRS(s*Tagging class for SuSE Linux distributions(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRXstIndependentPlugincBseZdZRS(s6Tagging class for plugins that can run on any platform(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyR]stExperimentalPlugincBseZdZRS(s=Tagging class that indicates that this plugin is experimental(RRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyRbscCs)d|}|stf}nt||S(sImport name as a module and return a list of all classes defined in that
    module. superclasses should be a tuple of valid superclasses to import,
    this defaults to (Plugin,).
    ssos.plugins.%s(RR(Rtsuperclassest
plugin_fqname((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt
import_plugings
(3Rt
__future__Rt
sos.utilitiesRRRRRRRRKRR-RRRRR
t	six.movesRR	R
tFileNotFoundErrort	NameErrorRRRR%R+R6R7RtDOTALLRRtobjectR8RRRRRRRRRRRRR(((s8/usr/lib/python2.7/site-packages/sos/plugins/__init__.pyt<module>sX.

							
Wc
Back to Directory File Manager