/usr/lib/python3/dist-packages/landscape/lib/__pycache__
Edit: /usr/lib/python3/dist-packages/landscape/lib/__pycache__/monitor.cpython-310.pyc (7200B)
o
c @ s d dl mZ d dlZd dlZd dlmZmZ G dd deZG dd deZ G dd d e Z
G d
d de ZG dd
d
e ZdS ) )absolute_importN)format_deltaformat_percentc @ s: e Zd ZdZd
ddZdd Zdd Zd d
Zdd ZdS )Timerzp
A timer keeps track of the number of seconds passed during it's
lifetime and since the last reset.
Nc C s" |pt j | _| | _| j| _d S N)time_create_time_creation_time
_last_time)selfcreate_time r
7/usr/lib/python3/dist-packages/landscape/lib/monitor.py__init__ s
zTimer.__init__c C s | S r )r r r
r
r r s z
Timer.timec C | | j S r )r r r r
r
r since_start zTimer.since_startc C r r r r
r r
r
r since_reset r zTimer.since_resetc C s | | _d S r r r r
r
r reset r zTimer.resetr ) __name__
__module____qualname____doc__r r r r r r
r
r
r r s
r c s> e Zd ZdZd fdd Zdd Z fddZd d
Z ZS )Monitora
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.
Nc s( t t| j|d || _d| _d| _d S )Nr r )superr r
event_namecounttotal_count)r r r __class__r
r r , s
zMonitor.__init__c C s | j d7 _ | jd7 _d S )N )r r r r
r
r ping2 s zMonitor.pingc s t t| d| _d S )Nr )r r r r r r! r
r r 6 s
z
Monitor.resetc C s( t d| j| jt| | d S )Nz%%d %s events occurred in the last %s.)logginginfor r r r r r r
r
r log: s
zMonitor.logr ) r r r r r r$ r r'
__classcell__r
r
r! r r ! s
r c s8 e Zd ZdZ d fdd Z fddZdd Z ZS )
BurstMonitorz
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.
Nc s* t t| j||d || _|| _g | _d S Nr )r r) r repeat_interval
maximum_count_last_times)r r+ r, r r r! r
r r G s
zBurstMonitor.__init__c s^ t t| | }| j| | jd | | jks%t| j| jd kr-| j d d S d S )Nr r# )
r r) r$ r r- appendr+ lenr, pop)r nowr! r
r r$ N s zBurstMonitor.pingc C s: | j sdS | | j d }|| jk ot| j | jd kS )NFr r# )r- r r+ r/ r, )r deltar
r
r warnW s
zBurstMonitor.warnr )r r r r r r$ r3 r( r
r
r! r r) @ s r) c sL e Zd ZdZ d
fdd Zedd Zedd Zd d
Zdd Z Z
S )CoverageMonitora
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.
Nc s$ t t| j||d || _|| _d S r* )r r4 r r+ min_percent)r r+ r5 r r r! r
r r j s
zCoverageMonitor.__init__c C s( z | j t| j W S ty Y dS w )Ng ?)r floatexpected_countZeroDivisionErrorr r
r
r percentq s
zCoverageMonitor.percentc C s t | | j S r )intr r+ r r
r
r r7 x s zCoverageMonitor.expected_countc C s^ d}| j r
| jr
| j d }tj}| rtj}|d| j| j| jt|t |
| d S )Ng d z9%d of %d expected %s events (%s) occurred in the last %s.)r9 r7 r% r&