File: //usr/lib/python3.6/site-packages/glances/exports/__pycache__/glances_riemann.cpython-36.opt-1.pyc
3
Eo�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� tj� | _| j � | _
dS )zInit the Riemann export IF.)�config�argsZriemann�host�port)ZmandatoriesZoptionszMissing RIEMANN configN)�superr �__init__Z load_conf�
export_enable�exit�socketZgethostname�hostname�init�client)�selfr r )� __class__� �%/usr/lib/python3.6/glances_riemann.pyr s
zExport.__init__c C sT | j s
dS ytj| j| jd�}|S tk
rN } ztjd| � dS d}~X nX 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� x�t t|��D ]�}t|| t�s$qq| j|d || || d�}tj|� y| jj|� W q t k
r� } ztj
d| � W Y dd}~X qX qW dS )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$ �
__classcell__r r )r r r s r )r( r Znumbersr Zglances.compatr Zglances.loggerr Zglances.exports.glances_exportr r r r r r r �<module>
s