Private GIT

Skip to content
Snippets Groups Projects
Commit 24ae221f authored by Barry Carey's avatar Barry Carey
Browse files

Add singlerun flag. Set server before each run to force ping to update

parent 6a716f3a
Branches
No related tags found
No related merge requests found
# Covers JetBrains IDEs: IntelliJ, RubyMine, PhpStorm, AppCode, PyCharm, CLion, Android Studio and WebStorm
# Reference: https://intellij-support.jetbrains.com/hc/en-us/articles/206544839
# User-specific stuff
.idea/**/workspace.xml
.idea/**/tasks.xml
.idea/**/usage.statistics.xml
.idea/**/dictionaries
.idea/**/shelf
venv
# Generated files
.idea/**/contentModel.xml
# Sensitive or high-churn files
.idea/**/dataSources/
.idea/**/dataSources.ids
.idea/**/dataSources.local.xml
.idea/**/sqlDataSources.xml
.idea/**/dynamic.xml
.idea/**/uiDesigner.xml
.idea/**/dbnavigator.xml
# Gradle
.idea/**/gradle.xml
.idea/**/libraries
# Gradle and Maven with auto-import
# When using Gradle or Maven with auto-import, you should exclude module files,
# since they will be recreated, and may cause churn. Uncomment if using
# auto-import.
# .idea/modules.xml
# .idea/*.iml
# .idea/modules
# CMake
cmake-build-*/
# Mongo Explorer plugin
.idea/**/mongoSettings.xml
# File-based project format
*.iws
# IntelliJ
out/
# mpeltonen/sbt-idea plugin
.idea_modules/
# JIRA plugin
atlassian-ide-plugin.xml
# Cursive Clojure plugin
.idea/replstate.xml
# Crashlytics plugin (for Android Studio and IntelliJ)
com_crashlytics_export_strings.xml
crashlytics.properties
crashlytics-build.properties
fabric.properties
# Editor-based Rest Client
.idea/httpRequests
# Android studio 3.1+ serialized cache file
.idea/caches/build_file_checksums.ser
\ No newline at end of file
...@@ -46,10 +46,11 @@ class configManager(): ...@@ -46,10 +46,11 @@ class configManager():
class InfluxdbSpeedtest(): class InfluxdbSpeedtest():
def __init__(self, config=None): def __init__(self, config=None, single_run=False):
self.config = configManager(config=config) self.config = configManager(config=config)
self.output = self.config.output self.output = self.config.output
self.single_run = single_run
self.influx_client = InfluxDBClient( self.influx_client = InfluxDBClient(
self.config.influx_address, self.config.influx_address,
self.config.influx_port, self.config.influx_port,
...@@ -62,7 +63,6 @@ class InfluxdbSpeedtest(): ...@@ -62,7 +63,6 @@ class InfluxdbSpeedtest():
self.speedtest = None self.speedtest = None
self.results = None self.results = None
self.setup_speedtest()
def setup_speedtest(self): def setup_speedtest(self):
...@@ -81,7 +81,7 @@ class InfluxdbSpeedtest(): ...@@ -81,7 +81,7 @@ class InfluxdbSpeedtest():
print('ERROR: No matched servers: {}'.format(self.config.test_server[0])) print('ERROR: No matched servers: {}'.format(self.config.test_server[0]))
sys.exit(1) sys.exit(1)
except speedtest.ServersRetrievalError: except speedtest.ServersRetrievalError:
print('ERROR: Cannot retrieve speedtest server list') print('ERROR: Cannot retrieve speedtest.net server list')
sys.exit(1) sys.exit(1)
except speedtest.InvalidServerIDType: except speedtest.InvalidServerIDType:
print('{} is an invalid server type, must be int'.format(self.config.test_server[0])) print('{} is an invalid server type, must be int'.format(self.config.test_server[0]))
...@@ -119,11 +119,13 @@ class InfluxdbSpeedtest(): ...@@ -119,11 +119,13 @@ class InfluxdbSpeedtest():
def run(self): def run(self):
while True: while True:
self.setup_speedtest()
self.speedtest.download() self.speedtest.download()
self.speedtest.upload() self.speedtest.upload()
self.send_results() self.send_results()
if self.single_run:
return
time.sleep(self.config.delay) time.sleep(self.config.delay)
...@@ -160,8 +162,9 @@ def main(): ...@@ -160,8 +162,9 @@ def main():
parser = argparse.ArgumentParser(description="A tool to send Plex statistics to InfluxDB") parser = argparse.ArgumentParser(description="A tool to send Plex statistics to InfluxDB")
parser.add_argument('--config', default='config.ini', dest='config', help='Specify a custom location for the config file') parser.add_argument('--config', default='config.ini', dest='config', help='Specify a custom location for the config file')
parser.add_argument('--singlerun', action='store_true', help='Only runs through once, does not keep monitoring')
args = parser.parse_args() args = parser.parse_args()
collector = InfluxdbSpeedtest(config=args.config) collector = InfluxdbSpeedtest(config=args.config, single_run=args.singlerun)
collector.run() collector.run()
......
...@@ -5,6 +5,11 @@ ...@@ -5,6 +5,11 @@
This tool is a wrapper for speedtest-cli which allows you to run periodic speedtets and save the results to Influxdb This tool is a wrapper for speedtest-cli which allows you to run periodic speedtets and save the results to Influxdb
## Command Line Args
--config whatever.ini - Use a different ini file
--singlerun - Run once and exit
## Configuration within config.ini ## Configuration within config.ini
#### GENERAL #### GENERAL
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment