Skip to content

Commit

Permalink
[netstat]: Fix for negative output values of counters after clear cou…
Browse files Browse the repository at this point in the history
…nters operation (#697)

Immediately after a clear counter operation, the difference between new
counter and old counter is negative. Returning 0 in this situation
  • Loading branch information
lyndonsiao authored and lguohan committed Oct 18, 2019
1 parent fc324f2 commit d77c411
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion utilities_common/netstat.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def ns_diff(newstr, oldstr):
return STATUS_NA
else:
new, old = int(newstr), int(oldstr)
return '{:,}'.format(new - old)
return '{:,}'.format(max(0, new - old))

def ns_brate(newstr, oldstr, delta):
"""
Expand Down

0 comments on commit d77c411

Please sign in to comment.