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_kafka.cpython-36.opt-1.pyc
3

Eo�c)�@sPdZddlZddlmZddlmZddlmZddlm	Z	Gdd�de�Z
dS)	zKafka interface class.�N)�logger)�
GlancesExport)�
json_dumps)�
KafkaProducercs>eZdZdZd�fdd�	Zdd�Zdd�Z�fd	d
�Z�ZS)�Exportz+This class manages the Kafka export module.Ncs^tt|�j||d�d|_d|_d|_|jddddgddgd	�|_|jsPtd
�|j	�|_
dS)zInit the Kafka export IF.)�config�argsN�kafka�host�port�topic�compression�tags)ZmandatoriesZoptionszMissing KAFKA config)�superr�__init__rr
rZ	load_conf�
export_enable�exit�init�client)�selfrr)�	__class__��#/usr/lib/python3.6/glances_kafka.pyrszExport.__init__cCs�|js
dSdj|j|j�}yt|dd�|jd�}Wn>tk
rp}z"tjd||f�t	j
d�WYdd}~XnXtjd|�|S)	z(Init the connection to the Kafka server.Nz{}:{}cSst|�jd�S)Nzutf-8)r�encode)�vrrr�<lambda>9szExport.init.<locals>.<lambda>)Zbootstrap_serversZvalue_serializerZcompression_typez&Cannot connect to Kafka server %s (%s)�z Connected to the Kafka server %s)r�formatr
rrr
�	ExceptionrZcritical�sysr�info)rZ
server_uri�s�errrr.szExport.initcCs�tjdj|��tt||��}|jdk	r:|j|j|j��y|jj	|j
|jd�|d�Wn4tk
r�}ztj
dj||��WYdd}~XnXdS)z%Write the points to the kafka server.zExport {} stats to KafkaNzutf-8)�key�valuez$Cannot export {} stats to Kafka ({}))r�debugr�dict�zipr�updateZ
parse_tagsr�sendrrr�error)r�name�columnsZpoints�datar"rrr�exportDs
z
Export.exportcs&|jj�|jj�tt|�j�dS)zClose the Kafka export module.N)r�flush�closerrr)r)rrrrZs

zExport.exit)NN)	�__name__�
__module__�__qualname__�__doc__rrr.r�
__classcell__rr)rrrs
r)r4rZglances.loggerrZglances.exports.glances_exportrZglances.globalsrr	rrrrrr�<module>
s