[ntp:questions] C api to ntpd

Patrik Arlos patrik.arlos at gmail.com
Fri Dec 6 12:13:17 UTC 2013


Hello,

I have a C program that needs to evaluate the system (where it runs) clock synchronization status on a regular interval(every ~60s). On the same system there is a ntpd running, that synchronized to other ntp servers. 

I can write a simple bash script that does this (saving to an intermediate file, then read by the C program), or I can implement a minimized ntp client that probes the local server. 

But I was hoping that there would be a simple api (library?) that would allow me to do this, without having to interface with the ntpd via a socket call or by calling an external program from the C program. 

The information that I'm looking for is 
* Is the server synchronized to any server, i.e. the presence of '*' for any of the servers. 
If there is a server that is '*'
* What is the delay associated with that server?
* What is the offset associated with that server? 

I've looked around to find some API/library that provides this, but obviously I have not found it. 

I might be going about this in a completely incorrect way, if so, please enlighten me. 

BR/Patrik



More information about the questions mailing list