mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2024-11-22 08:16:25 -06:00
Update graphInfluxDB.py
This commit is contained in:
parent
7e64ffbff1
commit
c3b213b35f
@ -13,13 +13,6 @@ from influxdb_client.client.write_api import SYNCHRONOUS
|
||||
|
||||
from ispConfig import interfaceA, interfaceB, influxDBEnabled, influxDBBucket, influxDBOrg, influxDBtoken, influxDBurl, sqm
|
||||
|
||||
class exceptionWithMessage(Exception):
|
||||
def __init__(self, message, detail = None):
|
||||
self.message = message
|
||||
trace = "not able to retrieve trace"
|
||||
trace = traceback.format_exc()
|
||||
super().__init__(self.message)
|
||||
|
||||
def getInterfaceStats(interface):
|
||||
command = 'tc -j -s qdisc show dev ' + interface
|
||||
jsonAr = json.loads(subprocess.run(command.split(' '), stdout=subprocess.PIPE).stdout.decode('utf-8'))
|
||||
@ -36,8 +29,6 @@ def chunk_list(l, n):
|
||||
yield l[i:i + n]
|
||||
|
||||
def getCircuitBandwidthStats(subscriberCircuits, tinsStats):
|
||||
|
||||
try:
|
||||
interfaces = [interfaceA, interfaceB]
|
||||
ifaceStats = list(map(getInterfaceStats, interfaces))
|
||||
|
||||
@ -100,17 +91,6 @@ def getCircuitBandwidthStats(subscriberCircuits, tinsStats):
|
||||
|
||||
if element:
|
||||
bytesSent = float(element['bytes'])
|
||||
|
||||
""" if "priorQuery" in circuit['stats']:
|
||||
if bytesSent - circuit['stats']['priorQuery']['bytesSentDownload'] < 0.0:
|
||||
exceptionWithMessage(
|
||||
"Less download data usage now versus the past, this should not be possible.",
|
||||
{
|
||||
"circuit": json.dumps(circuit),
|
||||
"element": json.dumps(element)
|
||||
}
|
||||
) """
|
||||
|
||||
drops = float(element['drops'])
|
||||
packets = float(element['packets'])
|
||||
if (element['drops'] > 0) and (element['packets'] > 0):
|
||||
@ -212,7 +192,7 @@ def getCircuitBandwidthStats(subscriberCircuits, tinsStats):
|
||||
priorQueryTime = datetime.fromisoformat(circuit['stats']['priorQuery']['time'])
|
||||
deltaSeconds = (currentQueryTime - priorQueryTime).total_seconds()
|
||||
if deltaSeconds < 0:
|
||||
exceptionWithMessage("Current query time ({}) is before last query time ({}), time sync may be broken. serviceId is {}. Name is: {}.".format(currentQueryTime, priorQueryTime, circuit['circuitID'], circuit['circuitName']))
|
||||
print("Current query time ({}) is before last query time ({}), time sync may be broken. serviceId is {}. Name is: {}.".format(currentQueryTime, priorQueryTime, circuit['circuitID'], circuit['circuitName']))
|
||||
circuit['stats']['sinceLastQuery']['bitsDownload'] = round((circuit['stats']['sinceLastQuery']['bytesSentDownload'] * 8) / deltaSeconds) if deltaSeconds > 0 else 0
|
||||
circuit['stats']['sinceLastQuery']['bitsUpload'] = round((circuit['stats']['sinceLastQuery']['bytesSentUpload'] * 8) / deltaSeconds) if deltaSeconds > 0 else 0
|
||||
else:
|
||||
@ -227,13 +207,6 @@ def getCircuitBandwidthStats(subscriberCircuits, tinsStats):
|
||||
|
||||
return subscriberCircuits, tinsStats
|
||||
|
||||
except exceptionWithMessage:
|
||||
print("There was an exception but it was caught and sent to Spike. Will try again next time around.")
|
||||
except Exception as e:
|
||||
exceptionWithMessage("getCircuitBandwidthStats: {}".format(e))
|
||||
except:
|
||||
exceptionWithMessage("getCircuitBandwidthStats")
|
||||
|
||||
def buildTinStats(data, allPacketsDownload, allPacketsUpload):
|
||||
# data is the dictionary that we want to do the calculations for, usually circuit['tinsStats'] or tinsStats.
|
||||
allPackets = {
|
||||
|
Loading…
Reference in New Issue
Block a user