/usr/lib/python3.9/site-packages/glances/exports/__pycache__
a ���c � @ sX d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z ddl Z G dd� de �ZdS ) zRiemann interface class.� N)�Number)�range)�logger)� GlancesExportc s2 e Zd ZdZd � fdd� Zdd� Zdd� Z� ZS ) �Exportz-This class manages the Riemann export module.Nc sP t t| �j||d� | jdddgg d�| _| js8td� t�� | _| � � | _ dS )zInit the Riemann export IF.)�config�argsZriemann�host�port)Zmandatories�optionszMissing RIEMANN configN)�superr �__init__Z load_conf� export_enable�exit�socketZgethostname�hostname�init�client)�selfr r �� __class__� �C/usr/lib/python3.9/site-packages/glances/exports/glances_riemann.pyr s zExport.__init__c C s\ | j s dS ztj| j| jd�}|W S tyV } zt�d| � W Y d}~dS d}~0 0 dS )z*Init the connection to the Riemann server.N)r r z"Connection to Riemann failed : %s )r �bernhardZClientr r � Exceptionr Zcritical)r r �er r r r 0 s zExport.initc C s� t t|��D ]�}t|| t�s"qq| j|d || || d�}t�|� z| j�|� W q t y� } zt� d| � W Y d}~qd}~0 0 qdS )zWrite the points in Riemann.� )r ZserviceZmetricz#Cannot export stats to Riemann (%s)N)r �len� isinstancer r r �debugr �sendr �error)r �name�columnsZpoints�i�datar r r r �export; s z Export.export)NN)�__name__� __module__�__qualname__�__doc__r r r&