Skip to content

Commit

Permalink
Merge branch 'v0.3.1' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
wifinigel committed Nov 15, 2021
2 parents 92de6d1 + 292b385 commit 1725b81
Show file tree
Hide file tree
Showing 5 changed files with 43 additions and 12 deletions.
7 changes: 7 additions & 0 deletions release_notes.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
v0.3.2
1. Added fix for Influx DB ssl support

v0.3.1
1. Added bug-fix for remote config pull status reporting
2. Added remote config pull additonal debugging info

v0.3
1. Added support for user-defined number of ping tests

Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="wiperf_poller",
version="0.3.0",
version="0.3.2",
author="Nigel Bowden",
author_email="[email protected]",
description="Poller for the wiperf utlity",
Expand Down
2 changes: 1 addition & 1 deletion wiperf_poller/exporters/exportresults.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def send_results_to_splunk(self, host, token, port, dict_data, file_logger, sour
splunk_exp_obj=SplunkExporter(host, token, file_logger, port)
return splunk_exp_obj.export_result(dict_data, source)

def send_results_to_influx(self, localhost, host, port, username, password, database, use_ssl, dict_data, source, file_logger):
def send_results_to_influx(self, localhost, host, port, username, password, database, use_ssl, dict_data, source, file_logger):

file_logger.info("Sending results data to Influx host: {}, port: {}, database: {})".format(host, port, database))
if is_ipv6(host): host = "[{}]".format(host)
Expand Down
4 changes: 2 additions & 2 deletions wiperf_poller/helpers/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ def read_local_config(config_file, file_logger):
####### Influx1 config ########
config_vars['influx_host'] = gen_sect.get('influx_host')
config_vars['influx_port'] = gen_sect.get('influx_port', '8086')
config_vars['influx_ssl'] = gen_sect.get('influx_ssl', True)
config_vars['influx_ssl'] = gen_sect.getboolean('influx_ssl', True)
config_vars['influx_username'] = gen_sect.get('influx_username', 'admin')
config_vars['influx_password'] = gen_sect.get('influx_password', 'admin')
config_vars['influx_database'] = gen_sect.get('influx_database', 'wiperf')
Expand All @@ -92,7 +92,7 @@ def read_local_config(config_file, file_logger):
####### Influx2 config ########
config_vars['influx2_host'] = gen_sect.get('influx2_host')
config_vars['influx2_port'] = gen_sect.get('influx2_port', '8086')
config_vars['influx2_ssl'] = gen_sect.get('influx2_ssl', True)
config_vars['influx2_ssl'] = gen_sect.getboolean('influx2_ssl', True)
config_vars['influx2_token'] = gen_sect.get('influx2_token', '')
config_vars['influx2_bucket'] = gen_sect.get('influx2_bucket', '')
config_vars['influx2_org'] = gen_sect.get('influx2_org', '')
Expand Down
40 changes: 32 additions & 8 deletions wiperf_poller/helpers/remoteconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,24 @@
####################################
# config server
####################################
def anon_value(value):
"""
Turn value in to anonymous value to protect sensitve data that will
be printed in log info
Args:
value (string): value to be anonymised
Return:
Anonymised string
"""
value = str(value)

if len(value) < 4:
return len(value) * "*"
else:
return value[0] + (len(value) -2) * "*" + value[-1]

def read_remote_cfg(config_file, check_cfg_file, config_vars, file_logger):
"""
Pull the remote cfg file if refresh time expired or on first boot
Expand All @@ -24,18 +42,26 @@ def read_remote_cfg(config_file, check_cfg_file, config_vars, file_logger):
cfg_password = config_vars['cfg_password']
cfg_text = ''

file_logger.debug("Trying to pull config file from URL: {}".format(cfg_file_url))

# if we use a token, we need to set user/pwd to be token
if cfg_token:
cfg_username = cfg_token
cfg_password = cfg_token

file_logger.info("Trying to pull config file from : {}".format(cfg_file_url))
file_logger.debug("Credential used (token): {}".format(anon_value(cfg_token)))
else:
file_logger.debug("Credential used (user/pwd): {} / {}".format(anon_value(cfg_username), anon_value(cfg_password)))

try:
warnings.simplefilter('ignore',InsecureRequestWarning)
response = requests.get(cfg_file_url, auth=(cfg_username, cfg_password), timeout=5)
if response.status_code == 200:
cfg_text = response.text
file_logger.info("Config file pulled OK.")
cfg_text = response.text
file_logger.debug("HTTP reponse code: {}".format(response.status_code))
file_logger.info("Config file pulled OK.")
else:
file_logger.error("Config file pull failed: {} ({}) - Note: Pretty much everything fails as a 404 on GitHub (if that is your remote target), even auth issues".format(response.status_code, response.text))
return False
except Exception as err:
file_logger.error("Config file pull error:")
file_logger.error("HTTP get error: {}".format(err))
Expand Down Expand Up @@ -89,9 +115,8 @@ def check_last_cfg_read(config_file, check_cfg_file, config_vars, file_logger):
last_read_time = f.read()
file_logger.debug("Last read timestamp: {}".format(last_read_time))
except FileNotFoundError:
# file does not exist, create & write timestamp
file_logger.info("Timestamp file does not exist, creating...")
write_cfg_timestamp(check_cfg_file, file_logger)
# file does not exist
file_logger.info("Timestamp file does not exist yet - will be created after successful read from remote file store.")
except Exception as e:
file_logger.info("File read error: {}".format(e))
return False
Expand All @@ -106,4 +131,3 @@ def check_last_cfg_read(config_file, check_cfg_file, config_vars, file_logger):
else:
file_logger.info("Not time to read remote cfg file.")
return False

0 comments on commit 1725b81

Please sign in to comment.