mirror of https://github.com/nicolargo/glances.git
Improve error message when export error occures
This commit is contained in:
parent
17ff53d3a7
commit
177eff05a2
|
|
@ -524,6 +524,7 @@ port=8125
|
|||
# Configuration for the --export elasticsearch option
|
||||
# Data are available via the ES RESTful API. ex: URL/<index>/cpu
|
||||
# https://www.elastic.co
|
||||
scheme=http
|
||||
host=localhost
|
||||
port=9200
|
||||
index=glances
|
||||
|
|
|
|||
|
|
@ -31,7 +31,7 @@ class Export(GlancesExport):
|
|||
self.index = None
|
||||
|
||||
# Load the ES configuration file
|
||||
self.export_enable = self.load_conf('elasticsearch', mandatories=['host', 'port', 'index'], options=[])
|
||||
self.export_enable = self.load_conf('elasticsearch', mandatories=['scheme', 'host', 'port', 'index'], options=[])
|
||||
if not self.export_enable:
|
||||
sys.exit(2)
|
||||
|
||||
|
|
@ -44,12 +44,22 @@ class Export(GlancesExport):
|
|||
return None
|
||||
|
||||
try:
|
||||
es = Elasticsearch(hosts=['{}:{}'.format(self.host, self.port)])
|
||||
es = Elasticsearch(hosts=['{}://{}:{}'.format(self.scheme, self.host, self.port)])
|
||||
except Exception as e:
|
||||
logger.critical("Cannot connect to ElasticSearch server %s:%s (%s)" % (self.host, self.port, e))
|
||||
logger.critical("Cannot connect to ElasticSearch server %s://%s:%s (%s)" % (self.scheme,
|
||||
self.host,
|
||||
self.port, e))
|
||||
sys.exit(2)
|
||||
|
||||
if not es.ping():
|
||||
logger.critical("Cannot ping the ElasticSearch server %s://%s:%s" % (self.scheme,
|
||||
self.host,
|
||||
self.port))
|
||||
sys.exit(2)
|
||||
else:
|
||||
logger.info("Connected to the ElasticSearch server %s:%s" % (self.host, self.port))
|
||||
logger.info("Connected to the ElasticSearch server %s://%s:%s" % (self.scheme,
|
||||
self.host,
|
||||
self.port))
|
||||
|
||||
return es
|
||||
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@
|
|||
import sys
|
||||
from numbers import Number
|
||||
|
||||
from glances.compat import range
|
||||
from glances.logger import logger
|
||||
from glances.exports.glances_export import GlancesExport
|
||||
|
||||
|
|
@ -80,7 +79,6 @@ class Export(GlancesExport):
|
|||
client = None
|
||||
else:
|
||||
logger.info("Stats will be exported to Graphite server: {}:{}".format(self.host, self.port))
|
||||
|
||||
return client
|
||||
|
||||
def export(self, name, columns, points):
|
||||
|
|
|
|||
|
|
@ -72,8 +72,8 @@ class Export(GlancesExport):
|
|||
channel = connection.channel()
|
||||
return channel
|
||||
except Exception as e:
|
||||
logger.critical("Connection to rabbitMQ failed : %s " % e)
|
||||
return None
|
||||
logger.critical("Connection to rabbitMQ server %s:%s failed. %s" % (self.host, self.port, e))
|
||||
sys.exit(2)
|
||||
|
||||
def export(self, name, columns, points):
|
||||
"""Write the points in RabbitMQ."""
|
||||
|
|
|
|||
Loading…
Reference in New Issue