Skip to content

Commit

Permalink
Fixed porstat rate and util issues (sonic-net#1140)
Browse files Browse the repository at this point in the history
Changed size factor from 1024 to 1000 for rate throughput calculation.
  • Loading branch information
rajkumar38 authored Nov 20, 2020
1 parent eb38aeb commit be834be
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions utilities_common/netstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,10 @@ def ns_brate(newstr, oldstr, delta):
return STATUS_NA
else:
rate = int(ns_diff(newstr, oldstr).replace(',',''))/delta
if rate > 1024*1024*10:
rate = "{:.2f}".format(rate/1024/1024)+' MB'
elif rate > 1024*10:
rate = "{:.2f}".format(rate/1024)+' KB'
if rate > 1000*1000*10:
rate = "{:.2f}".format(rate/1000/1000)+' MB'
elif rate > 1000*10:
rate = "{:.2f}".format(rate/1000)+' KB'
else:
rate = "{:.2f}".format(rate)+' B'
return rate+'/s'
Expand All @@ -53,7 +53,7 @@ def ns_util(newstr, oldstr, delta, port_rate=PORT_RATE):
return STATUS_NA
else:
rate = int(ns_diff(newstr, oldstr).replace(',',''))/delta
util = rate/(port_rate*1024*1024*1024/8.0)*100
util = rate/(port_rate*1000*1000*1000/8.0)*100
return "{:.2f}%".format(util)

def table_as_json(table, header):
Expand Down

0 comments on commit be834be

Please sign in to comment.