Record time spent on actual queue reload, clean up console output

This commit is contained in:
Robert Chacón 2022-09-08 05:43:35 -06:00 committed by GitHub
parent e60f3f4ffd
commit 30da53401b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -21,12 +21,10 @@ def shell(command):
if runShellCommandsAsSudo: if runShellCommandsAsSudo:
command = 'sudo ' + command command = 'sudo ' + command
commands = command.split(' ') commands = command.split(' ')
print(command) #print(command)
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
print(line) result = line
else:
print(command)
def clearPriorSettings(interfaceA, interfaceB): def clearPriorSettings(interfaceA, interfaceB):
if enableActualShellCommands: if enableActualShellCommands:
@ -362,7 +360,7 @@ def refreshShapers():
for device in circuit['devices']: for device in circuit['devices']:
if device['ipv4s']: if device['ipv4s']:
for ipv4 in device['ipv4s']: for ipv4 in device['ipv4s']:
print(tabs + ' ', end='') #print(tabs + ' ', end='')
xdpCPUmapCommands.append('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + str(ipv4) + ' --cpu ' + hex(queue-1) + ' --classid ' + flowIDstring) xdpCPUmapCommands.append('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --add --ip ' + str(ipv4) + ' --cpu ' + hex(queue-1) + ' --classid ' + flowIDstring)
if device['deviceName'] not in devicesShaped: if device['deviceName'] not in devicesShaped:
devicesShaped.append(device['deviceName']) devicesShaped.append(device['deviceName'])
@ -384,7 +382,10 @@ def refreshShapers():
#Here is the actual call to the recursive traverseNetwork() function. finalMinor is not used. #Here is the actual call to the recursive traverseNetwork() function. finalMinor is not used.
finalMinor = traverseNetwork(network, 0, major=1, minor=3, queue=1, parentClassID="1:1", parentMaxDL=upstreamBandwidthCapacityDownloadMbps, parentMaxUL=upstreamBandwidthCapacityUploadMbps) finalMinor = traverseNetwork(network, 0, major=1, minor=3, queue=1, parentClassID="1:1", parentMaxDL=upstreamBandwidthCapacityDownloadMbps, parentMaxUL=upstreamBandwidthCapacityUploadMbps)
#Record start time of actual filter reload
reloadStartTime = datetime.now()
#Clear Prior Settings #Clear Prior Settings
clearPriorSettings(interfaceA, interfaceB) clearPriorSettings(interfaceA, interfaceB)
@ -393,7 +394,8 @@ def refreshShapers():
shell('./xdp-cpumap-tc/bin/xps_setup.sh -d ' + interfaceB + ' --default --disable') shell('./xdp-cpumap-tc/bin/xps_setup.sh -d ' + interfaceB + ' --default --disable')
shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu --dev ' + interfaceA + ' --lan') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu --dev ' + interfaceA + ' --lan')
shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu --dev ' + interfaceB + ' --wan') shell('./xdp-cpumap-tc/src/xdp_iphash_to_cpu --dev ' + interfaceB + ' --wan')
result = os.system('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --clear') if enableActualShellCommands:
result = os.system('./xdp-cpumap-tc/src/xdp_iphash_to_cpu_cmdline --clear')
shell('./xdp-cpumap-tc/src/tc_classify --dev-egress ' + interfaceA) shell('./xdp-cpumap-tc/src/tc_classify --dev-egress ' + interfaceA)
shell('./xdp-cpumap-tc/src/tc_classify --dev-egress ' + interfaceB) shell('./xdp-cpumap-tc/src/tc_classify --dev-egress ' + interfaceB)
@ -426,13 +428,15 @@ def refreshShapers():
#Execute actual Linux TC and XDP-CPUMAP-TC filter commands #Execute actual Linux TC and XDP-CPUMAP-TC filter commands
with open('linux_tc.txt', 'w') as f: with open('linux_tc.txt', 'w') as f:
for line in linuxTCcommands: for line in linuxTCcommands:
print(line)
f.write(f"{line}\n") f.write(f"{line}\n")
print("Executing linux TC class/qdisc commands")
shell("/sbin/tc -f -b linux_tc.txt") shell("/sbin/tc -f -b linux_tc.txt")
print("Executing XDP-CPUMAP-TC IP filter commands")
for command in xdpCPUmapCommands: for command in xdpCPUmapCommands:
shell(command) shell(command)
reloadEndTime = datetime.now()
#Recap #Recap
for circuit in subscriberCircuits: for circuit in subscriberCircuits:
for device in circuit['devices']: for device in circuit['devices']:
@ -444,7 +448,11 @@ def refreshShapers():
json.dump(subscriberCircuits, infile) json.dump(subscriberCircuits, infile)
with open('statsByParentNode.json', 'w') as infile: with open('statsByParentNode.json', 'w') as infile:
json.dump(parentNodes, infile) json.dump(parentNodes, infile)
#Report reload time
reloadTimeSeconds = (reloadEndTime - reloadStartTime).seconds
print("Queue and IP filter reload completed in " + str(reloadTimeSeconds) + " seconds")
# Done # Done
currentTimeString = datetime.now().strftime("%d/%m/%Y %H:%M:%S") currentTimeString = datetime.now().strftime("%d/%m/%Y %H:%M:%S")
print("Successful run completed on " + currentTimeString) print("Successful run completed on " + currentTimeString)