mirror of https://github.com/nicolargo/glances
Connection to Graphite Server should be done before releasing the feature
parent
6bceeef43f
commit
560b989f17
|
@ -590,7 +590,7 @@ path=/
|
|||
# Configuration for the --export graphite option
|
||||
# https://graphiteapp.org/
|
||||
host=localhost
|
||||
port=2003
|
||||
port=20039
|
||||
protocol=tcp
|
||||
batch_size=1000
|
||||
# Prefix will be added for all measurement name
|
||||
|
|
|
@ -29,5 +29,9 @@ and run Glances with:
|
|||
|
||||
$ glances --export graphite
|
||||
|
||||
Note 1: the port defines the TCP or UDP port where the Graphite listen plain-text requests
|
||||
|
||||
Note: Only integer and float are supported in the Graphite datamodel.
|
||||
Note 2: As many time-series database, only integer and float are supported in the Graphite datamodel.
|
||||
|
||||
Note 3: Under the wood, Glances uses Graphyte Python lib (https://pypi.org/project/graphyte/)
|
||||
|
|
@ -76,16 +76,38 @@ class Export(GlancesExport):
|
|||
"""Init the connection to the Graphite server."""
|
||||
if not self.export_enable:
|
||||
return None
|
||||
|
||||
client = graphyte.Sender(self.host,
|
||||
port=self.port,
|
||||
prefix=self.prefix,
|
||||
protocol=self.protocol,
|
||||
batch_size=self.batch_size)
|
||||
|
||||
# !!! Except is never reached...
|
||||
# !!! Have to find away to test the connection with the Graphite server
|
||||
# !!! Waiting that, have to set the logger to debug in the export function
|
||||
# try:
|
||||
# client.send("check", 1)
|
||||
# except Exception as e:
|
||||
# logger.error("Can not write data to Graphite server: {}:{}/{} ({})".format(self.host,
|
||||
# self.port,
|
||||
# self.protocol,
|
||||
# e))
|
||||
# return None
|
||||
# else:
|
||||
# logger.info(
|
||||
# "Stats will be exported to Graphite server: {}:{}/{}".format(self.host,
|
||||
# self.port,
|
||||
# self.protocol))
|
||||
|
||||
# return client
|
||||
|
||||
logger.info(
|
||||
"Stats will be exported to Graphite server: {}:{}/{}".format(self.host,
|
||||
self.port,
|
||||
self.protocol))
|
||||
|
||||
return graphyte.Sender(self.host,
|
||||
port=self.port,
|
||||
prefix=self.prefix,
|
||||
protocol=self.protocol,
|
||||
batch_size=self.batch_size)
|
||||
return client
|
||||
|
||||
def export(self, name, columns, points):
|
||||
"""Export the stats to the Graphite server."""
|
||||
|
@ -99,7 +121,9 @@ class Export(GlancesExport):
|
|||
self.client.send(normalize(stat_name),
|
||||
stat_value)
|
||||
except Exception as e:
|
||||
logger.error("Can not export stats to Graphite (%s)" % e)
|
||||
# !! Set to error when the connection test is ok
|
||||
# logger.error("Can not export stats to Graphite (%s)" % e)
|
||||
logger.debug("Can not export stats to Graphite (%s)" % e)
|
||||
logger.debug("Export {} stats to Graphite".format(name))
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue