[Nagiosplug-devel] Patch: check_time returns OK if time is before or equal 1.1.1970
Thomas Guyot-Sionnest
dermoth at aei.ca
Wed May 2 07:29:06 CEST 2007
On 01/05/07 10:15 AM, Matthias Flacke wrote:
> Hello list,
>
> if a machine - perhaps due to a crash - gets a date before 1970
> check_time returns a wrong OK result even if the diff_time seems to be
> reasonable:
>
> $ date
> Thu Jan 1 00:01:01 CET 1970
> $ ./check_time -w 5 -c 10 -H ntp1.fau.de
> TIME OK - 3116935377 second time difference|time=0s;;;0 offset=-1178031919s;5;10;0
>
> The problem lies in the signed var diff_time which can get negative and
> then for sure is smaller than the positive thresholds warning_diff or
> critical_diff.
>
> A small patch changes time_t diff_time into uint32_t and works fine for
> me.
This seems to be very arch-specific; to reproduce it on both my x86_64
and i386 I had to replace time_t by int16_t.
I changed a bit your patch to:
1. Have server_time unsigned long as well (server_time comes from
ntohl() which return type ulong)
2. Remove unneeded casts
The attached patch have been committed to CVS.
Thanks,
Thomas
-------------- next part --------------
A non-text attachment was scrubbed...
Name: check_time.unsigned_diff.patch
Type: text/x-patch
Size: 1609 bytes
Desc: not available
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20070502/11cc86df/attachment.bin>
More information about the Devel
mailing list