Skip to content

Commit

Permalink
Add InfluxDB SSL Option
Browse files Browse the repository at this point in the history
Add possibility to connect to InfluxDB via https.
Also adding the option for verifying the https cert.

Signed-off-by: Tobias Gall <tobias.gall@mailbox.org>
  • Loading branch information
symptog committed Dec 19, 2017
1 parent dc23676 commit f5efaa2
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
3 changes: 2 additions & 1 deletion doc/mgr/influx.rst
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,8 @@ Additional optional configuration settings are:
:interval: Time between reports to InfluxDB. Default 5 seconds.
:database: InfluxDB database name. Default "ceph". You will need to create this database and grant write privileges to the configured username or the username must have admin privileges to create it.
:port: InfluxDB server port. Default 8086

:ssl: Use https connection for InfluxDB server. Use "true" or "false". Default false
:verify_ssl: Verify https cert for InfluxDB server. Use "true" or "false". Default true

---------
Debugging
Expand Down
16 changes: 14 additions & 2 deletions src/pybind/mgr/influx/module.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,9 @@ class Module(MgrModule):
'database': 'ceph',
'username': None,
'password': None,
'interval': 5
'interval': 5,
'ssl': 'false',
'verify_ssl': 'true'
}

def __init__(self, *args, **kwargs):
Expand Down Expand Up @@ -139,6 +141,9 @@ def set_config_option(self, option, value):
if option == 'interval' and value < 5:
raise RuntimeError('interval should be set to at least 5 seconds')

if option in ['ssl', 'verify_ssl']:
value = value.lower() == 'true'

self.config[option] = value

def init_module_config(self):
Expand All @@ -155,6 +160,11 @@ def init_module_config(self):
self.config['interval'] = \
int(self.get_config("interval",
default=self.config_keys['interval']))
ssl = self.get_config("ssl", default=self.config_keys['ssl'])
self.config['ssl'] = ssl.lower() == 'true'
verify_ssl = \
self.get_config("verify_ssl", default=self.config_keys['verify_ssl'])
self.config['verify_ssl'] = verify_ssl.lower() == 'true'

def send_to_influx(self):
if not self.config['hostname']:
Expand All @@ -169,7 +179,9 @@ def send_to_influx(self):
client = InfluxDBClient(self.config['hostname'], self.config['port'],
self.config['username'],
self.config['password'],
self.config['database'])
self.config['database'],
self.config['ssl'],
self.config['verify_ssl'])

# using influx client get_list_database requires admin privs,
# instead we'll catch the not found exception and inform the user if
Expand Down

0 comments on commit f5efaa2

Please sign in to comment.