glances/exports/glances_opentsdb.py 1 location
|
@@ 36-59 (lines=24) @@
|
33 |
|
|
34 |
|
"""This class manages the OpenTSDB export module.""" |
35 |
|
|
36 |
|
def __init__(self, config=None, args=None): |
37 |
|
"""Init the OpenTSDB export IF.""" |
38 |
|
super(Export, self).__init__(config=config, args=args) |
39 |
|
|
40 |
|
# Mandatories configuration keys (additional to host and port) |
41 |
|
# N/A |
42 |
|
|
43 |
|
# Optionals configuration keys |
44 |
|
self.prefix = None |
45 |
|
self.tags = None |
46 |
|
|
47 |
|
# Load the InfluxDB configuration file |
48 |
|
self.export_enable = self.load_conf('opentsdb', |
49 |
|
mandatories=['host', 'port'], |
50 |
|
options=['prefix', 'tags']) |
51 |
|
if not self.export_enable: |
52 |
|
sys.exit(2) |
53 |
|
|
54 |
|
# Default prefix for stats is 'glances' |
55 |
|
if self.prefix is None: |
56 |
|
self.prefix = 'glances' |
57 |
|
|
58 |
|
# Init the OpenTSDB client |
59 |
|
self.client = self.init() |
60 |
|
|
61 |
|
def init(self): |
62 |
|
"""Init the connection to the OpenTSDB server.""" |
glances/exports/glances_cassandra.py 1 location
|
@@ 39-61 (lines=23) @@
|
36 |
|
|
37 |
|
"""This class manages the Cassandra/Scylla export module.""" |
38 |
|
|
39 |
|
def __init__(self, config=None, args=None): |
40 |
|
"""Init the Cassandra export IF.""" |
41 |
|
super(Export, self).__init__(config=config, args=args) |
42 |
|
|
43 |
|
# Mandatories configuration keys (additional to host and port) |
44 |
|
self.keyspace = None |
45 |
|
|
46 |
|
# Optionals configuration keys |
47 |
|
self.protocol_version = 3 |
48 |
|
self.replication_factor = 2 |
49 |
|
self.table = None |
50 |
|
|
51 |
|
# Load the Cassandra configuration file section |
52 |
|
self.export_enable = self.load_conf('cassandra', |
53 |
|
mandatories=['host', 'port', 'keyspace'], |
54 |
|
options=['protocol_version', |
55 |
|
'replication_factor', |
56 |
|
'table']) |
57 |
|
if not self.export_enable: |
58 |
|
sys.exit(2) |
59 |
|
|
60 |
|
# Init the Cassandra client |
61 |
|
self.cluster, self.session = self.init() |
62 |
|
|
63 |
|
def init(self): |
64 |
|
"""Init the connection to the InfluxDB server.""" |
glances/exports/glances_statsd.py 1 location
|
@@ 36-58 (lines=23) @@
|
33 |
|
|
34 |
|
"""This class manages the Statsd export module.""" |
35 |
|
|
36 |
|
def __init__(self, config=None, args=None): |
37 |
|
"""Init the Statsd export IF.""" |
38 |
|
super(Export, self).__init__(config=config, args=args) |
39 |
|
|
40 |
|
# Mandatories configuration keys (additional to host and port) |
41 |
|
# N/A |
42 |
|
|
43 |
|
# Optionals configuration keys |
44 |
|
self.prefix = None |
45 |
|
|
46 |
|
# Load the InfluxDB configuration file |
47 |
|
self.export_enable = self.load_conf('statsd', |
48 |
|
mandatories=['host', 'port'], |
49 |
|
options=['prefix']) |
50 |
|
if not self.export_enable: |
51 |
|
sys.exit(2) |
52 |
|
|
53 |
|
# Default prefix for stats is 'glances' |
54 |
|
if self.prefix is None: |
55 |
|
self.prefix = 'glances' |
56 |
|
|
57 |
|
# Init the Statsd client |
58 |
|
self.client = self.init() |
59 |
|
|
60 |
|
def init(self): |
61 |
|
"""Init the connection to the Statsd server.""" |
glances/exports/glances_couchdb.py 1 location
|
@@ 37-56 (lines=20) @@
|
34 |
|
"""This class manages the CouchDB export module.""" |
35 |
|
|
36 |
|
def __init__(self, config=None, args=None): |
37 |
|
"""Init the CouchDB export IF.""" |
38 |
|
super(Export, self).__init__(config=config, args=args) |
39 |
|
|
40 |
|
# Mandatories configuration keys (additional to host and port) |
41 |
|
self.db = None |
42 |
|
|
43 |
|
# Optionals configuration keys |
44 |
|
self.user = None |
45 |
|
self.password = None |
46 |
|
|
47 |
|
# Load the Cassandra configuration file section |
48 |
|
self.export_enable = self.load_conf('couchdb', |
49 |
|
mandatories=['host', 'port', 'db'], |
50 |
|
options=['user', 'password']) |
51 |
|
if not self.export_enable: |
52 |
|
sys.exit(2) |
53 |
|
|
54 |
|
# Init the CouchDB client |
55 |
|
self.client = self.init() |
56 |
|
|
57 |
|
def init(self): |
58 |
|
"""Init the connection to the CouchDB server.""" |
59 |
|
if not self.export_enable: |
glances/exports/glances_zeromq.py 1 location
|
@@ 36-55 (lines=20) @@
|
33 |
|
class Export(GlancesExport): |
34 |
|
|
35 |
|
"""This class manages the ZeroMQ export module.""" |
36 |
|
|
37 |
|
def __init__(self, config=None, args=None): |
38 |
|
"""Init the ZeroMQ export IF.""" |
39 |
|
super(Export, self).__init__(config=config, args=args) |
40 |
|
|
41 |
|
# Mandatories configuration keys (additional to host and port) |
42 |
|
self.prefix = None |
43 |
|
|
44 |
|
# Optionals configuration keys |
45 |
|
# N/A |
46 |
|
|
47 |
|
# Load the ZeroMQ configuration file section ([export_zeromq]) |
48 |
|
self.export_enable = self.load_conf('zeromq', |
49 |
|
mandatories=['host', 'port', 'prefix'], |
50 |
|
options=[]) |
51 |
|
if not self.export_enable: |
52 |
|
sys.exit(2) |
53 |
|
|
54 |
|
# Init the ZeroMQ context |
55 |
|
self.context = None |
56 |
|
self.client = self.init() |
57 |
|
|
58 |
|
def init(self): |
glances/exports/glances_rabbitmq.py 1 location
|
@@ 39-64 (lines=26) @@
|
36 |
|
|
37 |
|
"""This class manages the rabbitMQ export module.""" |
38 |
|
|
39 |
|
def __init__(self, config=None, args=None): |
40 |
|
"""Init the RabbitMQ export IF.""" |
41 |
|
super(Export, self).__init__(config=config, args=args) |
42 |
|
|
43 |
|
# Mandatories configuration keys (additional to host and port) |
44 |
|
self.user = None |
45 |
|
self.password = None |
46 |
|
self.queue = None |
47 |
|
|
48 |
|
# Optionals configuration keys |
49 |
|
# N/A |
50 |
|
|
51 |
|
# Load the rabbitMQ configuration file |
52 |
|
self.export_enable = self.load_conf('rabbitmq', |
53 |
|
mandatories=['host', 'port', |
54 |
|
'user', 'password', |
55 |
|
'queue'], |
56 |
|
options=[]) |
57 |
|
if not self.export_enable: |
58 |
|
sys.exit(2) |
59 |
|
|
60 |
|
# Get the current hostname |
61 |
|
self.hostname = socket.gethostname() |
62 |
|
|
63 |
|
# Init the rabbitmq client |
64 |
|
self.client = self.init() |
65 |
|
|
66 |
|
def init(self): |
67 |
|
"""Init the connection to the rabbitmq server.""" |
glances/exports/glances_influxdb.py 1 location
|
@@ 42-65 (lines=24) @@
|
39 |
|
"""This class manages the InfluxDB export module.""" |
40 |
|
|
41 |
|
def __init__(self, config=None, args=None): |
42 |
|
"""Init the InfluxDB export IF.""" |
43 |
|
super(Export, self).__init__(config=config, args=args) |
44 |
|
|
45 |
|
# Mandatories configuration keys (additional to host and port) |
46 |
|
self.user = None |
47 |
|
self.password = None |
48 |
|
self.db = None |
49 |
|
|
50 |
|
# Optionals configuration keys |
51 |
|
self.prefix = None |
52 |
|
self.tags = None |
53 |
|
|
54 |
|
# Load the InfluxDB configuration file |
55 |
|
self.export_enable = self.load_conf('influxdb', |
56 |
|
mandatories=['host', 'port', |
57 |
|
'user', 'password', |
58 |
|
'db'], |
59 |
|
options=['prefix', 'tags']) |
60 |
|
if not self.export_enable: |
61 |
|
sys.exit(2) |
62 |
|
|
63 |
|
# Init the InfluxDB client |
64 |
|
self.client = self.init() |
65 |
|
|
66 |
|
def init(self): |
67 |
|
"""Init the connection to the InfluxDB server.""" |
68 |
|
if not self.export_enable: |
glances/exports/glances_prometheus.py 1 location
|
@@ 39-58 (lines=20) @@
|
36 |
|
|
37 |
|
METRIC_SEPARATOR = '_' |
38 |
|
|
39 |
|
def __init__(self, config=None, args=None): |
40 |
|
"""Init the Prometheus export IF.""" |
41 |
|
super(Export, self).__init__(config=config, args=args) |
42 |
|
|
43 |
|
# Optionals configuration keys |
44 |
|
self.prefix = 'glances' |
45 |
|
|
46 |
|
# Load the Prometheus configuration file section |
47 |
|
self.export_enable = self.load_conf('prometheus', |
48 |
|
mandatories=['host', 'port'], |
49 |
|
options=['prefix']) |
50 |
|
if not self.export_enable: |
51 |
|
sys.exit(2) |
52 |
|
|
53 |
|
# Init the metric dict |
54 |
|
# Perhaps a better method is possible... |
55 |
|
self._metric_dict = {} |
56 |
|
|
57 |
|
# Init the Prometheus Exporter |
58 |
|
self.init() |
59 |
|
|
60 |
|
def init(self): |
61 |
|
"""Init the Prometheus Exporter""" |
glances/exports/glances_kafka.py 1 location
|
@@ 36-54 (lines=19) @@
|
33 |
|
|
34 |
|
"""This class manages the Kafka export module.""" |
35 |
|
|
36 |
|
def __init__(self, config=None, args=None): |
37 |
|
"""Init the Kafka export IF.""" |
38 |
|
super(Export, self).__init__(config=config, args=args) |
39 |
|
|
40 |
|
# Mandatories configuration keys (additional to host and port) |
41 |
|
self.topic = None |
42 |
|
|
43 |
|
# Optionals configuration keys |
44 |
|
self.compression = None |
45 |
|
|
46 |
|
# Load the Cassandra configuration file section |
47 |
|
self.export_enable = self.load_conf('kafka', |
48 |
|
mandatories=['host', 'port', 'topic'], |
49 |
|
options=['compression']) |
50 |
|
if not self.export_enable: |
51 |
|
sys.exit(2) |
52 |
|
|
53 |
|
# Init the kafka client |
54 |
|
self.client = self.init() |
55 |
|
|
56 |
|
def init(self): |
57 |
|
"""Init the connection to the Kafka server.""" |
glances/exports/glances_restful.py 1 location
|
@@ 36-55 (lines=20) @@
|
33 |
|
"""This class manages the Restful export module. |
34 |
|
Be aware that stats will be exported in one big POST request""" |
35 |
|
|
36 |
|
def __init__(self, config=None, args=None): |
37 |
|
"""Init the Restful export IF.""" |
38 |
|
super(Export, self).__init__(config=config, args=args) |
39 |
|
|
40 |
|
# Mandatories configuration keys (additional to host and port) |
41 |
|
self.protocol = None |
42 |
|
self.path = None |
43 |
|
|
44 |
|
# Load the Restful section in the configuration file |
45 |
|
self.export_enable = self.load_conf('restful', |
46 |
|
mandatories=['host', 'port', 'protocol', 'path']) |
47 |
|
if not self.export_enable: |
48 |
|
sys.exit(2) |
49 |
|
|
50 |
|
# Init the stats buffer |
51 |
|
# It's a dict of stats |
52 |
|
self.buffer = {} |
53 |
|
|
54 |
|
# Init the Statsd client |
55 |
|
self.client = self.init() |
56 |
|
|
57 |
|
def init(self): |
58 |
|
"""Init the connection to the restful server.""" |