pyc • Lines: 623�
�j^B � �� � d Z ddlZddlZddlZddlmZ ddlZddlmZ ddd�Zd� Z d � Z
d
� Zd#d�Zd� Z
d$d
�Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zd� Zddd�Zd� Zd� Zd� Zd� Zd � Zda da!d!� Z"d"� Z#y)%a� Health monitoring, server lifecycle and the background maintenance loops.
Two llama-server processes run concurrently on separate ports:
* the **GPU** server on ``LLAMA_BASE`` (8081) for interactive chat UI users, and
* the **CPU** server on ``LLAMA_BASE_CPU`` (8079) for automated self-chat
agents.
Each is started, killed, health-checked and idle-unloaded independently so an
agent run never disturbs interactive users (and vice versa).
� N)�datetime)�M�8081�8079��gpu�cpuc �� � t j 5 t j t j t j t j
t j d�cd d d � S # 1 sw Y y xY w)N)�model�predicted_per_second�
overheated�gpu_temp�ram_evacuating)r �
_data_lock�model_status� _last_tps�_overheated� _gpu_temp�_ram_evacuating� � �7/home/palash/git/local-ai/server/features/monitoring.py�model_status_snapshotr sH � �
���
��^�^�$%�K�K��-�-�����/�/�
�
�
�
�s �AA)�)A2c � � t j g d�ddd�� } t | j j � � S # t
$ r Y y w xY w)N)z
nvidia-smiz--query-gpu=temperature.gpuz--format=csv,noheaderT� ��capture_output�text�timeout)�
subprocess�run�int�stdout�strip� Exception)�rs r �get_gpu_tempr' % sK � � ��N�N�R����
�� �1�8�8�>�>�#�$�$��� ���s �=A � A�Ac � � t j ddgddd�� } | j j � j d� }|d j � }t |d � }t |d � }||z
|z d z S # t $ r Y y w xY w)
N�freez-mTr r �
� � �d )r r! r# r$ �splitr"