|
| 1 | +diff --git a/scripts/portstat b/scripts/portstat |
| 2 | +index 42757d3..81761ea 100644 |
| 3 | +--- a/scripts/portstat |
| 4 | ++++ b/scripts/portstat |
| 5 | +@@ -251,13 +251,13 @@ class Portstat(object): |
| 6 | + table.append((key, self.get_port_state(key), |
| 7 | + ns_diff(cntr.rx_ok, old_cntr.rx_ok), |
| 8 | + ns_brate(cntr.rx_byt, old_cntr.rx_byt, time_gap), |
| 9 | +- ns_util(cntr.rx_byt, old_cntr.rx_byt, time_gap), |
| 10 | ++ ns_util(cntr.rx_byt, old_cntr.rx_byt, time_gap, port_speed), |
| 11 | + ns_diff(cntr.rx_err, old_cntr.rx_err), |
| 12 | + ns_diff(cntr.rx_drop, old_cntr.rx_drop), |
| 13 | + ns_diff(cntr.rx_ovr, old_cntr.rx_ovr), |
| 14 | + ns_diff(cntr.tx_ok, old_cntr.tx_ok), |
| 15 | + ns_brate(cntr.tx_byt, old_cntr.tx_byt, time_gap), |
| 16 | +- ns_util(cntr.tx_byt, old_cntr.tx_byt, time_gap), |
| 17 | ++ ns_util(cntr.tx_byt, old_cntr.tx_byt, time_gap, port_speed), |
| 18 | + ns_diff(cntr.tx_err, old_cntr.tx_err), |
| 19 | + ns_diff(cntr.tx_drop, old_cntr.tx_drop), |
| 20 | + ns_diff(cntr.tx_ovr, old_cntr.tx_ovr))) |
| 21 | +diff --git a/utilities_common/netstat.py b/utilities_common/netstat.py |
| 22 | +index 9bf266e..a8d62b5 100755 |
| 23 | +--- a/utilities_common/netstat.py |
| 24 | ++++ b/utilities_common/netstat.py |
| 25 | +@@ -23,10 +23,10 @@ def ns_brate(newstr, oldstr, delta): |
| 26 | + return STATUS_NA |
| 27 | + else: |
| 28 | + rate = int(ns_diff(newstr, oldstr).replace(',',''))/delta |
| 29 | +- if rate > 1024*1024*10: |
| 30 | +- rate = "{:.2f}".format(rate/1024/1024)+' MB' |
| 31 | +- elif rate > 1024*10: |
| 32 | +- rate = "{:.2f}".format(rate/1024)+' KB' |
| 33 | ++ if rate > 1000*1000*10: |
| 34 | ++ rate = "{:.2f}".format(rate/1000/1000)+' MB' |
| 35 | ++ elif rate > 1000*10: |
| 36 | ++ rate = "{:.2f}".format(rate/1000)+' KB' |
| 37 | + else: |
| 38 | + rate = "{:.2f}".format(rate)+' B' |
| 39 | + return rate+'/s' |
| 40 | +@@ -49,7 +49,7 @@ def ns_util(newstr, oldstr, delta, port_rate=PORT_RATE): |
| 41 | + return STATUS_NA |
| 42 | + else: |
| 43 | + rate = int(ns_diff(newstr, oldstr).replace(',',''))/delta |
| 44 | +- util = rate/(port_rate*1024*1024*1024/8.0)*100 |
| 45 | ++ util = rate/(port_rate*1000*1000*1000/8.0)*100 |
| 46 | + return "{:.2f}%".format(util) |
| 47 | + |
| 48 | + def table_as_json(table, header): |
0 commit comments