HEX
Server: LiteSpeed
System: Linux baran.dnsprotection.me 4.18.0-553.83.1.lve.el8.x86_64 #1 SMP Wed Nov 12 10:04:12 UTC 2025 x86_64
User: ddir12 (3618)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //usr/lib/python3.6/site-packages/glances/outputs/__pycache__/glances_stdout_apidoc.cpython-36.pyc
3

Eo�c��@s�dZddlmZddlZddlZddlmZddlmZdZ	dZ
dd	d
�Zdd�Zd
d�Z
dd�Zdd�Zdd�Zdd�Zdd�Zdd�ZGdd�de�ZdS)z#Fields description interface class.�)�pformatN)�logger)�	iteritemszhttp://localhost:61208/api/3a.. _api:

API (Restfull/JSON) documentation
=================================

The Glances Restfull/API server could be ran using the following command line:

.. code-block:: bash

    # glances -w --disable-webui

Note: Change request URL api/3 by api/2 if you use Glances 2.x.
�    cCspt|t�rLt|�dkrLt|dt�rL|t|dd��jdd|�jdd�S|t|�jdd|�jdd�SdS)N�r��
�'�")�
isinstance�list�len�dictr�replace)�stat�indent�r�+/usr/lib/python3.6/glances_stdout_apidoc.py�indent_stat%s$(rcCsrd}t|�tdt|��td�td�td�td�td�td�tdjt��ttd��td�dS)	NzGET API status�-�z8This entry point should be used to check the API status.z@It will return nothing but a 200 return code if everythin is OK.zGet the Rest API status::z    # curl -I {}/statuszHTTP/1.0 200 OK)�printr
�format�API_URLr)�	sub_titlerrr�print_api_status.srcCsZd}t|�tdt|��td�td�td�tdjt��tt|��td�dS)NzGET plugins listrrzGet the plugins list::z    # curl {}/pluginslist)rr
rrr)rrrrr�print_plugins_list=srcCsldj|�}t|�tdt|��td�td�td�tdjt|��tttj|j����td�dS)NzGET {}rrzGet plugin stats::z    # curl {}/{})rrr
rr�json�loadsZ	get_stats)�pluginrrrrr�print_plugin_statsIs
r cCs�|jrptd�td�xNt|j�D]@\}}tdj||djd�rP|ddd	�n|d|d��q"Wtd�ntjdj|��dS)
NzFields descriptions:rz* **{}**: {} (unit is *{}*)�description�.rZunitz4No fields_description variable defined for plugin {}���)Zfields_descriptionrrr�endswithr�error)rrZfieldr!rrr�print_plugin_descriptionVs
r&cCsVd}d}t|t�r(t|j��d}d}nRt|t�rzt|�dkrzt|dt�rzd|dkrf|dd}nt|dj��d}|r�|j|�r�tj|j|��}t||t�r�||d}n||}td�td�tdj	t
||��tt|��td�|�rR|�rR|j||��rRtd�td�tdj	t
|||��tttj|j||����td�dS)Nr�keyzGet a specific field::rz    # curl {}/{}/{}z7Get a specific item when field matchs the given value::z    # curl {}/{}/{}/{})
rrr�keysr
Zget_stats_itemrrrrrrZget_stats_value)rr�stat_export�item�valueZ	stat_itemrrr�print_plugin_item_valuejs2
$r,cCsVd}t|�tdt|��td�td�td�tdjt��td�td�dS)Nz
GET all statsrrzGet all Glances stats::z    # curl {}/allzZ    Return a very big dictionnary (avoid using this request, performances will be poor)...)rr
rr)rrrr�	print_all�sr-cCsdtjd�|j�tjd�|j�d}t|�tdt|��td�td�td�tdjt��tttj	|j
d�jdd	����td�td
�td�tdjt��tttj	|j
d�jdd	����td�td
�td�tdjt��tttj	|j
d�jd����td�td�td�tdjt��tttj	|j
d�jddd	����td�dS)NrzGET stats historyrrzHistory of a plugin::z    # curl {}/cpu/history�cpu�)Znbz Limit history to last 2 values::z    # curl {}/cpu/history/2rzHistory for a specific field::z     # curl {}/cpu/system/history�systemz5Limit history for a specific field to last 2 values::)�timeZsleep�updaterr
rrrrr�
get_pluginZget_stats_history)�statsrrrr�
print_history�s8

  "r5cCs�d}t|�tdt|��td�td�td�tdjt��tt|j���td�td�td�tdjt��tt|jd�j��td�dS)	Nz GET limits (used for thresholds)rrzAll limits/thresholds::z    # curl {}/all/limitsz&Limits/thresholds for the cpu plugin::z    # curl {}/cpu/limitsr.)rr
rrrZgetAllLimitsAsDictr3Zlimits)r4rrrr�print_limits�sr6c@s,eZdZdZd
dd�Zdd�Zddd	�ZdS)�GlancesStdoutApiDocz2This class manages the fields description display.NcCs||_||_dS)N)�config�args)�selfr8r9rrr�__init__�szGlancesStdoutApiDoc.__init__cCsdS)Nr)r:rrr�end�szGlancesStdoutApiDoc.endrcCs�tt�t�tt|j��x^t|j�D]P}|j|�}|j�}|dks(|gks(|ikrXq(t||�t	||�t
|||�q(Wt�t|�t
|�dS)z
Display issueNT)r�
APIDOC_HEADERrr�sortedZ_pluginsr3Z
get_exportr r&r,r-r5r6)r:r4Zdurationrrr)rrrr2�s


zGlancesStdoutApiDoc.update)NN)r)�__name__�
__module__�__qualname__�__doc__r;r<r2rrrrr7�s
r7)r)rB�pprintrrr1Zglances.loggerrZglances.compatrrr=rrrr r&r,r-r5r6�objectr7rrrr�<module>
s"