File: //lib/python3.6/site-packages/glances/exports/__pycache__/glances_prometheus.cpython-36.opt-1.pyc
3
Eo�c� � @ sd d Z ddlZddlmZ ddlmZ ddlmZ ddlm Z m
Z
ddlmZm
Z
G dd � d e�ZdS )
zPrometheus interface class.� N)�Number)�logger)�
GlancesExport)� iteritems�listkeys)�start_http_server�Gaugec s6 e Zd ZdZdZd
� fdd� Zdd� Zdd � Z� ZS )�Exportz0This class manages the Prometheus export module.�_Nc sn t t| �j||d� | jddddgdgd�| _| js<td� | jd krLd
| _| jd kr\d| _i | _| j � d S )zInit the Prometheus export IF.)�config�argsZ
prometheus�host�port�labels�prefix)ZmandatoriesZoptionszMissing PROMETHEUS configNZglanceszsrc:glances)
�superr �__init__Z load_confZ
export_enable�exitr r �_metric_dict�init)�selfr r )� __class__� �(/usr/lib/python3.6/glances_prometheus.pyr s
zExport.__init__c C sx yt t| j�| jd� W nD tk
r\ } z(tjdj| j| j|�� tj d� W Y dd}~X nX tj
dj| j| j�� dS )zInit the Prometheus Exporter)r Zaddrz/Can not start Prometheus exporter on {}:{} ({})� Nz"Start Prometheus exporter on {}:{})r �intr r
� Exceptionr Zcritical�format�sysr �info)r �er r r r 3 s zExport.initc
C s� t jdj|�� dd� ttt||���D �}x�t|�D ]�\}}| j| j t|� | j t|� }xdD ]}|j || j�}qfW | j
| j�} || jkr�t
||t| �d�| j|<