def v2_playbook_on_stats(self, stats):
"""Connect to InfluxDB and commit events"""
# Set InfluxDB host from an environment variable if provided
_host = os.getenv('influx_vip') or self.host_vars['influx_vip']
_port = "8086"
_user = "None"
_pass = "None"
_dbname = "events"
influxdb = InfluxDBClient(_host, _port, _user, _pass, _dbname)
try:
influxdb.write_points(self.events, time_precision='u')
except Exception:
# Disable the plugin if writes fail
self.disabled = True
self._display.warning(
"Cannot write to InfluxDB, check the service state "
"on %s." % _host)
return
评论列表
文章目录