tm_format_time output changes by +/1 second

Ondrej Zajicek santiago at crfreenet.org
Tue Feb 5 15:26:08 CET 2019


On Sun, Feb 03, 2019 at 04:37:36PM +0300, Ilya Evseev wrote:
>   Hi all!
> There is a problem in time output.
> Consider timeformat protocol "%Y-%m-%d %H:%M:%S";
> ...
> As you can see, time is changed by 1 second.
> That's bad for monitoring when it's configured to alert on time/state
> changes.

Hi

Yes, that is a general result of how timestamps are stored and processed.
It is partially hidden in 2.0 due to higher precision (so it oscillates
by just 1 us instead of 1 s, which is usually hidden by rounding to ms).

We could fix that by keeping delta between monotonic time and wall-clock
time instead of computing it repeatedly, and updating it only after
nontrivial change, but even that would cause change of reported time when
NTP updates wall-clock time due to clock drift.

> Quick fix for me:

Results of that quick fix depend on OS and kernel version, it would be
stable, but in many cases it would take boot as start of epoch (i.e. would
report dates like 1970-01-01).

-- 
Elen sila lumenn' omentielvo

Ondrej 'Santiago' Zajicek (email: santiago at crfreenet.org)
OpenPGP encrypted e-mails preferred (KeyID 0x11DEADC3, wwwkeys.pgp.net)
"To err is human -- to blame it on a computer is even more so."


More information about the Bird-users mailing list