Your IP : 172.28.240.42


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

ó
ÍÿŠTc@s ddlZddlZddlmZmZdefd„ƒYZdefd„ƒYZdefd„ƒYZd	efd
„ƒYZ	defd„ƒYZ
dS(
iÿÿÿÿN(tformat_deltatformat_percenttTimercBs>eZdZdd„Zd„Zd„Zd„Zd„ZRS(sp
    A timer keeps track of the number of seconds passed during it's
    lifetime and since the last reset.
    cCs1|ptj|_|jƒ|_|j|_dS(N(ttimet_create_timet_creation_timet
_last_time(tselftcreate_time((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyt__init__
scCs
|jƒS(N(R(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyRscCs|jƒ|jS(N(RR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytsince_startscCs|jƒ|jS(N(RR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytsince_resetscCs|jƒ|_dS(N(RR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytresetsN(	t__name__t
__module__t__doc__tNoneR	RR
RR(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyRs			tMonitorcBs5eZdZdd„Zd„Zd„Zd„ZRS(s«
    A monitor tracks the number of pings it received during it's
    lifetime and since the last reset.  The component being monitored
    is responsible for calling C{ping()} everytime a monitored
    activity occurs.  It should register a reactor event that logs
    statistics from this monitor every N seconds.  Essentially,
    monitors are just statistics checkers that components can use to
    monitor themselves.
    cCs8tt|ƒjd|ƒ||_d|_d|_dS(NRi(tsuperRR	t
event_nametcountttotal_count(RRR((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR	*s		cCs"|jd7_|jd7_dS(Ni(RR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytping0scCs tt|ƒjƒd|_dS(Ni(RRRR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR4scCs6tjd|j|jt|jƒƒƒ|jƒdS(Ns%%d %s events occurred in the last %s.(tloggingtinfoRRRRR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytlog8sN(R
RRRR	RRR(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyRs
			tBurstMonitorcBs,eZdZdd„Zd„Zd„ZRS(sš
    A burst monitor tracks the volume pings it receives.  It goes into
    warn mode when too many pings are received in a short period of
    time.
    cCs;tt|ƒj|d|ƒ||_||_g|_dS(NR(RRR	trepeat_intervalt
maximum_countt_last_times(RRRRR((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR	Es		cCs|tt|ƒjƒ|jƒ}|jj|ƒ|jd||jkset|jƒ|jdkrx|jj	dƒndS(Nii(
RRRRRtappendRtlenRtpop(Rtnow((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyRLscCsM|js
tS|jƒ|jd}||jkoLt|jƒ|jdkS(Nii(RtFalseRRRR(Rtdelta((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytwarnTs
	N(R
RRRR	RR$(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR>s	tCoverageMonitorcBsJeZdZdd„Zed„ƒZed„ƒZd„Zd„Z	RS(sÃ
    A coverage monitor tracks the volume of pings received since the
    last reset.  It has normal and warn states that are determined by
    calculating the number of expected pings since the last reset.  If
    the actual number of pings falls below the minimum required
    percent the monitor goes into warn mode.  The component being
    monitored should register a reactor event that logs statistics
    from this monitor every N seconds.
    cCs2tt|ƒj|d|ƒ||_||_dS(NR(RR%R	Rtmin_percent(RRR&RR((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR	gs	cCsB|jr|jrdS|jƒ}|s.dS|jt|jƒS(Ngð?(Rtexpected_countRtfloat(Rtelapsed_time((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pytpercentnscCst|jƒ|jƒS(N(tintRR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR'ysc	Cs‹d}|jr(|jr(|jd}ntj}|jƒrItj}n|d|j|j|jt|ƒt	|j
ƒƒƒ|jƒdS(Ngids9%d of %d expected %s events (%s) occurred in the last %s.(R*R'RRR$twarningRRRRRR(RR*R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR}s	cCs<|jr8|jr8|jstS|j|jkr8tSntS(N(RR&R'R"R*tTrue(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR$‹s	N(
R
RRRR	tpropertyR*R'RR$(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR%\s		tFrequencyMonitorcBsDeZdZdd„Zed„ƒZd„Zd„Zd„Z	RS(sz
    A frequency monitor tracks the number of pings received during a
    fixed period of time.  It has normal and warn states; a warn state
    is triggered when the minimum expected pings were not received
    during the specified interval.  The component being monitored
    should register a reactor event that checks the warn state of this
    monitor every N seconds.
    cCsAtt|ƒj|d|ƒ||_||_|jƒ|_dS(NR(RR/R	Rt
min_frequencyRt_last_count(RRR0RR((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR	žs
		cCs|jƒ|j}||jS(N(RR1R(Rt
since_ping((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR'¦scCs&tt|ƒjƒ|jƒ|_dS(N(RR/RRR1(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR«scCsH|jƒr:tjd|j|j|jt|jƒƒn|jƒdS(NsAOnly %d of %d minimum expected %s events occurred in the last %s.(	R$RR,RR'RRRR(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR¯s	cCsK|jrG|jrG|jƒ|j|jkrG|j|jkrGtSntS(N(RR0RR1RR-R"(R((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR$·s
N(
R
RRRR	R.R'RRR$(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyR/”s		(RRt
landscape.logRRtobjectRRRR%R/(((s9/usr/lib/python2.7/dist-packages/landscape/lib/monitor.pyt<module>s8