mirror of https://github.com/nicolargo/glances
Change exit message when export plugin init failed
parent
2ffb54a291
commit
9aaf620e2f
|
@ -546,7 +546,7 @@ queue=glances_queue
|
|||
[mqtt]
|
||||
# Configuration for the --export mqtt option
|
||||
host=localhost
|
||||
port=8883
|
||||
port=1883
|
||||
tls=true
|
||||
user=guest
|
||||
password=guest
|
||||
|
|
|
@ -42,7 +42,7 @@ class Export(GlancesExport):
|
|||
'influxdb', mandatories=['host', 'port', 'user', 'password', 'db'], options=['protocol', 'prefix', 'tags']
|
||||
)
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing INFLUXDB version 1 config')
|
||||
|
||||
# The hostname is always add as a tag
|
||||
self.hostname = node().split('.')[0]
|
||||
|
|
|
@ -43,7 +43,7 @@ class Export(GlancesExport):
|
|||
options=['protocol', 'prefix', 'tags'],
|
||||
)
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing INFLUXDB version 1 config')
|
||||
|
||||
# The hostname is always add as a tag
|
||||
self.hostname = node().split('.')[0]
|
||||
|
|
|
@ -40,7 +40,7 @@ class Export(GlancesExport):
|
|||
'kafka', mandatories=['host', 'port', 'topic'], options=['compression', 'tags']
|
||||
)
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing KAFKA config')
|
||||
|
||||
# Init the kafka client
|
||||
self.client = self.init()
|
||||
|
|
|
@ -12,6 +12,7 @@
|
|||
import socket
|
||||
import string
|
||||
import json
|
||||
import sys
|
||||
|
||||
from glances.logger import logger
|
||||
from glances.exports.glances_export import GlancesExport
|
||||
|
@ -53,10 +54,12 @@ class Export(GlancesExport):
|
|||
self.topic_structure = (self.topic_structure or 'per-metric').lower()
|
||||
if self.topic_structure not in ['per-metric', 'per-plugin']:
|
||||
logger.critical("topic_structure must be either 'per-metric' or 'per-plugin'.")
|
||||
return None
|
||||
sys.exit(2)
|
||||
|
||||
# Init the MQTT client
|
||||
self.client = self.init()
|
||||
if not self.client:
|
||||
exit('MQTT client initialization failed')
|
||||
|
||||
def init(self):
|
||||
"""Init the connection to the MQTT server."""
|
||||
|
|
|
@ -37,7 +37,7 @@ class Export(GlancesExport):
|
|||
# Load the configuration file
|
||||
self.export_enable = self.load_conf('opentsdb', mandatories=['host', 'port'], options=['prefix', 'tags'])
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing OPENTSDB config')
|
||||
|
||||
# Default prefix for stats is 'glances'
|
||||
if self.prefix is None:
|
||||
|
|
|
@ -32,7 +32,7 @@ class Export(GlancesExport):
|
|||
# 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)
|
||||
exit('Missing PROMETHEUS config')
|
||||
|
||||
# Optionals configuration keys
|
||||
if self.prefix is None:
|
||||
|
|
|
@ -44,7 +44,7 @@ class Export(GlancesExport):
|
|||
'rabbitmq', mandatories=['host', 'port', 'user', 'password', 'queue'], options=['protocol']
|
||||
)
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing RABBITMQ config')
|
||||
|
||||
# Get the current hostname
|
||||
self.hostname = socket.gethostname()
|
||||
|
|
|
@ -34,7 +34,7 @@ class Export(GlancesExport):
|
|||
# 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:
|
||||
sys.exit(2)
|
||||
exit('Missing RESTFUL config')
|
||||
|
||||
# Init the stats buffer
|
||||
# It's a dict of stats
|
||||
|
|
|
@ -38,7 +38,7 @@ class Export(GlancesExport):
|
|||
# Load the Riemann configuration
|
||||
self.export_enable = self.load_conf('riemann', mandatories=['host', 'port'], options=[])
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing RIEMANN config')
|
||||
|
||||
# Get the current hostname
|
||||
self.hostname = socket.gethostname()
|
||||
|
|
|
@ -36,7 +36,7 @@ class Export(GlancesExport):
|
|||
# Load the configuration file
|
||||
self.export_enable = self.load_conf('statsd', mandatories=['host', 'port'], options=['prefix'])
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing STATSD config')
|
||||
|
||||
# Default prefix for stats is 'glances'
|
||||
if self.prefix is None:
|
||||
|
|
|
@ -37,7 +37,7 @@ class Export(GlancesExport):
|
|||
# Load the ZeroMQ configuration file section ([export_zeromq])
|
||||
self.export_enable = self.load_conf('zeromq', mandatories=['host', 'port', 'prefix'], options=[])
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
exit('Missing ZEROMQ config')
|
||||
|
||||
# Init the ZeroMQ context
|
||||
self.context = None
|
||||
|
|
Loading…
Reference in New Issue