Skip to content

Commit d77c411

Browse files
lyndonsiaolguohan
authored andcommitted
[netstat]: Fix for negative output values of counters after clear counters operation (sonic-net#697)
Immediately after a clear counter operation, the difference between new counter and old counter is negative. Returning 0 in this situation
1 parent fc324f2 commit d77c411

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

utilities_common/netstat.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def ns_diff(newstr, oldstr):
1313
return STATUS_NA
1414
else:
1515
new, old = int(newstr), int(oldstr)
16-
return '{:,}'.format(new - old)
16+
return '{:,}'.format(max(0, new - old))
1717

1818
def ns_brate(newstr, oldstr, delta):
1919
"""

0 commit comments

Comments
 (0)