[ntp:questions] howto read ntpq output directly?
David L. Mills
mills at udel.edu
Tue Mar 22 03:41:40 UTC 2005
The NTP control/monitoring protocol was specifically crafted to be easy
prey for a simple perl script. The format of the reply packet is
freeform ASCII and is exactly what you see if you turn on raw mode in
ntpq. The packet format is described in Appendix B of RFC-1305. You
would need to send two pcakets, one to retrieve the association IDs, the
second to read the selected association.
mayer at gis.net wrote:
> ----- Original Message Follows -----
>>i have a network of machines that are synchronized by ntpd.
>>i would like to read the output of nptq -c peer directly from
>>my c source code (specifically, i would like to read the tallycode
>>to know if the machines are synced). one ugly way is to
>>system("ntpq -c peer > somefile"), and do some parsing on the output
>>file (looking for * and such). does any of you masters of global
>>time know of a cleaner way to do that?
>>greatly appreciate your oncoming help,
> Take the source code for ntpq and modify it to be a callable interface
> to get what you want. If you do this we'd appreciate it if you can
> contribute this back so we can incorporate it in out source code and
> take advantage of it. Right now it's not very modular.
More information about the questions