Skip to content

Commit

Permalink
adds InfluxDB TLS Support #7
Browse files Browse the repository at this point in the history
refs: #7
  • Loading branch information
bb-Ricardo committed Jul 29, 2020
1 parent 0e639a0 commit c96eb44
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 4 deletions.
2 changes: 2 additions & 0 deletions fritzinfluxdb.ini-sample
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ port = 8086
username = bla
password = blub
database = db
ssl = false
verify_ssl = true
measurement_name = fritzbox

[fritzbox]
Expand Down
11 changes: 7 additions & 4 deletions fritzinfluxdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@
import logging
import os
import signal
import sys
import time
from datetime import datetime

Expand All @@ -29,7 +28,7 @@
# default vars
running = True
default_config = os.path.join(os.path.dirname(__file__), 'fritzinfluxdb.ini')
default_loglevel = logging.INFO
default_log_level = logging.INFO


def parse_args():
Expand All @@ -52,7 +51,8 @@ def parse_args():
return parser.parse_args()


def shutdown():
# noinspection PyUnusedLocal
def shutdown(exit_signal, frame):
global running
running = False

Expand Down Expand Up @@ -203,7 +203,7 @@ def main():
args = parse_args()

# set logging
log_level = logging.DEBUG if args.verbose is True else default_loglevel
log_level = logging.DEBUG if args.verbose is True else default_log_level

if args.daemon:
# omit time stamp if run in daemon mode
Expand All @@ -223,6 +223,8 @@ def main():
config.get('influxdb', 'username'),
config.get('influxdb', 'password'),
config.get('influxdb', 'database'),
config.get('influxdb', 'ssl'),
config.get('influxdb', 'verify_ssl'),
)
# test more config options
_ = config.get('influxdb', 'measurement_name')
Expand Down Expand Up @@ -290,6 +292,7 @@ def main():

logging.debug("writing data to InfluxDB")

# noinspection PyBroadException
try:
influxdb_client.write_points([data], time_precision="ms")
except Exception:
Expand Down

0 comments on commit c96eb44

Please sign in to comment.