Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def main():
telemetry_target_host = os.getenv('TELEMETRY_TARGET_HOST')
telemetry_target_port = int(os.getenv('TELEMETRY_TARGET_PORT', '2003'))
telemetry_prefix = os.getenv('TELEMETRY_PREFIX', 'io.turntabl')
print('prefix: ' + telemetry_prefix)
SSID = get_ssid()
wifi_signal_quality = get_wifi_signal_quality()
upload, download = get_speeds()
graphyte.init(host=telemetry_target_host, port=telemetry_target_port, prefix=telemetry_prefix)
graphyte.send('wifi.signal_quality', wifi_signal_quality)
graphyte.send('4g.upload', upload / 1024 / 1024)
graphyte.send('4g.download', download / 1024 / 1024)
def main():
telemetry_target_host = os.getenv('TELEMETRY_TARGET_HOST')
telemetry_target_port = int(os.getenv('TELEMETRY_TARGET_PORT', '2003'))
telemetry_prefix = os.getenv('TELEMETRY_PREFIX', 'io.turntabl')
print('prefix: ' + telemetry_prefix)
SSID = get_ssid()
wifi_signal_quality = get_wifi_signal_quality()
upload, download = get_speeds()
graphyte.init(host=telemetry_target_host, port=telemetry_target_port, prefix=telemetry_prefix)
graphyte.send('wifi.signal_quality', wifi_signal_quality)
graphyte.send('4g.upload', upload / 1024 / 1024)
graphyte.send('4g.download', download / 1024 / 1024)
def main():
telemetry_target_host = os.getenv('TELEMETRY_TARGET_HOST')
telemetry_target_port = int(os.getenv('TELEMETRY_TARGET_PORT', '2003'))
telemetry_prefix = os.getenv('TELEMETRY_PREFIX', 'io.turntabl')
print('prefix: ' + telemetry_prefix)
SSID = get_ssid()
wifi_signal_quality = get_wifi_signal_quality()
upload, download = get_speeds()
graphyte.init(host=telemetry_target_host, port=telemetry_target_port, prefix=telemetry_prefix)
graphyte.send('wifi.signal_quality', wifi_signal_quality)
graphyte.send('4g.upload', upload / 1024 / 1024)
graphyte.send('4g.download', download / 1024 / 1024)
# 45107
# 1
#
current_connect_time_minutes = int(tree.find('CurrentConnectTime').text)
total_connect_time_minutes = int(tree.find('TotalConnectTime').text)
current_upload_bytes = int(tree.find('CurrentUpload').text)
current_upload_rate_bps = int(tree.find('CurrentUploadRate').text)
total_upload_bytes = int(tree.find('TotalUpload').text)
current_download_bytes = int(tree.find('CurrentDownload').text)
current_download_rate_bps = int(tree.find('CurrentDownloadRate').text)
total_download_bytes = int(tree.find('TotalDownload').text)
graphyte.send('4g.current_upload_bytes', current_upload_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_upload_rate', current_upload_rate_bps / 1024 / 1024, tags={'SSID': SSID})
graphyte.send('4g.current_download_bytes', current_download_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_download_rate', current_download_rate_bps / 1024 / 1024, tags={'SSID': SSID})
def publish_ping():
SSID = get_ssid()
graphyte.send('ping', 1, tags={'SSID': SSID})
logger.info('worker :: debug :: last_metric_timestamp for %s from %s is %s' % (metric, str(cache_key), str(last_metric_timestamp)))
except:
logger.error(traceback.format_exc())
logger.error('error :: worker :: failed to determine last_metric_timestamp from Redis key %s' % str(cache_key))
last_metric_timestamp = False
if last_metric_timestamp:
if timestamp <= last_metric_timestamp:
valid_data = False
if LOCAL_DEBUG:
logger.info('worker :: debug :: not valid data - the queue data timestamp %s is <= to the last_metric_timestamp %s for %s' % (
str(timestamp), str(last_metric_timestamp), metric))
if valid_data:
submittedToGraphite = False
try:
graphyte.send(metric, value, timestamp)
submittedToGraphite = True
logger.info('worker :: sent %s, %s, %s to Graphite' % (str(metric), str(value), str(timestamp)))
metrics_sent_to_graphite += 1
except:
logger.error(traceback.format_exc())
logger.error('error :: worker :: failed to send metric data to Graphite for %s' % str(metric))
metric = None
if submittedToGraphite:
# Update the metric Redis flux key
# @modified 20200206 - Feature #3444: Allow flux to backfill
# Only update the flux.last key if this is not backfill
if not backfill:
metric_data = [timestamp, value]
self.redis_conn.set(cache_key, str(metric_data))
# @added 20200213 - Bug #3448: Repeated airgapped_metrics
else:
current_connect_time_minutes = int(tree.find('CurrentConnectTime').text)
total_connect_time_minutes = int(tree.find('TotalConnectTime').text)
current_upload_bytes = int(tree.find('CurrentUpload').text)
current_upload_rate_bps = int(tree.find('CurrentUploadRate').text)
total_upload_bytes = int(tree.find('TotalUpload').text)
current_download_bytes = int(tree.find('CurrentDownload').text)
current_download_rate_bps = int(tree.find('CurrentDownloadRate').text)
total_download_bytes = int(tree.find('TotalDownload').text)
graphyte.send('4g.current_upload_bytes', current_upload_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_upload_rate', current_upload_rate_bps / 1024 / 1024, tags={'SSID': SSID})
graphyte.send('4g.current_download_bytes', current_download_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_download_rate', current_download_rate_bps / 1024 / 1024, tags={'SSID': SSID})
# 1
#
current_connect_time_minutes = int(tree.find('CurrentConnectTime').text)
total_connect_time_minutes = int(tree.find('TotalConnectTime').text)
current_upload_bytes = int(tree.find('CurrentUpload').text)
current_upload_rate_bps = int(tree.find('CurrentUploadRate').text)
total_upload_bytes = int(tree.find('TotalUpload').text)
current_download_bytes = int(tree.find('CurrentDownload').text)
current_download_rate_bps = int(tree.find('CurrentDownloadRate').text)
total_download_bytes = int(tree.find('TotalDownload').text)
graphyte.send('4g.current_upload_bytes', current_upload_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_upload_rate', current_upload_rate_bps / 1024 / 1024, tags={'SSID': SSID})
graphyte.send('4g.current_download_bytes', current_download_bytes, tags={'SSID': SSID})
graphyte.send('4g.current_download_rate', current_download_rate_bps / 1024 / 1024, tags={'SSID': SSID})