How to use the glances.exports.glances_export.GlancesExport function in Glances

To help you get started, we’ve selected a few Glances examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github nicolargo / glances / glances / exports / glances_prometheus.py View on Github external
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""Prometheus interface class."""

import sys
from numbers import Number

from glances.logger import logger
from glances.exports.glances_export import GlancesExport
from glances.compat import iteritems, listkeys

from prometheus_client import start_http_server, Gauge


class Export(GlancesExport):

    """This class manages the Prometheus export module."""

    METRIC_SEPARATOR = '_'

    def __init__(self, config=None, args=None):
        """Init the Prometheus export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Load the Prometheus configuration file section
        self.export_enable = self.load_conf('prometheus',
                                            mandatories=['host', 'port', 'labels'],
                                            options=['prefix'])
        if not self.export_enable:
            sys.exit(2)
github nicolargo / glances / glances / exports / glances_json.py View on Github external
"""JSON interface class."""

import sys
import json

from glances.compat import PY3, listkeys
from glances.logger import logger
from glances.exports.glances_export import GlancesExport


class Export(GlancesExport):

    """This class manages the JSON export module."""

    def __init__(self, config=None, args=None):
        """Init the JSON export IF."""
        super(Export, self).__init__(config=config, args=args)

        # JSON file name
        self.json_filename = args.export_json_file

        # Set the JSON output file
        try:
            if PY3:
                self.json_file = open(self.json_filename, 'w')
            else:
                self.json_file = open(self.json_filename, 'wb')
github nicolargo / glances / glances / exports / glances_riemann.py View on Github external
"""Riemann interface class."""

import socket
import sys
from numbers import Number

from glances.compat import range
from glances.logger import logger
from glances.exports.glances_export import GlancesExport

# Import bernhard for Riemann
import bernhard


class Export(GlancesExport):

    """This class manages the Riemann export module."""

    def __init__(self, config=None, args=None):
        """Init the Riemann export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        # N/A

        # Optionals configuration keys
        # N/A

        # Load the Riemann configuration
        self.export_enable = self.load_conf('riemann',
                                            mandatories=['host', 'port'],
github nicolargo / glances / glances / exports / glances_rabbitmq.py View on Github external
"""JMS interface class."""

import datetime
import socket
import sys
from numbers import Number

from glances.compat import range
from glances.logger import logger
from glances.exports.glances_export import GlancesExport

# Import pika for RabbitMQ
import pika


class Export(GlancesExport):

    """This class manages the rabbitMQ export module."""

    def __init__(self, config=None, args=None):
        """Init the RabbitMQ export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.user = None
        self.password = None
        self.queue = None

        # Optionals configuration keys
        # N/A

        # Load the rabbitMQ configuration file
github nicolargo / glances / glances / exports / glances_kafka.py View on Github external
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""Kafka interface class."""

import sys

from glances.logger import logger
from glances.compat import iteritems
from glances.exports.glances_export import GlancesExport

from kafka import KafkaProducer
import json


class Export(GlancesExport):

    """This class manages the Kafka export module."""

    def __init__(self, config=None, args=None):
        """Init the Kafka export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.topic = None

        # Optionals configuration keys
        self.compression = None

        # Load the Kafka configuration file section
        self.export_enable = self.load_conf('kafka',
                                            mandatories=['host', 'port', 'topic'],
github nicolargo / glances / glances / exports / glances_csv.py View on Github external
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""CSV interface class."""

import os.path
import csv
import sys
import time

from glances.compat import PY3, iterkeys, itervalues
from glances.logger import logger
from glances.exports.glances_export import GlancesExport


class Export(GlancesExport):

    """This class manages the CSV export module."""

    def __init__(self, config=None, args=None):
        """Init the CSV export IF."""
        super(Export, self).__init__(config=config, args=args)

        # CSV file name
        self.csv_filename = args.export_csv_file

        # Set the CSV output file
        # (see https://github.com/nicolargo/glances/issues/1525)
        if not os.path.isfile(self.csv_filename) or args.export_csv_overwrite:
            # File did not exist, create it
            file_mode = 'w'
            self.old_header = None
github nicolargo / glances / glances / exports / glances_couchdb.py View on Github external
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""CouchDB interface class."""

import sys
from datetime import datetime

from glances.logger import logger
from glances.exports.glances_export import GlancesExport

import couchdb
import couchdb.mapping


class Export(GlancesExport):

    """This class manages the CouchDB export module."""

    def __init__(self, config=None, args=None):
        """Init the CouchDB export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.db = None

        # Optionals configuration keys
        self.user = None
        self.password = None

        # Load the Cassandra configuration file section
        self.export_enable = self.load_conf('couchdb',
github nicolargo / glances / glances / exports / glances_zeromq.py View on Github external
# along with this program. If not, see .

"""ZeroMQ interface class."""

import sys
import json

from glances.compat import b
from glances.logger import logger
from glances.exports.glances_export import GlancesExport

import zmq
from zmq.utils.strtypes import asbytes


class Export(GlancesExport):

    """This class manages the ZeroMQ export module."""

    def __init__(self, config=None, args=None):
        """Init the ZeroMQ export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.prefix = None

        # Optionals configuration keys
        # N/A

        # Load the ZeroMQ configuration file section ([export_zeromq])
        self.export_enable = self.load_conf('zeromq',
                                            mandatories=['host', 'port', 'prefix'],
github nicolargo / glances / glances / exports / glances_restful.py View on Github external
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""RESTful interface class."""

import sys

from glances.compat import listkeys
from glances.logger import logger
from glances.exports.glances_export import GlancesExport

from requests import post


class Export(GlancesExport):

    """This class manages the RESTful export module.
    Be aware that stats will be exported in one big POST request"""

    def __init__(self, config=None, args=None):
        """Init the RESTful export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.protocol = None
        self.path = None

        # Load the RESTful section in the configuration file
        self.export_enable = self.load_conf('restful',
                                            mandatories=['host', 'port', 'protocol', 'path'])
        if not self.export_enable:
github nicolargo / glances / glances / exports / glances_influxdb.py View on Github external
#
# You should have received a copy of the GNU Lesser General Public License
# along with this program. If not, see .

"""InfluxDB interface class."""

import sys

from glances.logger import logger
from glances.exports.glances_export import GlancesExport

from influxdb import InfluxDBClient
from influxdb.client import InfluxDBClientError


class Export(GlancesExport):
    """This class manages the InfluxDB export module."""

    def __init__(self, config=None, args=None):
        """Init the InfluxDB export IF."""
        super(Export, self).__init__(config=config, args=args)

        # Mandatories configuration keys (additional to host and port)
        self.user = None
        self.password = None
        self.db = None

        # Optionals configuration keys
        self.protocol = 'http'
        self.prefix = None
        self.tags = None