mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
commit
eed68c6474
@ -10,3 +10,4 @@ requests
|
||||
schedule
|
||||
waitress
|
||||
setuptools >= 65.5.1
|
||||
apscheduler
|
||||
|
@ -7,6 +7,9 @@ if automaticImportUISP:
|
||||
from integrationUISP import importFromUISP
|
||||
if automaticImportSplynx:
|
||||
from integrationSplynx import importFromSplynx
|
||||
from apscheduler.schedulers.background import BlockingScheduler
|
||||
|
||||
ads = BlockingScheduler()
|
||||
|
||||
def importFromCRM():
|
||||
if automaticImportUISP:
|
||||
@ -20,6 +23,16 @@ def importFromCRM():
|
||||
except:
|
||||
print("Failed to import from Splynx")
|
||||
|
||||
def graphHandler():
|
||||
try:
|
||||
refreshBandwidthGraphs()
|
||||
except:
|
||||
print("Failed to update bandwidth graphs")
|
||||
try:
|
||||
refreshLatencyGraphs()
|
||||
except:
|
||||
print("Failed to update latency graphs")
|
||||
|
||||
def importAndShapeFullReload():
|
||||
importFromCRM()
|
||||
refreshShapers()
|
||||
@ -28,35 +41,12 @@ def importAndShapePartialReload():
|
||||
importFromCRM()
|
||||
refreshShapersUpdateOnly()
|
||||
|
||||
def graph():
|
||||
time.sleep(10)
|
||||
try:
|
||||
refreshBandwidthGraphs()
|
||||
except:
|
||||
print("Failed to run refreshBandwidthGraphs()")
|
||||
time.sleep(10)
|
||||
try:
|
||||
refreshBandwidthGraphs()
|
||||
except:
|
||||
print("Failed to run refreshBandwidthGraphs()")
|
||||
time.sleep(10)
|
||||
try:
|
||||
refreshBandwidthGraphs()
|
||||
except:
|
||||
print("Failed to run refreshBandwidthGraphs()")
|
||||
time.sleep(1)
|
||||
try:
|
||||
refreshLatencyGraphs()
|
||||
except:
|
||||
print("Failed to run refreshLatencyGraphs()")
|
||||
|
||||
if __name__ == '__main__':
|
||||
importAndShapeFullReload()
|
||||
while True:
|
||||
finish_time = datetime.datetime.now() + datetime.timedelta(minutes=30)
|
||||
while datetime.datetime.now() < finish_time:
|
||||
if influxDBEnabled:
|
||||
graph()
|
||||
else:
|
||||
time.sleep(1)
|
||||
importAndShapePartialReload()
|
||||
|
||||
ads.add_job(importAndShapePartialReload, 'interval', minutes=30)
|
||||
|
||||
if influxDBEnabled:
|
||||
ads.add_job(graphHandler, 'interval', seconds=10)
|
||||
|
||||
ads.start()
|
||||
|
@ -1,67 +0,0 @@
|
||||
import time
|
||||
|
||||
from LibreQoS import refreshShapers, refreshShapersUpdateOnly
|
||||
from graphInfluxDB import refreshBandwidthGraphs, refreshLatencyGraphs
|
||||
from ispConfig import influxDBEnabled, automaticImportUISP, automaticImportSplynx, httpRestIntegrationConfig
|
||||
|
||||
if automaticImportUISP:
|
||||
from integrationUISP import importFromUISP
|
||||
if automaticImportSplynx:
|
||||
from integrationSplynx import importFromSplynx
|
||||
if httpRestIntegrationConfig['enabled']:
|
||||
from integrationRestHttp import importFromRestHttp
|
||||
|
||||
from apscheduler.schedulers.background import BlockingScheduler
|
||||
|
||||
ads = BlockingScheduler()
|
||||
|
||||
|
||||
def importFromCRM():
|
||||
if automaticImportUISP:
|
||||
try:
|
||||
importFromUISP()
|
||||
except:
|
||||
print("Failed to import from UISP")
|
||||
elif automaticImportSplynx:
|
||||
try:
|
||||
importFromSplynx()
|
||||
except:
|
||||
print("Failed to import from Splynx")
|
||||
elif httpRestIntegrationConfig['enabled']:
|
||||
try:
|
||||
importFromRestHttp()
|
||||
except:
|
||||
print("Failed to import from RestHttp")
|
||||
|
||||
|
||||
def importAndShapeFullReload():
|
||||
importFromCRM()
|
||||
refreshShapers()
|
||||
|
||||
|
||||
def importAndShapePartialReload():
|
||||
importFromCRM()
|
||||
refreshShapersUpdateOnly()
|
||||
|
||||
|
||||
if __name__ == '__main__':
|
||||
importAndShapeFullReload()
|
||||
# schedule.every().day.at("04:00").do(importAndShapeFullReload)
|
||||
ads.add_job(importAndShapeFullReload, 'cron', hour=4)
|
||||
|
||||
# schedule.every(30).minutes.do(importAndShapePartialReload)
|
||||
ads.add_job(importAndShapePartialReload, 'interval', minutes=30)
|
||||
|
||||
if influxDBEnabled:
|
||||
# schedule.every(10).seconds.do(refreshBandwidthGraphs)
|
||||
ads.add_job(refreshBandwidthGraphs, 'interval', seconds=10)
|
||||
|
||||
# schedule.every(30).seconds.do(refreshLatencyGraphs)
|
||||
# Commented out until refreshLatencyGraphs works in v.14
|
||||
# ads.add_job(refreshLatencyGraphs, 'interval', seconds=30)
|
||||
|
||||
# while True:
|
||||
# schedule.run_pending()
|
||||
# time.sleep(1)
|
||||
|
||||
ads.start()
|
Loading…
Reference in New Issue
Block a user