try:
from influxdb import InfluxDBClient
from influxdb.exceptions import InfluxDBClientError
+ from requests.exceptions import ConnectionError
except ImportError:
InfluxDBClient = None
if not self.config['hostname']:
self.log.error("No Influx server configured, please set one using: "
"ceph influx config-set hostname <hostname>")
+ self.set_health_checks({
+ 'MGR_INFLUX_NO_SERVER': {
+ 'severity': 'warning',
+ 'summary': 'No InfluxDB server configured',
+ 'detail': ['Configuration option hostname not set']
+ }
+ })
return
# If influx server has authentication turned off then
try:
client.write_points(self.get_df_stats(), 'ms')
client.write_points(self.get_daemon_stats(), 'ms')
+ self.set_health_checks(dict())
+ except ConnectionError as e:
+ self.log.exception("Failed to connect to Influx host %s:%d",
+ self.config['hostname'], self.config['port'])
+ self.set_health_checks({
+ 'MGR_INFLUX_SEND_FAILED': {
+ 'severity': 'warning',
+ 'summary': 'Failed to send data to InfluxDB server at %s:%d'
+ ' due to an connection error'
+ % (self.config['hostname'], self.config['port']),
+ 'detail': [str(e)]
+ }
+ })
except InfluxDBClientError as e:
if e.code == 404:
self.log.info("Database '%s' not found, trying to create "
self.config['username'])
client.create_database(self.config['database'])
else:
+ self.set_health_checks({
+ 'MGR_INFLUX_SEND_FAILED': {
+ 'severity': 'warning',
+ 'summary': 'Failed to send data to InfluxDB',
+ 'detail': [str(e)]
+ }
+ })
raise
def shutdown(self):