1ntpq(8) System Manager's Manual ntpq(8)
2
3
4
6 ntpq - standard NTP query program
7
8
10 ntpq [-46dinp] [-c command] [host] [...]
11
12
14 The ntpq utility program is used to monitor NTP daemon ntpd operations
15 and determine performance. It uses the standard NTP mode 6 control mes‐
16 sage formats defined in Appendix B of the NTPv3 specification RFC1305.
17 The same formats are used in NTPv4, although some of the variable names
18 have changed and new ones added. The description on this page is for
19 the NTPv4 variables.
20
21 The program can be run either in interactive mode or controlled using
22 command line arguments. Requests to read and write arbitrary variables
23 can be assembled, with raw and pretty-printed output options being
24 available. The ntpq can also obtain and print a list of peers in a com‐
25 mon format by sending multiple queries to the server.
26
27 If one or more request options is included on the command line when
28 ntpq is executed, each of the requests will be sent to the NTP servers
29 running on each of the hosts given as command line arguments, or on
30 localhost by default. If no request options are given, ntpq will
31 attempt to read commands from the standard input and execute these on
32 the NTP server running on the first host given on the command line,
33 again defaulting to localhost when no other host is specified. ntpq
34 will prompt for commands if the standard input is a terminal device.
35
36 ntpq uses NTP mode 6 packets to communicate with the NTP server, and
37 hence can be used to query any compatible server on the network which
38 permits it. Note that since NTP is a UDP protocol this communication
39 will be somewhat unreliable, especially over large distances in terms
40 of network topology. ntpq makes one attempt to retransmit requests, and
41 will time requests out if the remote host is not heard from within a
42 suitable timeout time.
43
44 Note that in contexts where a host name is expected, a -4 qualifier
45 preceding the host name forces DNS resolution to the IPv4 namespace,
46 while a -6 qualifier forces DNS resolution to the IPv6 namespace.
47
48 For examples and usage, see the NTP Debugging Techniques page.
49
50 Command line options are described following. Specifying a command line
51 option other than -i or -n will cause the specified query (queries) to
52 be sent to the indicated host(s) immediately. Otherwise, ntpq will
53 attempt to read interactive format commands from the standard input.
54
55
56 -4 Force DNS resolution of following host names on the command
57 line to the IPv4 namespace.
58
59 -6 Force DNS resolution of following host names on the command
60 line to the IPv6 namespace.
61
62 -c The following argument is interpreted as an interactive format
63 command and is added to the list of commands to be executed on
64 the specified host(s). Multiple -c options may be given.
65
66 -d Turn on debugging mode.
67
68 -i Force ntpq to operate in interactive mode. Prompts will be
69 written to the standard output and commands read from the stan‐
70 dard input.
71
72 -n Output all host addresses in dotted-quad numeric format rather
73 than converting to the canonical host names.
74
75 -p Print a list of the peers known to the server as well as a sum‐
76 mary of their state. This is equivalent to the peers interac‐
77 tive command.
78
79
81 Interactive format commands consist of a keyword followed by zero to
82 four arguments. Only enough characters of the full keyword to uniquely
83 identify the command need be typed. The output of a command is normally
84 sent to the standard output, but optionally the output of individual
85 commands may be sent to a file by appending a >, followed by a file
86 name, to the command line. A number of interactive format commands are
87 executed entirely within the ntpq program itself and do not result in
88 NTP mode-6 requests being sent to a server. These are described follow‐
89 ing.
90
91
92 ? [command_keyword]
93
94 help [command_keyword]
95 A ? by itself will print a list of all the command keywords
96 known to ntpq. A ? followed by a command keyword will print
97 function and usage information about the command.
98
99 addvars name [ = value] [...]
100
101 rmvars name [...]
102
103 clearvars
104 The arguments to this command consist of a list of items of the
105 form name = value, where the = value is ignored, and can be
106 omitted in read requests. ntpq maintains an internal list in
107 which data to be included in control messages can be assembled,
108 and sent using the readlist and writelist commands described
109 below. The addvars command allows variables and optional values
110 to be added to the list. If more than one variable is to be
111 added, the list should be comma-separated and not contain white
112 space. The rmvars command can be used to remove individual
113 variables from the list, while the clearlist command removes
114 all variables from the list.
115
116 cooked Display server messages in prettyprint format.
117
118 debug more | less | off
119 Turns internal query program debugging on and off.
120
121 delay milliseconds
122 Specify a time interval to be added to timestamps included in
123 requests which require authentication. This is used to enable
124 (unreliable) server reconfiguration over long delay network
125 paths or between machines whose clocks are unsynchronized.
126 Actually the server does not now require timestamps in authen‐
127 ticated requests, so this command may be obsolete.
128
129 host name
130 Set the host to which future queries will be sent. The name may
131 be either a DNS name or a numeric address.
132
133 hostnames [yes | no]
134 If yes is specified, host names are printed in information dis‐
135 plays. If no is specified, numeric addresses are printed
136 instead. The default is yes, unless modified using the command
137 line -n switch.
138
139 keyid keyid
140 This command specifies the key number to be used to authenti‐
141 cate configuration requests. This must correspond to a key num‐
142 ber the server has been configured to use for this purpose.
143
144 ntpversion 1 | 2 | 3 | 4
145 Sets the NTP version number which ntpq claims in packets.
146 Defaults to 2, Note that mode-6 control messages (and modes,
147 for that matter) didn't exist in NTP version 1.
148
149 passwd This command prompts for a password to authenticate configura‐
150 tion requests. The password must correspond to the key config‐
151 ured for NTP server for this purpose.
152
153 quit Exit ntpq.
154
155 raw Display server messages as received and without reformatting.
156
157 timeout milliseconds
158 Specify a timeout period for responses to server queries. The
159 default is about 5000 milliseconds. Note that since ntpq
160 retries each query once after a timeout, the total waiting time
161 for a timeout will be twice the timeout value set.
162
163
165 Association IDs are used to identify system, peer and clock variables.
166 System variables are assigned an association ID of zero and system name
167 space, while each association is assigned a nonzero association ID and
168 peer namespace. Most control commands send a single mode-6 message to
169 the server and expect a single response message. The exceptions are the
170 peers command, which sends a series of messages, and the mreadlist and
171 mreadvar commands, which iterate over a range of associations.
172
173
174 associations
175 Display a list of mobilized associations in the form ind assid
176 status conf reach auth condition last_event cnt
177
178
179 ┌──────────┬───────────────────────────────────────────────────────────────┐
180 │Variable │Description │
181 ├──────────┼───────────────────────────────────────────────────────────────┤
182 │ind │index on this list │
183 ├──────────┼───────────────────────────────────────────────────────────────┤
184 │assid │association ID │
185 ├──────────┼───────────────────────────────────────────────────────────────┤
186 │status │peer status word │
187 ├──────────┼───────────────────────────────────────────────────────────────┤
188 │conf │yes: persistent, no: ephemeral │
189 ├──────────┼───────────────────────────────────────────────────────────────┤
190 │reach │yes: reachable, no: unreachable │
191 ├──────────┼───────────────────────────────────────────────────────────────┤
192 │auth │ok, yes, bad and none │
193 ├──────────┼───────────────────────────────────────────────────────────────┤
194 │condition │selection status (see the select field of the peer status word)│
195 ├──────────┼───────────────────────────────────────────────────────────────┤
196 │last_event │event report (see the event field of the peer status word) │
197 ├──────────┼───────────────────────────────────────────────────────────────┤
198 │cnt │event count (see the count field of the peer status word) │
199 └──────────┴───────────────────────────────────────────────────────────────┘
200
201 clockvar assocID [name [ = value [...]] [...]
202
203 cv assocID [name [ = value [...] ][...]
204 Display a list of clock variables for those assocations sup‐
205 porting a reference clock.
206
207 :config [...]
208 Send the remainder of the command line, including whitespace,
209 to the server as a run-time configuration command in the same
210 format as the configuration file. This command is experimental
211 until further notice and clarification. Authentication is of
212 course required.
213
214 config-from-file filename
215 Send the each line of filename to the server as run-time con‐
216 figuration commands in the same format as the configuration
217 file. This command is experimental until further notice and
218 clarification. Authentication is of course required.
219
220 keyid Specify the key ID to use for write requests.
221
222 lassociations
223 Perform the same function as the associations command, execept
224 display mobilized and unmobilized associations.
225
226 mreadvar assocID assocID [ variable_name [ = value[ ... ]
227
228 mrv assocID assocID [ variable_name [ = value[ ... ]
229 Perform the same function as the readvar command, except for a
230 range of association IDs. This range is determined from the
231 association list cached by the most recent associations com‐
232 mand.
233
234 passociations
235 Perform the same function as the associations command, except
236 that it uses previously stored data rather than making a new
237 query.
238
239 passwd Specify the password to use for write requests.
240
241 peers Display a list of peers in the form [tally]remote refid st t
242 when pool reach delay offset jitter
243
244
245 ┌────────┬──────────────────────────────────────────────────────────────────────────────────────────┐
246 │Variable │Description │
247 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
248 │[tally] │single-character code indicating current value of the select field of the peer status word│
249 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
250 │remote │host name (or IP number) of peer │
251 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
252 │refid │association ID or kiss code │
253 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
254 │st │stratum │
255 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
256 │t │u: unicast, b: broadcast, l: local │
257 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
258 │when │sec/min/hr since last received packet │
259 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
260 │poll │poll interval (log2 s) │
261 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
262 │reach │reach shift register (octal) │
263 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
264 │delay │roundtrip delay │
265 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
266 │offset │offset │
267 ├────────┼──────────────────────────────────────────────────────────────────────────────────────────┤
268 │jitter │jitter │
269 └────────┴──────────────────────────────────────────────────────────────────────────────────────────┘
270
271 readvar assocID name [ = value ] [,...]
272
273 rv assocID [ name ] [,...]
274 Display the specified variables. If assocID is zero, the vari‐
275 ables are from the system variables name space, otherwise they
276 are from the peer variables name space. The assocID is
277 required, as the same name can occur in both spaces. If no name
278 is included, all operative variables in the name space are dis‐
279 played. In this case only, if the assocID is omitted, it is
280 assumed zero. Multiple names are specified with comma separa‐
281 tors and without whitespace. Note that time values are repre‐
282 sented in milliseconds and frequency values in parts-per-mil‐
283 lion (PPM). Some NTP timestamps are represented in the format
284 YYYYMMDDTTTT, where YYYY is the year, MM the month of year, DD
285 the day of month and TTTT the time of day.
286
287 saveconfig filename
288 Write the current configuration, including any runtime modifi‐
289 cations given with :config or config-from-file, to the ntpd
290 host's file filename. This command will be rejected by the
291 server unless saveconfigdir appears in the ntpd configuration
292 file. filename can use strftime() format specifiers to substi‐
293 tute the current date and time, for example, saveconfig
294 ntp-%Y%m%d-%H%M%S.conf. The filename used is stored in system
295 variable savedconfig. Authentication is required.
296
297 writevar assocID name = value [,...]
298 Write the specified variables. If the assocID is zero, the
299 variables are from the system variables name space, otherwise
300 they are from the peer variables name space. The assocID is
301 required, as the same name can occur in both spaces.
302
303
305 The current state of the operating program is shown in a set of status
306 words maintained by the system and each association separately. These
307 words are displayed in the rv and as commands both in hexadecimal and
308 decoded short tip strings. The codes, tips and short explanations are
309 on the Event Messages and Status Words page. The page also includes a
310 list of system and peer messages, the code for the latest of which is
311 included in the status word.
312
313 Information resulting from protocol machine state transitions is dis‐
314 played using an informal set of ASCII strings called kiss codes. The
315 original purpose was for kiss-o'-death (KoD) packets sent by the server
316 to advise the client of an unusual condition. They are now displayed,
317 when appropriate, in the reference identifier field in various bill‐
318 boards.
319
320
322 The following system variables appear in the rv billboard. Not all
323 variables are displayed in some configurations.
324
325
326 ┌─────────────┬────────────────────────────────────────────────────────┐
327 │Variable │ Description │
328 ├─────────────┼────────────────────────────────────────────────────────┤
329 │status │ system status word │
330 ├─────────────┼────────────────────────────────────────────────────────┤
331 │version │ NTP software version and build time │
332 ├─────────────┼────────────────────────────────────────────────────────┤
333 │processor │ hardware platform and version │
334 ├─────────────┼────────────────────────────────────────────────────────┤
335 │system │ operating system and version │
336 ├─────────────┼────────────────────────────────────────────────────────┤
337 │leap │ leap warning indicator (0-3) │
338 ├─────────────┼────────────────────────────────────────────────────────┤
339 │stratum │ stratum (1-15) │
340 ├─────────────┼────────────────────────────────────────────────────────┤
341 │precision │ precision (log2 s) │
342 ├─────────────┼────────────────────────────────────────────────────────┤
343 │rootdelay │ total roundtrip delay to the primary reference clock │
344 ├─────────────┼────────────────────────────────────────────────────────┤
345 │rootdisp │ total dispersion to the primary reference clock │
346 ├─────────────┼────────────────────────────────────────────────────────┤
347 │peer │ system peer association ID │
348 ├─────────────┼────────────────────────────────────────────────────────┤
349 │tc │ time constant and poll exponent (log2 s) (3-17) │
350 ├─────────────┼────────────────────────────────────────────────────────┤
351 │mintc │ minimum time constant (log2 s) (3-10) │
352 ├─────────────┼────────────────────────────────────────────────────────┤
353 │clock │ date and time of day │
354 ├─────────────┼────────────────────────────────────────────────────────┤
355 │refid │ reference ID or kiss code │
356 ├─────────────┼────────────────────────────────────────────────────────┤
357 │reftime │ reference time │
358 ├─────────────┼────────────────────────────────────────────────────────┤
359 │offset │ combined time offset │
360 ├─────────────┼────────────────────────────────────────────────────────┤
361 │sys_jitter │ combined system jitter │
362 ├─────────────┼────────────────────────────────────────────────────────┤
363 │frequency │ clock frequency offset (PPM) │
364 ├─────────────┼────────────────────────────────────────────────────────┤
365 │clk_wander │ clock frequency wander (PPM) │
366 ├─────────────┼────────────────────────────────────────────────────────┤
367 │clk_jitter │ clock jitter │
368 ├─────────────┼────────────────────────────────────────────────────────┤
369 │tai │ TAI-UTC offset (s) │
370 ├─────────────┼────────────────────────────────────────────────────────┤
371 │leapsec │ NTP seconds when the next leap second is/was inserted │
372 ├─────────────┼────────────────────────────────────────────────────────┤
373 │expire │ NTP seconds when the NIST leapseconds file expires │
374 └─────────────┴────────────────────────────────────────────────────────┘
375
376 The jitter and wander statistics are exponentially-weighted RMS aver‐
377 ages. The system jitter is defined in the NTPv4 specification; the
378 clock jitter statistic is computed by the clock discipline module.
379
380 When the NTPv4 daemon is compiled with the OpenSSL software library,
381 additional system variables are displayed, including some or all of the
382 following, depending on the particular Autokey dance:
383
384
385 ┌──────────────┬───────────────────────────────────────────────────────┐
386 │ Variable │ Description │
387 ├──────────────┼───────────────────────────────────────────────────────┤
388 │ host │ Autokey host name │
389 ├──────────────┼───────────────────────────────────────────────────────┤
390 │ group │ Autokey group name │
391 ├──────────────┼───────────────────────────────────────────────────────┤
392 │ flags │ host flags (see Autokey specification) │
393 ├──────────────┼───────────────────────────────────────────────────────┤
394 │ digest │ OpenSSL message digest algorithm │
395 ├──────────────┼───────────────────────────────────────────────────────┤
396 │ signature │ OpenSSL digest/signature scheme │
397 ├──────────────┼───────────────────────────────────────────────────────┤
398 │ update │ NTP seconds at last signature update │
399 ├──────────────┼───────────────────────────────────────────────────────┤
400 │ cert │ certificate subject, issuer and certificate flags │
401 ├──────────────┼───────────────────────────────────────────────────────┤
402 │ until │ NTP seconds when the certificate expires │
403 └──────────────┴───────────────────────────────────────────────────────┘
404
406 The following system variables apear in the rv billboard for each asso‐
407 ciation. Not all variables are displayed in some configurations.
408
409
410 ┌──────────────┬──────────────────────────────────────────────────────────┐
411 │Variable │Description │
412 ├──────────────┼──────────────────────────────────────────────────────────┤
413 │associd │association ID │
414 ├──────────────┼──────────────────────────────────────────────────────────┤
415 │status │peer status word │
416 ├──────────────┼──────────────────────────────────────────────────────────┤
417 │srcadr srcport │source (remote) IP address and port │
418 ├──────────────┼──────────────────────────────────────────────────────────┤
419 │dstadr dstport │destination (local) IP address and port │
420 ├──────────────┼──────────────────────────────────────────────────────────┤
421 │leap │leap indicator (0-3) │
422 ├──────────────┼──────────────────────────────────────────────────────────┤
423 │stratum │stratum (0-15) │
424 ├──────────────┼──────────────────────────────────────────────────────────┤
425 │precision │precision (log2 s) │
426 ├──────────────┼──────────────────────────────────────────────────────────┤
427 │rootdelay │total roundtrip delay to the primary reference clock │
428 ├──────────────┼──────────────────────────────────────────────────────────┤
429 │rootdisp │total root dispersion to the primary reference clock │
430 ├──────────────┼──────────────────────────────────────────────────────────┤
431 │refid │reference ID or kiss code │
432 ├──────────────┼──────────────────────────────────────────────────────────┤
433 │reftime │reference time │
434 ├──────────────┼──────────────────────────────────────────────────────────┤
435 │reach │reach register (octal) │
436 ├──────────────┼──────────────────────────────────────────────────────────┤
437 │unreach │unreach counter │
438 ├──────────────┼──────────────────────────────────────────────────────────┤
439 │hmode │host mode (1-6) │
440 ├──────────────┼──────────────────────────────────────────────────────────┤
441 │pmode │peer mode (1-5) │
442 ├──────────────┼──────────────────────────────────────────────────────────┤
443 │hpoll │host poll exponent (log2 s) (3-17) │
444 ├──────────────┼──────────────────────────────────────────────────────────┤
445 │ppoll │peer poll exponent (log2 s) (3-17) │
446 ├──────────────┼──────────────────────────────────────────────────────────┤
447 │headway │headway (see Rate Management and the Kiss-o'-Death Packet)│
448 ├──────────────┼──────────────────────────────────────────────────────────┤
449 │flash │flash status word │
450 ├──────────────┼──────────────────────────────────────────────────────────┤
451 │offset │filter offset │
452 ├──────────────┼──────────────────────────────────────────────────────────┤
453 │delay │filter delay │
454 ├──────────────┼──────────────────────────────────────────────────────────┤
455 │dispersion │filter dispersion │
456 ├──────────────┼──────────────────────────────────────────────────────────┤
457 │jitter │filter jitter │
458 ├──────────────┼──────────────────────────────────────────────────────────┤
459 │bias │unicast/broadcast bias │
460 ├──────────────┼──────────────────────────────────────────────────────────┤
461 │xleave │interleave delay (see NTP Interleaved Modes) │
462 └──────────────┴──────────────────────────────────────────────────────────┘
463 The bias vaqriable is calculated when the first broadcast packet is
464 received after the calibration volley. It represents the offset of the
465 broadcast subgraph relative to the unicast subgraph. The xleave vari‐
466 able appears only the interleaved symmetric and ingterleaved modes. It
467 represents the internal queueing, buffering and transmission delays for
468 the preceeding packet.
469
470 When the NTPv4 daemon is compiled with the OpenSSL software library,
471 additional peer variables are displayed, including the following:
472
473
474 ┌─────────────────────┬────────────────────────────────────────────────┐
475 │ Variable │ Description │
476 ├─────────────────────┼────────────────────────────────────────────────┤
477 │ flags │ peer flags (see Autokey specification) │
478 ├─────────────────────┼────────────────────────────────────────────────┤
479 │ host │ Autokey server name │
480 ├─────────────────────┼────────────────────────────────────────────────┤
481 │ flags │ peer flags (see Autokey specification) │
482 ├─────────────────────┼────────────────────────────────────────────────┤
483 │ signature │ OpenSSL digest/signature shceme │
484 ├─────────────────────┼────────────────────────────────────────────────┤
485 │ initsequence │ initial key ID │
486 ├─────────────────────┼────────────────────────────────────────────────┤
487 │ initkey │ initial key index │
488 ├─────────────────────┼────────────────────────────────────────────────┤
489 │ timestamp │ Autokey signature timestamp │
490 └─────────────────────┴────────────────────────────────────────────────┘
491
493 The following clock variables apear in the cv billboard for each asso‐
494 ciation with a reference clock. Not all variables are displayed in some
495 configurations.
496
497
498 ┌──────────────────┬───────────────────────────────────────────────────┐
499 │ Variable │ Description │
500 ├──────────────────┼───────────────────────────────────────────────────┤
501 │ associd │ association ID │
502 ├──────────────────┼───────────────────────────────────────────────────┤
503 │ status │ clock status word │
504 ├──────────────────┼───────────────────────────────────────────────────┤
505 │ device │ device description │
506 ├──────────────────┼───────────────────────────────────────────────────┤
507 │ timecode │ ASCII timecode string (specific to device) │
508 ├──────────────────┼───────────────────────────────────────────────────┤
509 │ poll │ poll messages sent │
510 ├──────────────────┼───────────────────────────────────────────────────┤
511 │ noreply │ no reply │
512 ├──────────────────┼───────────────────────────────────────────────────┤
513 │ badformat │ bad format │
514 ├──────────────────┼───────────────────────────────────────────────────┤
515 │ baddata │ bad date or time │
516 ├──────────────────┼───────────────────────────────────────────────────┤
517 │ fudgetime1 │ fudge time 1 │
518 ├──────────────────┼───────────────────────────────────────────────────┤
519 │ fudgetime2 │ fudge time 2 │
520 ├──────────────────┼───────────────────────────────────────────────────┤
521 │ stratum │ driver stratum │
522 ├──────────────────┼───────────────────────────────────────────────────┤
523 │ refid │ driver reference ID │
524 ├──────────────────┼───────────────────────────────────────────────────┤
525 │ flags │ driver flags │
526 └──────────────────┴───────────────────────────────────────────────────┘
527
529 ntp_decode(5), ntpd(8), ntpdc(8)
530
531 The official HTML documentation.
532
533 This file was automatically generated from HTML source.
534
535
536
537
538 ntpq(8)