[Nagiosplug-devel] check_ntp (Was: Flight 1.4.8, ready for boarding)

sean finney seanius at seanius.net
Fri Apr 6 00:14:25 CEST 2007

hi thomas,

On Thu, 2007-04-05 at 13:54 -0700, Thomas Guyot-Sionnest wrote:
> I was rather thinking of adding ntp read and write functions that takes a
> pointer to the structure you want to send/receive and the linked list. On
> write it will send the packet then append a node to the linked list with
> some of the headers on success. On read it will remove the matching node
> from the list, drop the request if the packet is not matched, then check the
> error field. The return status could be used to induce various behavior
> (i.e. error, unmatched, nothing to read (empty list or packets too old)).

i still say this is overengineering things though.  why not just do what
we're doing in the offset calculation again?  if we know  how to throw
away stale packets then we don't even have the problem with needing to
duplicate all the fd's, and we know O(n) instead of O(n^2) where a
packet has come from (we already traverse all n fd's to find the ones
with input waiting after a poll).  

i suppose we could set up a single socket and use some form of
non-blocking send/recv* family of functions, but i don't think that it
would fare much better and using poll() is much friendlier and more
efficient than looping around nonblocking reads, and plus then we'd have
to figure from the packet contents where it came from instead of just
knowing by knowing which fd it came from.

> Anyways let me first see how I'm gonna work it out to: 1) Allow multiple
> servers to be specified on the command line, and 2) make the jitter check
> run on every host found.

i don't think either would be too hard, if we just generalized the code
from offset_request().  i would hazard that it could be possible to:

- build a list of supplied hostnames, and generalize the current
  resolution via getaddrinfo to work for a list of hostnames.
- preallocate enough space for all the fd's
- poll() the entire thing after firing off the offset packets.  
- know which sockets belonged to which host for calculating the sync
- use the same set of fd's for jitter and just discard anything that
  arrives too late.  or, filter it and put it back with the offset
  information, and defer the final offset calculation until the 
  very end.

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 191 bytes
Desc: This is a digitally signed message part
URL: <https://www.monitoring-plugins.org/archive/devel/attachments/20070406/3486e869/attachment.sig>

More information about the Devel mailing list