관리-도구
편집 파일: resource_limits.cpython-311.pyc
� IMg+ � � � d dl Z d dlZd dlmZ d dlmZ d dlmZ d dlm Z d dl mZ ej e � � ZdZ ed� � Z ed � � Z G d � de� � Zdefd �Zde e dededede j j f d�Zdefd�Zdefd�ZdS )� N)�Enum)�fsdecode)�Path)�List)� OsReleaseInfoz/usr/libexec/run-with-intensityz/usr/sbin/lvectlz/proc/lve/listc � � e Zd ZdZdZdZdS )�LimitsMethod�nice�lve�cgroupsN)�__name__� __module__�__qualname__�NICE�LVE�CGROUPS� � �Z/opt/imunify360/venv/lib/python3.11/site-packages/defence360agent/utils/resource_limits.pyr r s � � � � � ��D� �C��G�G�Gr r �returnc � �� K � t j t dt j j t j j �� � � d{V ��} | � � � � d{V ��\ }}t |� � � � � }|dk rt j S |dk rt j S |dk rt j S t d� |t |� � � � � � � � � �)z6Returns limit method, used in run-with-intensity tool.�show)�stdout�stderrNr r r z>Parsing of used limitation method failed stdout: {} stderr: {})�asyncio�create_subprocess_exec�RUN_WITH_INTENSITY� subprocess�PIPE�communicater �stripr r r r �LookupError�format)�procr r s r �get_current_methodr% s � � � ��/����!�&��!�&� � � � � � � � � �D� �+�+�-�-�-�-�-�-�-�-�N�F�F� �f� � � #� #� %� %�F� ����� � � ������� �����#�#� �J� �����(�(�.�.�0�0� 1� 1�� � r �cmd�key� intensity_cpu�intensity_ioc � � K � t ddt |� � dt |� � g}|� d|g� � t j || z i |��� d{V ��S )aS Creates asyncio.Process with limited resources (cpu & io), using run-with-intensity tool. :param cmd: command to execute :param intensity_cpu: cpu intensity limit :param intensity_io: io intensity limit :param subprocess_kwargs: keyword arguments for create_subprocess_exec func :return: executed Process �runz--intensity-cpuz--intensity-ioz--keyN)r �str�extendr r )r&