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__/process.cpython-310.pyc
o

���c��@slddlmZddlZddlZddlmZmZddlmZddlm	Z	ddl
mZGdd�de�Z
d	d
�ZdS)�)�absolute_importN)�	timedelta�datetime)�sysstats)�to_timestamp)�detect_jiffiesc@s.eZdZdZ		d
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).
    �/procNcCsH|dur
t����}|durt�|�}||_||_|pt�|_||_	dS)N)
r�	BootTimes�get_last_boot_timer�utcfromtimestamp�
_boot_time�	_proc_dirr�_jiffies_per_sec�_uptime)�self�proc_dir�jiffies�	boot_time�uptime�r�7/usr/lib/python3/dist-packages/landscape/lib/process.py�__init__s

zProcessInformation.__init__c	csL�t�|j�D]}zt|�}Wn	tyYqw|�|�}|r#|VqdS)z8Get process information for all processes on the system.N)�os�listdirr�int�
ValueError�get_process_info)r�filename�
process_id�process_inforrr�get_all_process_info s��
��z'ProcessInformation.get_all_process_infocCs�d}tj�|jt|��}d|i}�zttj�|d�d�}z|��}tj�|�d�d�}W|�	�n|�	�wttj�|d�d�}z�|D]y}|�dd	�}|dd
kr_|�
�p[|d	�
�|d<qD|ddkr}|d	�
�}	|	d
krs|	��}	|	d�d�|d<qD|ddkr�|d	��}
t
|
d�|d<qD|ddkr�|d	��}
t
|
d�|d<qD|ddkr�|d	��}
t
|
d�|d<nqDW|�	�n|�	�wttj�|d�d�}zV|����}t
|d�}t
|d�}t
|d�}
|jp�t��}t||
|||j�}||d<td||j�}|jdu�rt�d�W|�	�WdSt|j|�|d<W|�	�n|�	�wWnt�y;YdSwd|v�rZd|v�rZd|v�rZd|v�rZd|v�rZd|v�s\J�|S)a
        Parse the /proc/<pid>/cmdline and /proc/<pid>/status files for
        information about the running process with process_id.

        The /proc filesystem doesn't behave like ext2, open files can disappear
        during the read process.
        ��pid�cmdline�r�r�status�:��Name�name�StatezT (tracing stop)�ascii�state�Uid�uid�Gid�gid�VmSizezvm-size�stat��
�zpercent-cpuNz,Skipping process (PID %s) without boot time.z
start-time)r�path�joinr�str�open�readline�basename�split�close�strip�lower�encoder�readrr�
get_uptime�calculate_pcpurrr
�logging�warningr�IOError)rr�
cmd_line_name�process_dirr �file�cmd_line�line�partsr.�value_parts�
start_time�utime�stimer�pcpu�deltarrrr+s�
���
���
��z#ProcessInformation.get_process_info)r	NNN)�__name__�
__module__�__qualname__�__doc__rr!rrrrrrs
�rcCsBd}||}|||}|r|d||}ttt|d�d�d�S)ao
    Implement ps' algorithm to calculate the percentage cpu utilisation for a
    process.::

    unsigned long long total_time;   /* jiffies used by this process */
    unsigned pcpu = 0;               /* scaled %cpu, 99 means 99% */
    unsigned long long seconds;      /* seconds of process life */
    total_time = pp->utime + pp->stime;
    if(include_dead_children) total_time += (pp->cutime + pp->cstime);
    seconds = seconds_since_boot - pp->start_time / hertz;
    if(seconds) pcpu = (total_time * 100ULL / hertz) / seconds;
    if (pcpu > 99U) pcpu = 99U;
    return snprintf(outbuf, COLWID, "%2u", pcpu);
    r�dg�X@r))�round�max�min)rQrRrrP�hertzrS�
total_time�secondsrrrrE�srE)�
__future__rrFrrr�
landscape.libr�landscape.lib.timestampr�landscape.lib.jiffiesr�objectrrErrrr�<module>sz

Spamworldpro Mini