When MongoDB freezes or restarts, do not report negative diffs

Fixes #253
This commit is contained in:
Cameron Sparr 2015-10-22 10:55:26 -06:00
parent 2f08577967
commit eb0a19062e
1 changed files with 5 additions and 1 deletions

View File

@ -367,7 +367,11 @@ func computeLockDiffs(prevLocks, curLocks map[string]LockUsage) []LockUsage {
}
func diff(newVal, oldVal, sampleTime int64) int64 {
return (newVal - oldVal) / sampleTime
d := newVal - oldVal
if d <= 0 {
d = newVal
}
return d / sampleTime
}
// NewStatLine constructs a StatLine object from two ServerStatus objects.