관리-도구
편집 파일: health.cpython-311.pyc
� IMg� � �f � d Z ddlZ ej dddg� � Z G d� d� � Z e� � ZdS )a� This module implements health status reporting for watchdog operation. Module receive important health metrics and exports its status of overall health assessment. This health assessment can be used by external watchdog scripts to initiate agent restart. Process is considered "healthy" if: * it is being shut down and shutdown timeout has not elapsed -> HEALTHY * it is not registered -> HEALTHY * process was started more than 6 hours ago and no data was sent to server within last 6 hours -> FAULTY * process was started more than 18 hours ago and no data was received from server within last 18 hours -> FAULTY Otherwise process is considered HEALTHY. As agent exports this information through RPC interface there is an additional implicit "health" requirement that: * it responds to RPC requests. This implicit requirement considered valid because UI fully depends on RPC so it does not make health assessment any worse than it should.� N�HealthStatus�healthy�whyc � � e Zd ZdZdZdZdZd� Zdeddfd �Z deddfd �Z deddfd�Zdeddfd�Zdd �Z dd�Zdedefd�ZdS )�HealthSensora� HealthSensor receives events about agent operation and provides information about overall status. Initially, new HealthSensor object assumes: * process was started long ago; * process is not being shut down; * data from server has been received long ago; * data to server was sent long ago; * agent is registered (license is valid). So, initial health status is False (faulty).i � i`T iX c �L � d| _ d| _ d| _ d| _ d| _ d S )Ng T)�_started_at�_shutdown_at�_last_received� _last_sent�_is_registered��selfs �O/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/api/health.py�__init__zHealthSensor.__init__1 s/ � �������!������"����� �when�returnNc � � || _ dS )z!Records a moment of agent startupN)r �r r s r �startingzHealthSensor.starting8 s � �����r c � � || _ dS )z7Records a moment of externally initiated agent shutdownN)r r s r � shutting_downzHealthSensor.shutting_down<