mirror of
https://github.com/LibreQoE/LibreQoS.git
synced 2025-02-25 18:55:32 -06:00
lqTools.py updated to use unified config
This commit is contained in:
@@ -10,10 +10,11 @@ import subprocess
|
|||||||
import warnings
|
import warnings
|
||||||
import argparse
|
import argparse
|
||||||
import logging
|
import logging
|
||||||
from ispConfig import interfaceA, interfaceB, enableActualShellCommands, upstreamBandwidthCapacityDownloadMbps, upstreamBandwidthCapacityUploadMbps, generatedPNDownloadMbps, generatedPNUploadMbps
|
from liblqos_python import interface_a, interface_b, enable_actual_shell_commands, upstream_bandwidth_capacity_download_mbps, \
|
||||||
|
upstream_bandwidth_capacity_upload_mbps, generated_pn_download_mbps, generated_pn_upload_mbps
|
||||||
|
|
||||||
def shell(command):
|
def shell(command):
|
||||||
if enableActualShellCommands:
|
if enable_actual_shell_commands():
|
||||||
logging.info(command)
|
logging.info(command)
|
||||||
commands = command.split(' ')
|
commands = command.split(' ')
|
||||||
proc = subprocess.Popen(commands, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(commands, stdout=subprocess.PIPE)
|
||||||
@@ -24,7 +25,7 @@ def shell(command):
|
|||||||
|
|
||||||
def safeShell(command):
|
def safeShell(command):
|
||||||
safelyRan = True
|
safelyRan = True
|
||||||
if enableActualShellCommands:
|
if enable_actual_shell_commands():
|
||||||
commands = command.split(' ')
|
commands = command.split(' ')
|
||||||
proc = subprocess.Popen(commands, stdout=subprocess.PIPE)
|
proc = subprocess.Popen(commands, stdout=subprocess.PIPE)
|
||||||
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): # or another encoding
|
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): # or another encoding
|
||||||
@@ -61,7 +62,7 @@ def getQdiscForIPaddress(ipAddress):
|
|||||||
def printStatsFromIP(ipAddress):
|
def printStatsFromIP(ipAddress):
|
||||||
qDiscID = getQdiscForIPaddress(ipAddress)
|
qDiscID = getQdiscForIPaddress(ipAddress)
|
||||||
if qDiscID != None:
|
if qDiscID != None:
|
||||||
interfaces = [interfaceA, interfaceB]
|
interfaces = [interface_a(), interface_b()]
|
||||||
for interface in interfaces:
|
for interface in interfaces:
|
||||||
command = 'tc -s qdisc show dev ' + interface + ' parent ' + qDiscID
|
command = 'tc -s qdisc show dev ' + interface + ' parent ' + qDiscID
|
||||||
commands = command.split(' ')
|
commands = command.split(' ')
|
||||||
@@ -77,7 +78,7 @@ def printCircuitClassInfo(ipAddress):
|
|||||||
print("IP: " + ipAddress + " | Class ID: " + qDiscID)
|
print("IP: " + ipAddress + " | Class ID: " + qDiscID)
|
||||||
print()
|
print()
|
||||||
theClassID = ''
|
theClassID = ''
|
||||||
interfaces = [interfaceA, interfaceB]
|
interfaces = [interface_a(), interface_b()]
|
||||||
downloadMin = ''
|
downloadMin = ''
|
||||||
downloadMax = ''
|
downloadMax = ''
|
||||||
uploadMin = ''
|
uploadMin = ''
|
||||||
@@ -91,7 +92,7 @@ def printCircuitClassInfo(ipAddress):
|
|||||||
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): # or another encoding
|
for line in io.TextIOWrapper(proc.stdout, encoding="utf-8"): # or another encoding
|
||||||
if "htb" in line:
|
if "htb" in line:
|
||||||
listOfThings = line.split(" ")
|
listOfThings = line.split(" ")
|
||||||
if interface == interfaceA:
|
if interface == interface_a():
|
||||||
downloadMin = line.split(' rate ')[1].split(' ')[0]
|
downloadMin = line.split(' rate ')[1].split(' ')[0]
|
||||||
downloadMax = line.split(' ceil ')[1].split(' ')[0]
|
downloadMax = line.split(' ceil ')[1].split(' ')[0]
|
||||||
burst = line.split(' burst ')[1].split(' ')[0]
|
burst = line.split(' burst ')[1].split(' ')[0]
|
||||||
@@ -103,8 +104,8 @@ def printCircuitClassInfo(ipAddress):
|
|||||||
print("Upload rate/ceil: " + uploadMin + "/" + uploadMax)
|
print("Upload rate/ceil: " + uploadMin + "/" + uploadMax)
|
||||||
print("burst/cburst: " + burst + "/" + cburst)
|
print("burst/cburst: " + burst + "/" + cburst)
|
||||||
else:
|
else:
|
||||||
download = min(upstreamBandwidthCapacityDownloadMbps, generatedPNDownloadMbps)
|
download = min(upstream_bandwidth_capacity_download_mbps(), generated_pn_download_mbps())
|
||||||
upload = min(upstreamBandwidthCapacityUploadMbps, generatedPNUploadMbps)
|
upload = min(upstream_bandwidth_capacity_upload_mbps(), generated_pn_upload_mbps())
|
||||||
bwString = str(download) + '/' + str(upload)
|
bwString = str(download) + '/' + str(upload)
|
||||||
print("Invalid IP address provided (default queue limit is " + bwString + " Mbps)")
|
print("Invalid IP address provided (default queue limit is " + bwString + " Mbps)")
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user