Spamworldpro Mini Shell
Spamworldpro


Server : Apache/2.4.52 (Ubuntu)
System : Linux webserver 6.8.0-49-generic #49~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Wed Nov 6 17:42:15 UTC 2 x86_64
User : www-data ( 33)
PHP Version : 8.1.2-1ubuntu2.21
Disable Function : NONE
Directory :  /lib/python3/dist-packages/landscape/lib/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : //lib/python3/dist-packages/landscape/lib/__pycache__/monitor.cpython-310.pyc
o

���c��@s�ddlmZddlZddlZddlmZmZGdd�de�ZGdd�de�Z	Gdd	�d	e	�Z
Gd
d�de	�ZGdd
�d
e	�ZdS)�)�absolute_importN)�format_delta�format_percentc@s:eZdZdZd
dd�Zdd�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.
    NcCs"|ptj|_|��|_|j|_dS�N)�time�_create_time�_creation_time�
_last_time)�self�create_time�r
�7/usr/lib/python3/dist-packages/landscape/lib/monitor.py�__init__s
zTimer.__init__cCs|��Sr)r�rr
r
rrsz
Timer.timecC�|��|jSr)rr	rr
r
r�since_start�zTimer.since_startcCrr�rr
rr
r
r�since_resetrzTimer.since_resetcCs|��|_dSrrrr
r
r�resetrzTimer.resetr)	�__name__�
__module__�__qualname__�__doc__rrrrrr
r
r
rr	s
rcs>eZdZdZd�fdd�	Zdd�Z�fdd�Zd	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.
    Ncs(tt|�j|d�||_d|_d|_dS)N�rr)�superrr�
event_name�count�total_count)rrr��	__class__r
rr,s
zMonitor.__init__cCs |jd7_|jd7_dS)N�)rr rr
r
r�ping2szMonitor.pingcstt|���d|_dS)Nr)rrrrrr!r
rr6s
z
Monitor.resetcCs(t�d|j|jt|����|��dS)Nz%%d %s events occurred in the last %s.)�logging�inforrrrrrr
r
r�log:s
�zMonitor.logr)	rrrrrr$rr'�
__classcell__r
r
r!rr!s
rcs8eZdZdZ	d	�fdd�	Z�fdd�Zdd�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.
    Ncs*tt|�j||d�||_||_g|_dS�Nr)rr)r�repeat_interval�
maximum_count�_last_times)rr+r,rrr!r
rrGs
zBurstMonitor.__init__cs^tt|���|��}|j�|�|jd||jks%t|j�|jdkr-|j�	d�dSdS)Nrr#)
rr)r$rr-�appendr+�lenr,�pop)r�nowr!r
rr$Ns�zBurstMonitor.pingcCs:|jsdS|��|jd}||jkot|j�|jdkS)NFrr#)r-rr+r/r,)r�deltar
r
r�warnWs
�zBurstMonitor.warnr)rrrrrr$r3r(r
r
r!rr)@s�	r)csLeZdZdZ	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.
    Ncs$tt|�j||d�||_||_dSr*)rr4rr+�min_percent)rr+r5rrr!r
rrjs
�
zCoverageMonitor.__init__cCs(z	|jt|j�WStyYdSw)Ng�?)r�float�expected_count�ZeroDivisionErrorrr
r
r�percentqs
�zCoverageMonitor.percentcCst|��|j�Sr)�intrr+rr
r
rr7xszCoverageMonitor.expected_countc	Cs^d}|jr
|jr
|jd}tj}|��rtj}|d|j|j|jt|�t	|�
���|��dS)Ng�dz9%d of %d expected %s events (%s) occurred in the last %s.)r9r7r%r&r3�warningrrrrrr)rr9r'r
r
rr'|s
�zCoverageMonitor.logcCs*|jr|jr|jsdS|j|jkrdSdS)NFT)r+r5r7r9rr
r
rr3�szCoverageMonitor.warnr)rrrrr�propertyr9r7r'r3r(r
r
r!rr4_s�

r4csLeZdZdZ	d
�fdd�	Zedd��Z�fdd�Zd	d
�Zdd�Z	�Z
S)�FrequencyMonitoraz
    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.
    Ncs.tt|�j||d�||_||_|��|_dSr*)rr>rr+�
min_frequencyr�_last_count)rr+r?rrr!r
rr�s�zFrequencyMonitor.__init__cCs|��|j}||jSr)rr@r+)r�
since_pingr
r
rr7�s
zFrequencyMonitor.expected_countcstt|���|��|_dSr)rr>r$rr@rr!r
rr$�szFrequencyMonitor.pingcCs2|��rt�d|j|j|jt|j��|��dS)NzAOnly %d of %d minimum expected %s events occurred in the last %s.)	r3r%r<rr7rrr+rrr
r
rr'�s�zFrequencyMonitor.logcCs4|jr|jr|��|j|jkr|j|jkrdSdS)NTF)r+r?rr@rrr
r
rr3�s�zFrequencyMonitor.warnr)rrrrrr=r7r$r'r3r(r
r
r!rr>�s
�
r>)
�
__future__rr%r�landscape.lib.formatrr�objectrrr)r4r>r
r
r
r�<module>s4

Spamworldpro Mini