KGRKJGETMRETU895U-589TY5MIGM5JGB5SDFESFREWTGR54TY
Server : Apache/2.2.17 (Unix) mod_ssl/2.2.17 OpenSSL/0.9.8e-fips-rhel5 DAV/2 PHP/5.2.17
System : Linux localhost 2.6.18-419.el5 #1 SMP Fri Feb 24 22:47:42 UTC 2017 x86_64
User : nobody ( 99)
PHP Version : 5.2.17
Disable Function : NONE
Directory :  /proc/21573/task/21573/root/usr/lib/python2.4/site-packages/sos/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //proc/21573/task/21573/root/usr/lib/python2.4/site-packages/sos/plugintools.pyc
m
l2Wc@sdZdkTdklZlZdkZdkZdkZdkZdk	Z	dk
Z
dkZdkZdk
Z
dkTdklZdkZeiddjo*eiddjod	Zee_nd
fdYZdS(s.
This is the base class for sosreport plugins
(t*(sThreadsactiveCountN(stimeiiiicCs?dk}|i}tid||i}|i|S(Ntfile(tStringIOtoutputt	tracebackt	print_exctgetvaluettorettclose(RRR((t3/usr/lib/python2.4/site-packages/sos/plugintools.pyt
format_exc)s	
t
PluginBasecBstZdZdZdZdZdZdZdZdZ	dZ
d	Zd
dZdZ
d
ZdZdZdZdZdZeedZdZdZdZeedZdZdZdZdZdZdZ edZ!eedZ"d Z#d!Z$d"Z%d#Z&d$Z'd%Z(d&Z)d'Z*d(Z+RS()s 
    Base class for plugins
    cCs;yt|iWng|_nXg|_g|_g|_g|_g|_d|_g|_	g|_
||_||_g|_g|_g|_d|_d|_d|_d|_d|_tid|_x\|iD]Q}|i	i|d|i
ihd|d<d|d<d|d	<qWdS(
Ntitsositdesctspeeditenabledi(tlentselft
optionListtcopiedFilest
copiedDirstexecutedCommandst
diagnose_msgstalertst
customTexttoptNamestoptParmst
pluginnametpiNametcommonstcInfotforbiddenPathst	copyPathstcollectProgstNonetthreadtpidt
eta_weightt
time_startt	time_stoptloggingt	getLoggertsoslogtopttappend(RRRR,((R	t__init__8s6
																		
c
CsXt|ioDxA|iD]2}ti|d|otii|i	d|di
tii}	yyt
|	d}ti|||i\}}|i|djo.t
|	d}|i||i|SnWqLtj
o
tqLtj
o
tqLtj
o*}|iitid|	|fPqLXqqWnt S(sEApply a regexp substitution to a file archived by sosreport.
        tsrcpathtdstroottritwsProblem at path %s (%s)N(!RRRtafiletfnmatchR/tostpathtjoinRtlstriptseptabspathtopentfptretsubntregexptsubsttreadttmpouttoccursRtwritet
SystemExittKeyboardInterruptt	ExceptionteR+tlogR)tVERBOSEtFalse(
RR/R?R@R<RHRBRCR3R:((R	t
doRegexSubZs0
!





 cCskg}t|d}|i}|iti|ti
}x$|i|D]}|i|qPW|S(sG Return a list of all non overlapping matches in the string(s)
        R1N(toutR;tfnametfRAtcontentRR=tcompiletregext	MULTILINEtregtfindalltiR-(RRRRNRORVRPRTRM((R	tdoRegexFindAllts
cCsd}x1|iD]&}|i|djo
d}qqW|odSntii|p|ii	d|dSntii
|otii|odSnti|}tii|id|itii}tii|oDttii|tii|id|itii}	n|}	tii|o"|iitid|dSntiitii|otiitii|ptitii|n|iitid||	fti|	|tii|o|i|n)|itiitii|||iihd	|<d
|	<dd<d
|<dSnitii|oUxJti |D]9}|djp
|djoq|i|d|qWdSn|iitid|y|i"|\}}Wndj
o%|iitid|dSnht%j
o#}
|ii'd||
n:t(j
o-}
|iiti)d||
fdSnX|iihd	|<d
|<dd<|S(s Copy 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
        iiRs#file or directory %s does not existNR0s.skipping symlink creation: already exists (%s)screating symlink %s -> %sR/tdstpathtsymlinktyestpointstot.s..t/scopying file %st
AlreadyExistss&error copying file %s (already exists)serror copying file %s (IOError)serror copying file %s (%s)tno(*tcopyProhibitedRR R6R/tcountR5texistsR+tdebugtislinktisdirtreadlinktlinkR7RR8R9t	dstslnametisabst
sosRelPathtdirnametrpthRIR)tDEBUGtmakedirstVERBOSE3RYtdoCopyFileOrDirRR-tlistdirR3t_PluginBase__copyFilettdstpathR:tIOErrorRHtwarningRGtVERBOSE2(RR/RsRgRhR6R3R`R:RlRH((R	Rpsh
+D> (4
 	+cCsytd|d|id\}}}|o|ii|nt	i
i|id|it	i
i
}t|id|}||fSWn_tj
o
tnHtj
o
tn0tj
o#}|iid||fnXdS(sn call cp to copy a file, collect return status and output. Returns the
        destination file name.
        s@/bin/cp --parents -P --preserve=mode,ownership,timestamps,links t R0trptdirsProblem copying file %s (%s)N(tsosGetCommandOutputtsrcRRtstatustshouttruntimeR+RcR5R6R7R8R9R:RjtrelpathRERFRGRHRu(RRzR{RHR|R}R:R~((R	t
__copyFiles(+

cCs.x'ti|D]}|ii|qWdS(sNSpecify a path to not copy, even if it's part of a copyPaths[] entry.
        N(tglobt
forbiddenPathtfilespecRR R-(RRR((R	taddForbiddenPathscCs|i|ifS(s7
        return a list of all options selected
        N(RRR(R((R	t
getAllOptionsscCsEx>t|i|iD]'\}}||jo||d<qqWdS(s- enable or disable the named option.
        RN(tzipRRRtnametparmst
optionnametenable(RRRRR((R	t	setOptions

cCsCx<t|i|iD]%\}}||jo|dSqqWdS(s2 see whether the named option is enabled.
        RiN(RRRRRRR(RRRR((R	tisOptionEnableds
icCs|djo|i|Snti|}t|p|iid|dSn|i	d}t}|dd9}xQ|D]I}|ti|t7}|o||jot}Pn|i|qW||djo<|o5|id||fdtii||dndS(s/Add a file specification (with limits)
        isglob %s is emptyNistail -c%d %sttail_i(t	sizelimitRtaddCopySpectcopyspecRtfilesRR+RctsorttcursizeRKt
limit_reachedtflogR5tstattST_SIZEtTruetcollectExtOutputR6tbasename(RRRRRRR((R	taddCopySpecLimits*


cCs.x'ti|D]}|ii|qWdS(sz Add a file specification (can be file, dir,or shell glob) to be
        copied into the sosreport by this module
        N(RRRRR!R-(RRR((R	RscCs1tiidtiid|i|dS(sA Deprecated - please modify modules to use addCopySpec()
        s@Warning: thecopyFileGlob() function has been deprecated.  Pleases6use addCopySpec() instead.  Calling addCopySpec() now.N(tsyststderrRDRRtsrcglob(RR((R	tcopyFileGlob'scCs*tiidtiidtdS(sA Deprecated - please modify modules to use addCopySpec()
        sCWarning: the copyFileOrDir() function has been deprecated.  Please
s7use addCopySpec() instead.  Calling addCopySpec() now.
N(RRRDt
ValueError(RR/((R	t
copyFileOrDir.scCs4tiidtiidtiiddS(s( Deprecated - use callExtProg()
        sCWarning: the runExeInd() function has been deprecated.  Please use
s8the callExtProg() function.  This should only be called
sif collect() is overridden.N(RRRD(Rtexe((R	t	runExeInd6scCsati|idtip(|iiti	d|idnt
|\}}}|S(s[ Execute a command independantly of the output gathering part of
        sosreport
        is-binary '%s' does not exist or is not runnableN(R5taccesstprogtsplittX_OKRR+RIR)RJRyR{R|R}(RRR{R|R}((R	tcallExtProg>s
 (cCsRti|idtip(|iiti	d|idnt
|S(s[ Execute a command independantly of the output gathering part of
        sosreport
        is-binary '%s' does not exist or is not runnableN(R5RRRRRR+RIR)RJRy(RR((R	tcallExtProgWithOutputJs (cCs$tiidtiiddS(s- Deprecated - use collectExtOutput()
        s@Warning: the runExe() function has been deprecated.  Please use
s!the collectExtOutput() function.
N(RRRD(RR((R	trunExeUscCs|ii|||fdS(s6
        Run a program and collect the output
        N(RR"R-Rtsuggest_filenameRY(RRRRY((R	R\scCs^g}t|d}x8|iD]*}ti||o|i	|q"q"W|i
|S(NR1(tresultsR;RNR<t	readlinestlineR=tmatchR?R-R(RR?RNR<RR((R	tfileGrepbs

cCsStidd|}tidd|}tidd|iddd	!}|S(
Ns^/(usr/|)(bin|sbin)/Rs[^\w\-\.\/]+t_R]R\s ._-ii@(R=tsubRtmanglednametstrip(RRR((R	t
mangleCommandls%cCs|idd|id|i|}tii|oQd}xHt
o<d||f}tii|p|}Pn|d7}qEWn|S(sA The internal function to build up a filename based on a command tcmddirR]is%s_%diN(RRRRRtoutfnR5R6RbtincRtnewfn(RRRRR((R	tmakeCommandFilenamess)c	Csati|idtip(|iiti	d|idnt
|\}}}|o|i|}
n|i|}
tiitii|
ptitii|
n|djp
|djpy?t|
d}t|o|i|dn|iWntj
o}|nX|o|
t|idd}d	ti |d
|}	ti"}ti$|idyti|	|i%dWnnXti$|n|
t|idd}
n'|iiti	d
|d}
d}
|i(i)hd|<d|
<|idi*d|d|d|
d||
S(s] Execute a command and save the output to a file for inclusion in
        the report
        is=binary '%s' does not exist or is not runnable, trying anywaysiiR2s
R0is../R]s/.Rscould not run command: %sRRt	xmlreporttcmdlinetexitcodetf_stdoutR}N(+R5RRRRRR+RIR)RJRyR{R|R}RRRR6ReRktmkdirR;toutfdRRDRRtRHRYRt
dst_from_roottstringRattargettgetcwdtcurdirtchdirRtoutfn_stripR#RR-tadd_command(RRRRYRR|RR{RHRRRR}R((R	tcollectOutputNowsD (
")cCs|i|}tiitii|ptitii|nt	|d}|i||i
|iihd|<d|<|S(s
 A function that allows you to write a random text string to the
        command output location referenced by exe; this is useful if you want
        to conditionally collect information, but still want the output file
        to exist so as not to confuse readers R2RRN(RRRRR5R6ReRkRR;RRDttextRRR-(RRRRR((R	twriteTextToCommands

"cCs|ii|dS(s Add a configuration sanity warning for this plugin. These
        will be displayed on-screen before collection and in the report as well.
        N(RRR-talertstring(RR((R	taddDiagnosescCs|ii|dS(sq Add an alert to the collection of alerts for this plugin. These
        will be displayed in the report
        N(RRR-R(RR((R	taddAlertscCs|i||_dS(sw Append text to the custom text that is included in the report. This
        is freeform and can include html.
        N(RRR(RR((R	t
addCustomTextscCs|idtS(s This function has been replaced with copyStuff(threaded = True).  Please change your
        module calls.  Calling setup() now.
        tthreadedN(Rt	copyStuffR(R((R	t	doCollectscCs|io|iiSndS(s2
        if threaded, is thread running ?
        N(RR$tisAliveR#(R((R	t	isRunnings
cCs|ii||iiS(sT
        wait for a thread to complete - only called for threaded execution
        N(RR$R7ttimeoutR(RR((R	twaitscCs|oV|idjoFtd|id|iddt|g|_|ii	|iSn|o|i
n|iit
id|it|_d|_x|iD]}|iid|y|i|Wqtj
o}|qtj
o|otSqtqtj
o|otSqtqtj
oE}|iit
id||f|iit
itiqXqWx|iD]\}}}|iid|y|i"|||Wqtj
o}|qtj
o|otSqtqtj
o|otSqtq|iit
id	||iit
itiqXqWt|_|o|i#n|iit
id
|it$i%i&d|ift$i%i'dS(
s/
        Collect the data for a plugin
        RRs-threadtargssstarting threaded plugin %sscopying pathspec %ss7error copying from pathspec %s (%s), traceback follows:scollecting output of '%s's3error collection output of '%s', traceback follows:splugin %s returnings+
 plugin %s finished ...                   N((RRR$R#tThreadRRRt	semaphoretstarttacquireR+RIR)RJttimeR'R(R!R6RcRpRtRHRERFRGRvRR
R"RRRYRtreleaseRtstdoutRDtflush(RRRRYRR6RHR((R	Rsh.
	



 %



$cCs#y|iiSWndSnXdS(s9 This function will return the description for the plugins<no description available>N(Rt__doc__R(R((R	tget_description8s
cCstS(sg This function can be overidden to let the plugin decide whether
        it should run or not.
        N(R(R((R	tcheckenabled?scCstS(swThis devices whether a plugin should be automatically loaded or
        only if manually specified in the command line.N(R(R((R	tdefaultenabledEscCs|idS(sw This function has been replaced with setup().  Please change your
        module calls.  Calling setup() now.
        N(Rtsetup(R((R	tcollectJscCsdS(s~This class must be overridden to check the sanity of the system's
        configuration before the collection begins.
        N((R((R	tdiagnosePscCsdS(sThis class must be overridden to add the copyPaths, forbiddenPaths,
        and external programs to be collected at a minimum.
        N((R((R	RVscCsdS(sM
        perform any analysis. To be replaced by a plugin if desired
        N((R((R	tanalyze\scCsdS(sS
        perform any postprocessing. To be replaced by a plugin if desired
        N((R((R	tpostprocbscCs`d|i}|d|id}t|ioy|d}x^|iD]S}|d|d|df}|dd	jo|d
|d}n|d}qFW|d
}nt|ioy|d}x^|iD]S}|d|d|df}|dd	jo|d
|d}n|d}qW|d
}nt|io|d}x|iD]y}|doVt|doEt
|id|idd|d}|d||df}qX|d|d}qXW|d
}nt|i
o:|d}x|i
D]}|d|}qW|d
}n|idjo|d}||id}n|S(sm Present all information that was gathered in an html file that allows browsing
        the results.
        s<hr/><a name="%s"></a>
s<h2> Plugin <em>s</em></h2>
s<p>Files copied:<br><ul>
s<li><a href="%s">%s</a>RXR/RYRZs (symlink to %s)R[s</li>
s
</ul></p>
s<p>Directories Copied:<br><ul>
s<li><a href="%s">%s</a>
s<p>Commands Executed:<br><ul>
RRxRR]s<li><a href="%s">%s</a></li>
Rs<li>%s</li>
s<p>Alerts:<br><ul>
Rs<p>Additional Information:<br>
s</p>
N(RRthtmlRRR3RtadirRtcmdRjRt
cmdOutRelPathRtalertR(RRRRRRR3((R	treporthsP






)


(,t__name__t
__module__RR.RLRWRpRrRRRRRRRRRRRRR#RRRRRKRRRRRRRRRRRRRRRRRR(((R	R4sP	"		
	U														
		6						@								(Rtsos.helperst	threadingRtactiveCountR5tos.pathRRt	itertoolsRR=RR)RRR4tversion_infoR
R(RR)RRR
RRRRR=RRR4R5((R	t?sH	
	(		


Anon7 - 2021