← Back
Editing: process.cpython-38.pyc
U ���c� � @ sl d dl mZ d dlZd dlZd dlmZmZ d dlmZ d dlm Z d dl mZ G dd� de�Z d d � ZdS )� )�absolute_importN)� timedelta�datetime)�sysstats)�to_timestamp)�detect_jiffiesc @ s* e Zd ZdZd dd�Zdd� Zdd � ZdS )�ProcessInformationaI @param proc_dir: The directory to use for process information. @param jiffies: The value to use for jiffies per second. @param boot_time: An alternate value to use for the last boot time. If None, the system last boot time will be used. @param uptime: The uptime value to use (for unit tests only). �/procNc C sH |d krt �� �� }|d k r&t�|�}|| _|| _|p:t� | _|| _ d S )N) r Z BootTimesZget_last_boot_timer Zutcfromtimestamp� _boot_time� _proc_dirr �_jiffies_per_sec�_uptime)�selfZproc_dirZjiffiesZ boot_time�uptime� r �7/usr/lib/python3/dist-packages/landscape/lib/process.py�__init__ s zProcessInformation.__init__c c sP t �| j�D ]>}zt|�}W n tk r4 Y qY nX | �|�}|r|V qdS )z8Get process information for all processes on the system.N)�os�listdirr �int� ValueError�get_process_info)r �filename� process_id�process_infor r r �get_all_process_info s z'ProcessInformation.get_all_process_infoc C s� d}t j�| jt|��}d|i}�z*tt j�|d�d�}z"|�� }t j�|� d�d �}W 5 |�� X tt j�|d�d�}�z|D ]�}|� dd �}|d d kr�|� � p�|d � � |d<