File: //usr/lib/python3.6/site-packages/glances/exports/__pycache__/glances_influxdb2.cpython-36.pyc
3
Eo�cL � @ sT d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z m
Z
G dd� de�ZdS ) z1InfluxDB (from to InfluxDB 1.8+) interface class.� N)�node)�logger)�
GlancesExport)�InfluxDBClient�WriteOptionsc s: e Zd ZdZd� fdd� Zdd� Zdd� Zd d
� Z� ZS )�Exportz.This class manages the InfluxDB export module.Nc s� t t| �j||d� d| _d| _d| _d| _d| _d| _d| _ | j
dddddd d
dgdd
dgd�| _| jsrtd� t
� jd�d | _ | j� | _dS )zInit the InfluxDB export IF.)�config�argsNZhttpZ influxdb2�host�port�userZpassword�org�bucket�token�protocol�prefix�tags)ZmandatoriesZoptionsz!Missing INFLUXDB version 1 config�.r )�superr �__init__r
r r r r r �hostnameZ load_conf�
export_enable�exitr �split�init�client)�selfr r )� __class__� �'/usr/lib/python3.6/glances_influxdb2.pyr s zExport.__init__c C s� | j s
dS dj| j| j| j�}yt|dd| j| jd�}W n> tk
rv } z"t j
d||f � tjd� W Y dd}~X n X t j
dj|j� j|j� j�� |jtdd d
ddd
dd�d�}|S )z+Init the connection to the InfluxDB server.Nz
{}://{}:{}F)�urlZenable_gzipZ
verify_sslr
r z+Cannot connect to InfluxDB server '%s' (%s)� z,Connected to InfluxDB server version {} ({})i� i'