DataDog/dd-agent — pull request #977 by Tenzer (2014-06-12 08:50:33+00:00)
Title: Postgres: Handle negative replication delay

In case the master and slave's clocks are slightly out of sync, and there is virtually no replication delay, we may experience that a negative timedelta in the replication delay check. That is however not detected in the current code, as Python sets the `days` property to `-1` and `seconds` to `86400`, in order to not have a negative number in the `seconds` property.

This change checks if `days` is a negative number, and if it is, we always send 0 seconds as the replication delay.

There's an example of how it can look if it isn't fixed here:
![replication-delay-example](https://cloud.githubusercontent.com/assets/68696/3255721/8bc5c8fa-f20e-11e3-8c5b-de251f355b37.png)