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_opentsdb.cpython-36.pyc
3

Eo�c�	�@sXdZddlZddlmZddlmZddlmZddlm	Z	ddl
Z
Gdd�de	�ZdS)	zOpenTSDB interface class.�N)�Number)�range)�logger)�
GlancesExportcs>eZdZdZd�fdd�	Zdd�Zdd�Z�fd	d
�Z�ZS)�Exportz.This class manages the OpenTSDB export module.Ncsftt|�j||d�d|_d|_|jdddgddgd�|_|jsHtd	�|jdkrXd
|_|j�|_	dS)zInit the OpenTSDB export IF.)�config�argsNZopentsdb�host�port�prefix�tags)ZmandatoriesZoptionszMissing OPENTSDB configZglances)
�superr�__init__rrZ	load_conf�
export_enable�exit�init�client)�selfrr)�	__class__��&/usr/lib/python3.6/glances_opentsdb.pyrs
zExport.__init__cCsp|js
dSytj|jt|j�dd�}WnDtk
rj}z(tjd|j|j|f�t	j
d�WYdd}~XnX|S)z+Init the connection to the OpenTSDB server.NT)r
Z
check_hostz,Cannot connect to OpenTSDB server %s:%s (%s)�)r�potsdbZClientr	�intr
�	ExceptionrZcritical�sysr)rZdb�errrr1szExport.initc	Cs�x�tt|��D]�}t||t�s"qdj|j|||�}||}|j|j�}y|jj	||f|�Wqt
k
r�}ztjd||f�WYdd}~XqXqWtj
dj|��dS)z&Export the stats to the Statsd server.z{}.{}.{}z(Can not export stats %s to OpenTSDB (%s)NzExport {} stats to OpenTSDB)r�len�
isinstancer�formatrZ
parse_tagsrr�sendrr�error�debug)	r�name�columnsZpoints�iZ	stat_nameZ
stat_valuerrrrr�export>s(z
Export.exportcs|jj�tt|�j�dS)z!Close the OpenTSDB export module.N)r�waitr
rr)r)rrrrLs
zExport.exit)NN)	�__name__�
__module__�__qualname__�__doc__rrr&r�
__classcell__rr)rrrs

r)r+rZnumbersrZglances.compatrZglances.loggerrZglances.exports.glances_exportrrrrrrr�<module>
s