Skip to content

Commit

Permalink
Change over bandwidth field tracking to connection ID from IP.
Browse files Browse the repository at this point in the history
  • Loading branch information
jgiszczak committed Aug 14, 2023
1 parent 6b6ea38 commit 09ea0cc
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions tools/net-util.py
Original file line number Diff line number Diff line change
Expand Up @@ -326,19 +326,19 @@ def __init__(self, bytesReceived=0, bytesSent=0, connectionStarted=0):
listwalker[startOffset:endOffset] = [AttrMap(Text(host), None, 'reversed')]
elif fieldName == 'bytes_received':
bytesReceived = int(sample.value)
stats = bandwidths.get(host, bandwidthStats())
stats = bandwidths.get(connID, bandwidthStats())
stats.bytesReceived = bytesReceived
bandwidths[host] = stats
bandwidths[connID] = stats
elif fieldName == 'bytes_sent':
bytesSent = int(sample.value)
stats = bandwidths.get(host, bandwidthStats())
stats = bandwidths.get(connID, bandwidthStats())
stats.bytesSent = bytesSent
bandwidths[host] = stats
bandwidths[connID] = stats
elif fieldName == 'connection_start_time':
connectionStarted = int(sample.value)
stats = bandwidths.get(host, bandwidthStats())
stats = bandwidths.get(connID, bandwidthStats())
stats.connectionStarted = connectionStarted
bandwidths[host] = stats
bandwidths[connID] = stats
else:
attrname = fieldName[:1] + fieldName.replace('_', ' ').title().replace(' ', '')[1:] + 'LW'
if hasattr(self, attrname):
Expand All @@ -361,9 +361,9 @@ def __init__(self, bytesReceived=0, bytesSent=0, connectionStarted=0):
else:
if sample.name == 'nodeos_p2p_connections':
now = time.time_ns()
hostListwalker = getattr(self, 'ipAddressLW')
for host, stats in bandwidths.items():
startOffset = hostListwalker.index(host)
connIDListwalker = getattr(self, 'connectionIDLW')
for connID, stats in bandwidths.items():
startOffset = connIDListwalker.index(connID)
endOffset = startOffset + 1
connected_seconds = (now - stats.connectionStarted)/1000000000
listwalker = getattr(self, 'receiveBandwidthLW')
Expand Down

0 comments on commit 09ea0cc

Please sign in to comment.