]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - usr.sbin/xntpd/doc/ntpq.8
This commit was generated by cvs2svn to compensate for changes in r38494,
[FreeBSD/FreeBSD.git] / usr.sbin / xntpd / doc / ntpq.8
1 .\"
2 .\"     $Id$
3 .\"
4 .Dd December 21, 1993
5 .Dt NTPQ 8
6 .Os
7 .Sh NAME
8 .Nm ntpq
9 .Nd standard Network Time Protocol query program
10 .Sh SYNOPSIS
11 .Nm
12 .Op Fl inp
13 .Op Fl c Ar command
14 .Op Ar host ...
15 .Sh DESCRIPTION
16 .Nm Ntpq
17 is used to query NTP servers which implement the recommended NTP mode 6
18 control message format about current state and to request changes in
19 that state. The program may be run either in interactive mode or
20 controlled using command line arguments. Requests to read and write
21 arbitrary variables can be assembled, with raw and pretty\-printed
22 output options being available.
23 .Nm Ntpq
24 can also obtain and print a list of peers in a common format by sending
25 multiple queries to the server.
26 .Pp
27 If one or more request options is included on the command line when
28 .Nm
29 is executed, each of the requests will be sent to the NTP servers
30 running on each of the hosts given as command line arguments, or on
31 .Ar localhost
32 by default. If no request options are given,
33 .Nm
34 will attempt to read commands from the standard input and execute these
35 on the NTP server running on the first host given on the command line,
36 again
37 defaulting to
38 .Ar localhost
39 when no other host is specified.
40 .Nm Ntpq
41 will prompt for commands if the standard input is a terminal device.
42 .Pp
43 .Nm Ntpq
44 uses NTP mode 6 packets to communicate with the NTP server, and hence
45 can be used to query any compatable server on the network which permits
46 it. Note that since NTP is a UDP protocol this communication will be
47 somewhat unreliable, especially over large distances in terms of network
48 topology.
49 .Nm Ntpq
50 makes one attempt to retransmit requests, and will time requests out if
51 the remote host is not heard from within a suitable time out time.
52 .Pp
53 Command line options are described following. Specifying a command line
54 option other than
55 .Fl i
56 or
57 .Fl n
58 will cause the specified query (queries) to be sent to the indicated
59 host(s) immediately. Otherwise,
60 .Nm
61 will attempt to read interactive format commands from the standard
62 input.
63 The following options are available:
64 .Bl -tag -width indent
65 .It Fl c Ar command
66 The following argument is interpreted as an interactive format
67 .Ar command
68 and is added to the list of commands to be executed on the specified
69 host(s). Multiple
70 .Fl c
71 options may be given.
72 .It Fl i
73 Force
74 .Nm
75 to operate in interactive mode. Prompts will be written to the standard
76 output and commands read from the standard input.
77 .It Fl n
78 Output all host addresses in dotted\-quad numeric format rather than
79 converting to the canonical host names.
80 .It Fl p
81 Print a list of the peers known to the server as well as a summary of
82 their state. This is equivalent to the
83 .Em peers
84 interactive command.
85 .El
86 .Sh INTERNAL COMMANDS
87 .Pp
88 Interactive format commands consist of a keyword followed by zero to
89 four arguments. Only enough characters of the full keyword to uniquely
90 identify the command need be typed. The output of a command is normally
91 sent to the standard output, but optionally the output of individual
92 commands may be sent to a file by appending a
93 .Qq > ,
94 followed by a file name, to the command line.
95 .Pp
96 A number of interactive format commands are executed entirely within the
97 .Nm
98 program itself and do not result in NTP mode 6 requests being sent to a
99 server. These are described following.
100 .Pp
101 .Bl -tag -width indent
102 .It ? Op Ar command_keyword
103 A
104 .Qq ?
105 by itself will print a list of all the command keywords
106 known to this incarnation of
107 .Nm Ns .
108 A
109 .Qq ?
110 followed by a command keyword will print function and
111 usage information about the command. This command is probably a better
112 source of information about
113 .Nm
114 than this manual page.
115 .It timeout Ar milliseconds
116 Specify a time out period for responses to server queries. The default
117 is about 5000 milliseconds. Note that since
118 .Nm
119 retries each query once after a time out the total waiting time for a
120 time out will be twice the time out value set.
121 .It delay Ar milliseconds
122 Specify a time interval to be added to timestamps included in requests
123 which require authentication. This is used to enable (unreliable) server
124 reconfiguration over long delay network paths or between machines whose
125 clocks are unsynchronized. Actually the server does not now require time
126 stamps in authenticated requests, so this command may be obsolete.
127 .It host Ar hostname
128 Set the host to which future queries will be sent.
129 .Ar Hostname
130 may be either a host name or a numeric
131 address.
132 .It Xo poll
133 .Op Ar #
134 .Op Ar verbose
135 .Xc
136 Poll the current server in client mode. The first argument is the number
137 of times to poll (default is 1) while the second argument may be given
138 to obtain a more detailed output of the results. This command is
139 currently just wishful thinking.
140 .It keyid Ar #
141 This command allows the specification of a key number to be used to
142 authenticate configuration requests. This must correspond to a key
143 number the server has been configured to use for this purpose.
144 .It passwd
145 This command prompts you to type in a password (which will not be
146 echoed) which will be used to authenticate configuration requests. The
147 password must correspond to the key configured for use by the NTP server
148 for this purpose if such requests are to be successful.
149 .It hostnames Ar yes | Ar no
150 If
151 .Ar yes
152 is specified, host names are printed in information
153 displays. If
154 .Ar no
155 is given, numeric addresses are printed
156 instead. The default is
157 .Ar yes
158 unless modified using the command line
159 .Fl n
160 switch.
161 .It raw
162 Cause all output from query commands is printed as received from the
163 remote server. The only formating/intepretation done on the data is to
164 transform nonascii data into a printable (but barely understandable)
165 form.
166 .It cooked
167 Cause output from query commands to be
168 .Qq cooked Ns .
169 Variables
170 which are recognized by the server will have their values reformatted
171 for human consumption. Variables which
172 .Nm
173 thinks should have a decodeable value but didn't are marked with a
174 trailing
175 .Qq ? Ns .
176 .It ntpversion Ar 1 | Ar 2 | Ar 3
177 Set the NTP version number which
178 .Nm
179 claims in packets. Defaults to 3, Note that mode 6 control messages (and
180 modes, for that matter) didn't exist in NTP version 1. There appear to
181 be no servers left which demand version 1.
182 .It authenticate Ar yes | Ar no
183 Normally
184 .Nm
185 does not authenticate requests unless they are write requests. The
186 command
187 .Em authenticate yes
188 causes
189 .Nm
190 to send authentication with all requests it makes. Authenticated
191 requests causes some servers to handle requests slightly differently,
192 and can occasionally melt the CPU in fuzzballs if you turn
193 authentication on before doing a peer display.
194 .It Xo addvars
195 .Aq variable_name Ns
196 .Op = Ns Aq value Ns
197 .Op ,...
198 .Xc
199 .It Xo rmvars
200 .Aq variable_name Ns
201 .Op ,...
202 .Xc
203 .It clearvars
204 The data carried by NTP mode 6 messages consists of a list of items of
205 the form
206 .Xo Aq variable_name Ns
207 .Pf = Aq value
208 .Xc
209 where the
210 .Qq = Ns Aq value
211 is ignored, and can be omitted, in requests
212 to the server to read variables.
213 .Nm Ntpq
214 maintains an internal list in which data to be included in control
215 messages can be assembled, and sent using the
216 .Em readlist
217 and
218 .Em writelist
219 commands described below. The
220 .Em addvars
221 command allows variables and their optional values to be added to the
222 list. If more than one variable is to be added, the list should be
223 comma\-separated and not contain white space. The
224 .Em rmvars
225 command can be used to remove individual variables from the list, while
226 the
227 .Em clearlist
228 command removes all variables from the list.
229 .It debug Ar more | Ar less | Ar off
230 Turn internal query program debugging on and off.
231 .It quit
232 Exit
233 .Nm Ns .
234 .El
235 .Sh CONTROL MESSAGE COMMANDS
236 Each peer known to an NTP server has a 16 bit integer
237 .Em association identifier
238 assigned to it. NTP control messages which carry peer variables must
239 identify the peer the values correspond to by including its association
240 ID. An association ID of 0 is special, and indicates the variables are
241 system variables, whose names are drawn from a separate name space.
242 .Pp
243 Control message commands result in one or more NTP mode 6 messages being
244 sent to the server, and cause the data returned to be printed in some
245 format. Most commands currently implemented send a single message and
246 expect a single response. The current exceptions are the
247 .Em peers
248 command, which will send a preprogrammed series of messages to obtain
249 the data it needs, and the
250 .Em mreadlist
251 and
252 .Em mreadvar
253 commands, which will iterate over a range of associations.
254 .Bl -tag -width indent
255 .It associations
256 Obtain and print a list of association identifiers and peer statuses
257 for in\-spec peers of the server being queried. The list is printed in
258 columns. The first of these is an index numbering the associations from
259 1 for internal use, the second the actual association identifier
260 returned by the server and the third the status word for the peer. This
261 is followed by a number of columns containing data decoded from the
262 status word. Note that the data returned by the \*(L"associations\*(R"
263 command is cached internally in
264 .Nm Ns .
265 The index is then of use when dealing with stupid servers which use
266 association identifiers which are hard for humans to type, in that for
267 any subsequent commands which require an association identifier as an
268 argument, the form
269 .Em &index
270 may be used as an alternative.
271 .It lassocations
272 Obtain and print a list of association identifiers and peer statuses
273 for all associations for which the server is maintaining state. This
274 command differs from the
275 .Em associations
276 command only for servers
277 which retain state for out\-of\-spec client associations (i.e.
278 fuzzballs). Such associations are normally omitted from the display when
279 the
280 .Em associations
281 command is used, but are included in the
282 output of
283 .Em lassociations Ns .
284 .It passociations
285 Print association data concerning in\-spec peers from the internally
286 cached list of associations. This command performs identically to the
287 .Em associations
288 except that it displays the internally stored
289 data rather than making a new query.
290 .It lpassociations
291 Print data for all associations, including out\-of\-spec client
292 associations, from the internally cached list of associations. This
293 command differs from
294 .Em passociations
295 only when dealing with fuzzballs.
296 .It pstatus Ar assocID
297 Send a read status request to the server for the given association. The
298 names and values of the peer variables returned will be printed. Note
299 that the status word from the header is displayed preceding the
300 variables, both in hexadecimal and in pidgin English.
301 .It Xo readvar
302 .Op Ar assocID Ns
303 .Pf [ Aq variable_name Ns
304 .Op = Ns Aq value Ns
305 .Op ,...]
306 .Xc
307 Request that the values of the specified variables be returned by the
308 server by sending a read variables request. If the association ID is
309 omitted or is given as zero the variables are system variables,
310 otherwise they are peer variables and the values returned will be those
311 of the corresponding peer. Omitting the variable list will send a
312 request with no data which should induce the server to return a default
313 display.
314 .It Xo rv
315 .Op Ar assocID Ns
316 .Pf [ Aq variable_name Ns
317 .Op = Ns Aq value Ns
318 .Op ,...]
319 .Xc 
320 An easy\-to\-type short form for the
321 .Em readvar
322 command.
323 .It Xo writevar
324 .Ar assocID
325 .Aq variable_name Ns
326 .Pf = Ns Aq value Ns
327 .Op ,...
328 .Xc
329 Like the
330 .Em readvar
331 request, except the specified variables are written instead of read.
332 .It readlist Op Ar assocID
333 Request that the values of the variables in the internal variable list
334 be returned by the server. If the association ID is omitted or is 0 the
335 variables are assumed to be system variables. Otherwise they are treated
336 as peer variables. If the internal variable list is empty a request is
337 sent without data, which should induce the remote server to return a
338 default display.
339 .It rl Op Ar assocID
340 An easy\-to\-type short form of the
341 .Em readlist
342 command.
343 .It writelist Op Ar assocID
344 Like the
345 .Em readlist
346 request, except the internal list variables are written instead of read.
347 .It Xo mreadvar
348 .Ar assocID assocID [
349 .Aq variable_name Ns
350 .Op = Ns Aq value Ns
351 .Op ,...]
352 .Xc
353 Like the
354 .Em readvar
355 command except the query is done for each of a range of (nonzero)
356 association IDs. This range is determined from the association list
357 cached by the most recent
358 .Em associations
359 command.
360 .It Xo mrv
361 .Ar assocID assocID [
362 .Aq variable_name Ns
363 .Op = Ns Aq value Ns
364 .Op ,...]
365 .Xc
366 An easy\-to\-type short form of the
367 .Em mreadvar
368 command.
369 .It mreadlist Ar assocID assocID
370 Like the
371 .Em readlist
372 command except the query is done for each of a range of (nonzero)
373 association IDs. This range is determined from the association list
374 cached by the most recent
375 .Em associations
376 command.
377 .It mrl Ar assocID assocID
378 An easy\-to\-type short form of the
379 .Em mreadlist
380 command.
381 .It Xo clockvar
382 .Op Ar assocID Ns
383 .Pf [ Aq variable_name Ns
384 .Op = Ns Aq value Ns
385 .Op ,...]
386 .Xc
387 Request that a list of the server's clock variables be sent. Servers
388 which have a radio clock or other external synchronization will respond
389 positively to this. If the association identifier is omitted or zero the
390 request is for the variables of the
391 .Qq system clock
392 and will
393 generally get a positive response from all servers with a clock. If the
394 server treats clocks as pseudo\-peers, and hence can possibly have more
395 than one clock connected at once, referencing the appropriate peer
396 association ID will show the variables of a particular clock. Omitting
397 the variable list will cause the server to return a default variable
398 display.
399 .It Xo cv
400 .Op Ar assocID Ns
401 .Pf [ Aq variable_name Ns
402 .Op = Ns Aq value Ns
403 .Op ,...]
404 .Xc
405 An easy\-to\-type short form of the
406 .Em clockvar
407 command.
408 .It peers
409 Obtain a list of in\-spec peers of the server, along with a summary of
410 each peer's state. Summary information includes the address of the
411 remote peer, the reference ID (0.0.0.0 if the refID is unknown), the
412 stratum of the remote peer, the type of the peer (local, unicast,
413 multicast or broadcast), when the last packet was received, the polling
414 interval, in seconds, the reachability register, in octal, and the
415 current estimated delay, offset and dispersion of the peer, all in
416 seconds.
417 .Pp
418 The character in the left margin indicates the fate of this peer in the
419 clock selection process. The codes mean: <sp> discarded due to high
420 stratum and/or failed sanity checks;
421 .Qq x
422 designated falsticker
423 by the intersection algorithm;
424 .Qq .
425 culled from the end of the
426 candidate list;
427 .Qq -
428 discarded by the clustering algorithm;
429 .Qq +
430 included in the final selection set;
431 .Qq #
432 selected
433 for synchronization but distance exceeds maximum;
434 .Qq *
435 selected
436 for synchronization; and
437 .Qq o
438 selected for synchronization, pps
439 signal in use.
440 .Pp
441 Note that since the
442 .Em peers
443 command depends on the ability to parse the values in the responses it
444 gets it may fail to work from time to time with servers which poorly
445 control the data formats.
446 .Pp
447 The contents of the host field may be one of four forms. It may be a
448 host name, an IP address, a reference clock implementation name with its
449 parameter or
450 .Qq REFCLK(<implementation number>, <parameter>) .
451 On
452 .Qq hostnames no
453 only IP\-addresses will be displayed.
454 .It lpeers
455 Like
456 .Em peers ,
457 except a summary of all associations for which the server is maintaining
458 state is printed. This can produce a much longer list of peers from
459 fuzzball servers.
460 .It opeers
461 An old form of the
462 .Em peers
463 command with the reference ID
464 replaced by the local interface address.
465 .El
466 .Sh HISTORY
467 Written by
468 .An Dennis Ferguson
469 at the University of Toronto.
470 .Sh BUGS
471 The
472 .Em peers
473 command is non\-atomic and may occasionally result in spurious error
474 messages about invalid associations occurring and terminating the
475 command.
476 .Pp
477 The timeout time is a fixed constant, which means you wait a long time
478 for time outs since it assumes sort of a worst case. The program should
479 improve the time out estimate as it sends queries to a particular host,
480 but doesn't.