Your IP : 172.28.240.42


Current Path : /usr/lib/python2.7/dist-packages/landscape/monitor/
Upload File :
Current File : //usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyc


Tc@sddlZddlZddlZddlmZddlmZdefdYZdddYZddd	YZ	d
ddYZ
ddd
YZde	fdefde
fdefgZdS(iN(tPluginConfigError(t
MonitorPlugint
ProcessorInfocBsweZdZdZdZd
Zdd
ddZdZdZ	dZ
ed	Zed
Z
dZdZRS(sPlugin captures information about the processor(s) in this machine.

    This plugin runs once per client session.  When processor
    information is retrieved it's compared against the last known
    processor information, which is saved in persistent storage.  A
    message is only put on the message queue if the latest processor
    information differs from the last known processor information.

    The information available from /proc/cpuinfo varies per platform.
    For example, an Apple PowerMac Dual G5 doesn't contain a vendor ID
    and provides the processor name in the 'cpu' field, as opposed to
    the 'model name' field used on x86-based hardware.  For reasons
    such as this, the schema of the data reported by this plugin is
    flexible.  Only 'processor-id' and 'model' are guaranteed to be
    present.

    In order to deal with the vagaries of parsing /proc/cpu
    information on the various platforms we support, message
    generation is deferred to per-platform message factories.

    @param delay: Set the starting delay.
    @param machine_name: The machine name to report.
    @param source_filename: The filesystem path to read information from.
    sprocessor-infotcpuis
/proc/cpuinfocCsJ||_||_|dkr1tjd}n|j|||_dS(Ni(t_delayt_source_filenametNonetostunamet_create_cpu_info_readert_cpu_info_reader(tselftdelaytmachine_nametsource_filename((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyt__init__(s			cCsUx>tD]6}tj|d}|j|r|d|SqWtd|dS(sAReturn a message factory suitable for the specified machine name.iis2A processor info reader for '%s' is not available.N(tmessage_factoriestretcompiletmatchR(RR
Rtpairtregexp((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR	3s
cCsLtt|j||jjj|j|j|jd|j	t
dS(s8Register this plugin with the specified plugin registry.sprocessor-infoN(tsuperRtregistertregistrytreactort
call_laterRtruntcall_on_acceptedtsend_messagetTrue(RR((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR>scCsidd6|jjd6S(s6Retrieve processor information and generate a message.sprocessor-infottypet
processors(R
tcreate_message(R((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR!Ds
cCst}|j}x|dD]}dt|df}|jj|}|dkrvi}|j||t}q|j||r|j||t}qqW|rt	j
d|jjj
||jd|ndS(NR t	processorsprocessor-ids-Queueing message with updated processor info.turgent(tFalseR!tstrt_persisttgetRt_updateRt_has_changedtloggingtinfoRtbrokerRt_session_id(RR#tdirtytmessageR"tkeytcached_processor((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRIs 	

cCs |jjjd|j|dS(s1Create a message and put it on the message queue.sprocessor-infoN(RR,tcall_if_acceptedR(RR#((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR^scCs\|d|dkrtS|d|jddkr8tS|d|jddkrXtStS(s>Returns true if processor details changed since the last read.tmodeltvendortt
cache_sizes
cache-sizei(RR'R$(RR"R/((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR)cscCso|d|d<|d|d<|jdd|d<|jdd|d<|jjd	t|df|d
S(s1Update the processor details with current values.sprocessor-idtidR3s
cache-sizeiR6R4R5R"N(R'R&tsetR%(RR"R/((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR(psN(t__name__t
__module__t__doc__tpersist_nametscopeRtrun_intervalRR	RR!R$RRR)R((((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR	s
				
tPowerPCMessageFactorycBs eZdZdZdZRS(sFactory for ppc-based processors provides processor information.

    @param source_filename: The file name of the data source.
    cCs
||_dS(N(R(RR((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRscCsg}t|j}zd}x|D]}|jdd}|dj}|dkrit|djd6}|j|q%|dkr%|dj|d<q%q%WWd|jX|S(	s;Returns a list containing information about each processor.t:iiR"sprocessor-idRR3N(topenRRtsplittstriptinttappendtclose(RR tfiletcurrenttlinetpartsR0((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR!s
(R9R:R;RR!(((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR?zs	tARMMessageFactorycBs eZdZdZdZRS(sFactory for arm-based processors provides processor information.

    @param source_filename: The file name of the data source.
    cCs
||_dS(N(R(RR((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRsc	Csg}t|j}ztjd}i}x|D]}|j|j}|r4|jd}|jd}|dkrd|d<||d<q|dkrt||d	<qq4q4W|r|j|nWd
|j	X|S(s;Returns a list containing information about each processor.s (?P<key>.*?)\s*:\s*(?P<value>.*)R0tvaluet	Processorisprocessor-idR3s
Cache sizes
cache-sizeN(
RARRRRRCtgroupRDRERF(	RR RGRRHRIRR0RL((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR!s&


(R9R:R;RR!(((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRKs	tSparcMessageFactorycBs eZdZdZdZRS(sFactory for sparc-based processors provides processor information.

    @param source_filename: The file name of the data source.
    cCs
||_dS(N(R(RR((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRscCsg}d	}t|j}ztjd}x|D]}|jdd}|dj}|dkr{|dj}q4|j|r4tjdj|j	\}}	it
|||	!d6|d6}
|j|
q4q4WWd	|jX|S(
s;Returns a list containing information about each processor.sCPU(\d{1})+R@iiRs\d+sprocessor-idR3N(
RRARRRRBRCRtsearchtspanRDRERF(RR R3RGRRIRJR0tstarttendR/((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR!s"
$
(R9R:R;RR!(((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyROs	tX86MessageFactorycBs eZdZdZdZRS(sFactory for x86-based processors provides processor information.

    @param source_filename: The file name of the data source.
    cCs
||_dS(N(R(RR((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRscCsg}t|j}zd}x|D]}|jdd}|dj}|dkrit|djd6}|j|q%|dkr|dj|d<q%|dkr|dj|d	<q%|d
kr%|dj}t|dj|d<q%q%WWd|jX|S(
s;Returns a list containing information about each processor.R@iiR"sprocessor-idt	vendor_idR4s
model nameR3s
cache sizes
cache-sizeN(RARRRBRCRDRERF(RR RGRHRIRJR0tvalue_parts((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyR!s&
%(R9R:R;RR!(((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyRTs	s(arm*|aarch64)sppc(64)?s	sparc[64]si[3-7]86|x86_64(((((
R*RRtlandscape.pluginRtlandscape.monitor.pluginRRR?RKRORTR(((sC/usr/lib/python2.7/dist-packages/landscape/monitor/processorinfo.pyt<module>sq (#%