Permalink
Browse files

Check that diff is not negative

  • Loading branch information...
vvuksan committed Jan 21, 2014
1 parent bbf8cf3 commit 133c19518dcc4486e878829d5a9a361e09a11216
Showing with 6 additions and 0 deletions.
  1. +6 −0 diskstat/python_modules/diskstat.py
@@ -342,6 +342,12 @@ def get_diff(dev, key, val, convert=1):
else:
stats[dev][key] = 0
+ # If for some reason we have a negative diff we should assume counters reset
+ # and should set it back to 0
+ if stats[dev][key] < 0:
+ stats[dev][key] = 0
+
+
last_val[dev][key] = val
def get_stat(name):

0 comments on commit 133c195

Please sign in to comment.