Update main.py to remove unused schedule import, enhance logging, and ensure server collector starts correctly; update telegraf.conf for MongoDB connection details and add authentication; include beautifulsoup4 in requirements.

This commit is contained in:
2025-01-28 22:25:52 +01:00
parent 95babcde15
commit d8fc99fe68
3 changed files with 11 additions and 13 deletions

View File

@@ -1,4 +1,3 @@
import schedule
import signal
import json
import time
@@ -32,7 +31,6 @@ def setupLogger():
def interrupt_handler(signum, driver: webdriver.Chrome):
logger.log(logging.INFO, f'Handling signal {signum} ({signal.Signals(signum).name}).')
schedule.clear()
driver.quit()
raise SystemExit
@@ -49,6 +47,8 @@ def setupChromeDriver():
chrome_options.add_argument(f"--load-extension={os.path.abspath(os.path.join(os.path.dirname(__file__), 'webrtc-internals-exporter'))}")
chrome_options.add_experimental_option('prefs', {'intl.accept_languages': 'en,en_US'})
logger.info(f"{os.path.abspath(os.path.join(os.path.dirname(__file__), 'webrtc-internals-exporter'))}")
driver = webdriver.Chrome(options=chrome_options)
#driver = webdriver.Remote(command_executor='http://localhost:4444', options=chrome_options)
logger.log(logging.INFO, 'Chrome driver setup complete.')
@@ -187,8 +187,5 @@ if __name__ == '__main__':
logger.log(logging.INFO, 'Starting server collector.')
httpd = HTTPServer(('localhost', 9092), partial(Handler, downloadStats, driver, logger))
logger.info('Server collector started.')
httpd.serve_forever()
#schedule.every(2).seconds.do(downloadStats, driver)
#while True:
#schedule.run_pending()

View File

@@ -1 +1,2 @@
selenium
beautifulsoup4

View File

@@ -25,9 +25,9 @@
data_format = "json"
[[outputs.mongodb]]
dsn = "mongodb://192.168.68.204:27017"
dsn = "mongodb://192.168.68.120:27017"
database = "peertube"
granularity = "seconds"
#authentication = "SCRAM"
#username = "root"
#password = "example"
authentication = "SCRAM"
username = "stats_user"
password = "@z^VFhN7q%vzit"