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/exports/__pycache__/glances_prometheus.cpython-36.pyc
3

Eo�c��@sddZddlZddlmZddlmZddlmZddlm	Z	m
Z
ddlmZm
Z
Gdd	�d	e�ZdS)
zPrometheus interface class.�N)�Number)�logger)�
GlancesExport)�	iteritems�listkeys)�start_http_server�Gaugecs6eZdZdZdZd
�fdd�	Zdd�Zdd	�Z�ZS)�Exportz0This class manages the Prometheus export module.�_Ncsntt|�j||d�|jddddgdgd�|_|js<td�|jd	krLd
|_|jd	kr\d|_i|_|j	�d	S)zInit the Prometheus export IF.)�config�argsZ
prometheus�host�port�labels�prefix)ZmandatoriesZoptionszMissing PROMETHEUS configNZglanceszsrc:glances)
�superr	�__init__Z	load_confZ
export_enable�exitrr�_metric_dict�init)�selfrr)�	__class__��(/usr/lib/python3.6/glances_prometheus.pyrs

zExport.__init__cCsxytt|j�|jd�WnDtk
r\}z(tjdj|j|j|��tj	d�WYdd}~XnXtj
dj|j|j��dS)zInit the Prometheus Exporter)rZaddrz/Can not start Prometheus exporter on {}:{} ({})�Nz"Start Prometheus exporter on {}:{})r�intrr
�	ExceptionrZcritical�format�sysr�info)r�errrr3szExport.initc
Cs�tjdj|��dd�ttt||���D�}x�t|�D]�\}}|j|jt|�|jt|�}xdD]}|j	||j�}qfW|j
|j�}	||jkr�t
||t|	�d�|j|<t|j|d	�r�|j|jf|	�j|�q6|j|j|�q6Wd
S)z8Write the points to the Prometheus exporter using Gauge.z&Export {} stats to Prometheus exportercSs$i|]\}}t|t�rt|�|�qSr)�
isinstancer�float)�.0�k�vrrr�
<dictcomp>Bsz!Export.export.<locals>.<dictcomp>�.�-�/� )Z
labelnamesrN)r'r(r)r*)r�debugrr�dict�zipr�METRIC_SEPARATOR�str�replaceZ
parse_tagsrrrr�hasattr�set)
r�name�columnsZpoints�datar$r%Zmetric_name�crrrr�export=s"

z
Export.export)NN)	�__name__�
__module__�__qualname__�__doc__r.rrr7�
__classcell__rr)rrr	s

r	)r;rZnumbersrZglances.loggerrZglances.exports.glances_exportrZglances.compatrrZprometheus_clientrrr	rrrr�<module>
s