NTPQ(8)
π NAME π
okay so this is ntpq β the standard NTP query program β and youβre reading the NTPQ(8) page from the System Managerβs Manual. Thatβs the whole name section, bestie. iconic. π
πΈ SYNOPSIS πΈ
ntpq [-flags] [-flag [value]] [--option-name[[=| ]value]] [ host ...]
π DESCRIPTION π
The ntpq utility program is your little query goblin for NTP servers β it monitors NTP operations and performance, requesting information about current state and/or changes in that state. The program may be run either in interactive mode or controlled using command line arguments. Requests to read and write arbitrary variables can be assembled, with raw and pretty-printed output options being available. The ntpq utility can also obtain and print a list of peers in a common format by sending multiple queries to the server. π«Ά
If one or more request options is included on the command line when ntpq is executed, each of the requests will be sent to the NTP servers running on each of the hosts given as command line arguments, or on localhost by default. If no request options are given, ntpq will attempt to read commands from the standard input and execute these on the NTP server running on the first host given on the command line, again defaulting to localhost when no other host is specified. The ntpq utility will prompt for commands if the standard input is a terminal device. β¨
ntpq uses NTP mode 6 packets to communicate with the NTP server, and hence can be used to query any compatible server on the network which permits it. Note that since NTP is a UDP protocol this communication will be somewhat unreliable, especially over large distances in terms of network topology. The ntpq utility makes one attempt to retransmit requests, and will time requests out if the remote host is not heard from within a suitable timeout time. π
β οΈ lowkey important: UDP means stuff can get lost, especially over big network-topology distances. ntpq retransmits once, then times out if the remote host isnβt heard from in a suitable timeout time.
Note that in contexts where a host name is expected, a -4 qualifier preceding the host name forces resolution to the IPv4 namespace, while a -6 qualifier forces resolution to the IPv6 namespace. For examples and usage, see the βNTP Debugging Techniquesβ page. π¦
Specifying a command line option other than -i or -n will cause the specified query (queries) to be sent to the indicated host(s) immediately. Otherwise, ntpq will attempt to read interactive format commands from the standard input. π
π Internal Commands π
Interactive format commands consist of a keyword followed by zero to four arguments. Only enough characters of the full keyword to uniquely identify the command need be typed. β¨
A number of interactive format commands are executed entirely within the ntpq utility itself and do not result in NTP requests being sent to a server. These are described following. π
? [command],help [command]β A β?β by itself will print a list of all the commands known tontpq. A β?β followed by a command name will print function and usage information about the command. π«Άaddvars name[=value][,...],rmvars name[,...],clearvars,showvarsβ The arguments to this command consist of a list of items of the formname[=value], where the=valueis ignored, and can be omitted, in requests to the server to read variables. Thentpqutility maintains an internal list in which data to be included in messages can be assembled, and displayed or set using thereadlistandwritelistcommands described below. Theaddvarscommand allows variables and their optional values to be added to the list. If more than one variable is to be added, the list should be comma-separated and not contain white space. Thermvarscommand can be used to remove individual variables from the list, while theclearvarscommand removes all variables from the list. Theshowvarscommand displays the current list of optional variables. πauthenticate [yes|no]β Normallyntpqdoes not authenticate requests unless they are write requests. The commandauthenticate yescausesntpqto send authentication with all requests it makes. Authenticated requests causes some servers to handle requests slightly differently. The commandauthenticatecausesntpqto display whether or not it is currently authenticating requests. π₯cookedβ Causes output from query commands to be "cooked", so that variables which are recognized byntpqwill have their values reformatted for human consumption. Variables whichntpqcould not decode completely are marked with a trailing β?β. πdebug [more|less|off]β With no argument, displays the current debug level. Otherwise, the debugging level is changed as indicated. πdelay [milliseconds]β Specify a time interval to be added to timestamps included in requests which require authentication. This is used to enable (unreliable) server reconfiguration over long delay network paths or between machines whose clocks are unsynchronized. Actually the server does not now require timestamps in authenticated requests, so this command may be obsolete. Without any arguments, displays the current delay. πdrefid [hash|ipv4]β Display refids as IPv4 or hash. Without any arguments, displays whether refids are shown as IPv4 addresses or hashes. π¦exitβ Exitntpq. πhost [name]β Set the host to which future queries will be sent. The name may be either a host name or a numeric address. Without any arguments, displays the current host. πhostnames [yes|no]β Ifyesis specified, host names are printed in information displays. Ifnois specified, numeric addresses are printed instead. The default isyes, unless modified using the command line-nswitch. Without any arguments, displays whether host names or numeric addresses are shown. β¨keyid [keyid]β This command allows the specification of a key number to be used to authenticate configuration requests. This must correspond to thecontrolkeykey number the server has been configured to use for this purpose. Without any arguments, displays the currentkeyid. πkeytype [digest]β Specify the digest algorithm to use for authenticating requests, with defaultMD5. Ifntpqwas built with OpenSSL support, and OpenSSL is installed,digestcan be any message digest algorithm supported by OpenSSL. If no argument is given, the currentkeytypedigest algorithm used is displayed. πΈntpversion [1|2|3|4]β Sets the NTP version number whichntpqclaims in packets. Defaults to3, and note that mode 6 control messages (and modes, for that matter) didnβt exist in NTP version 1. There appear to be no servers left which demand version 1. With no argument, displays the current NTP version that will be used when communicating with servers. πpasswdβ This command prompts you to type in a password (which will not be echoed) which will be used to authenticate configuration requests. The password must correspond to the key configured for use by the NTP server for this purpose if such requests are to be successful. πpoll [n] [verbose]β Poll an NTP server in client modentimes. Poll not implemented yet. πquitβ Exitntpq. π«Άrawβ Causes all output from query commands is printed as received from the remote server. The only formating/interpretation done on the data is to transform nonascii data into a printable (but barely understandable) form. π§timeout [milliseconds]β Specify a timeout period for responses to server queries. The default is about5000milliseconds. Without any arguments, displays the current timeout period. Note that sincentpqretries each query once after a timeout, the total waiting time for a timeout will be twice the timeout value set. βversionβ Display the version of thentpqprogram. π
π¦ Control Message Commands π¦
Association ids are used to identify system, peer and clock variables. System variables are assigned an association id of zero and system name space, while each association is assigned a nonzero association id and peer namespace. Most control commands send a single message to the server and expect a single response message. The exceptions are the peers command, which sends a series of messages, and the mreadlist and mreadvar commands, which iterate over a range of associations. π
apeersβ Display a list of peers in the form:
[tally]remote refid assid st t when pool reach delay offset jitter
where the output is just like the peers command except that the refid is displayed in hex format and the association number is also displayed. π
associationsβ Display a list of mobilized associations in the form:
ind assid status conf reach auth condition last_event cnt
indβ index on this listassidβ association idstatusβ peer status wordconfβyes: persistent,no: ephemeralreachβyes: reachable,no: unreachableauthβok,yes,badandnoneconditionβ selection status (see theselectfield of the peer status word)last_eventβ event report (see theeventfield of the peer status word)cntβ event count (see thecountfield of the peer status word)
authinfoβ bestie, this one spills the authentication tea β it displays the authentication statistics counters: time since reset, stored keys, free keys, key lookups, keys not found, uncached keys, expired keys, encryptions, decryptions. literally the whole receipts list πclocklist [associd]cl [associd]β these two are the same vibe, ok? they display all clock variables in the variable list for those associations supporting a reference clock π°οΈclockvar [associd] [name[=value]][,...]cv [associd] [name[=value]][,...]β same energy, different spelling β¨ this one displays a list of clock variables for those associations supporting a reference clock.:config configuration command lineβ send the remainder of the command line, including whitespace, to the server as a run-time configuration command in the same format as a line in the configuration file. π«Ά
heads up bestie: this command is experimental until further notice and clarification. authentication is of course required. no cap.
config-from-file filenameβ this one sends each line of filename to the server as run-time configuration commands in the same format as lines in the configuration file. π
again: this command is experimental until further notice and clarification. authentication is required. don't say i didn't warn you π
ifstatsβ display status and statistics counters for each local network interface address: interface number, interface name and address or broadcast, drop, flag, ttl, mc, received, sent, send failed, peers, uptime. π authentication is required, periodt.iostatsβ network and reference clock I/O stats incoming!! πΎ time since reset, receive buffers, free receive buffers, used receive buffers, low water refills, dropped packets, ignored packets, received packets, packets sent, packet send failures, input wakeups, useful input wakeups.kerninfoβ kernel loop and PPS statistics, the whole main-character lineup π: associd, status, pll offset, pll frequency, maximum error, estimated error, kernel status, pll time constant, precision, frequency tolerance, pps frequency, pps stability, pps jitter, calibration interval, calibration cycles, jitter exceeded, stability exceeded, calibration errors.
ok so important detail: as with otherntpqoutput, times are in milliseconds; very small values may be shown as exponentials. and theprecisionvalue displayed is in milliseconds as well, unlike theprecisionsystem variable. ikyk π
lassociationsβ does the same thing as theassociationscommand, except it displays mobilized and unmobilized associations, including all clients. the full guest list fr fr πlopeers [-4|-6]β display a list of all peers and clients showingdstadr(associated with the given IP version). pick your fave:-4or-6π«lpassociationsβ display the last obtained list of associations, including all clients. it's giving leftovers-but-make-it-iconic πlpeers [-4|-6]β display a list of all peers and clients (associated with the given IP version). same deal,-4or-6πmonstatsβ monitor facility status, statistics, and limits, served fresh π: enabled, addresses, peak addresses, maximum addresses, reclaim above count, reclaim older than, kilobytes, maximum kilobytes.mreadlist associdlo associdhimrl associdlo associdhiβ perform the same function as thereadlistcommand for a range of association ids. πmreadvar associdlo associdhi [name][,...]β this range may be determined from the list displayed by any command showing associations. slay.mrv associdlo associdhi [name][,...]β perform the same function as thereadvarcommand for a range of association ids. this range may be determined from the list displayed by any command showing associations. πmrulist [limited | kod | mincount=count | laddr=localaddr | sort=[-]sortorder | resany=hexmask | resall=hexmask]β display traffic counts of the most recently seen source addresses collected and maintained by the monitor facility. π With the exception ofsort=[-]sortorder, the options filter the list returned byntpd(8).- The
limitedandkodoptions return only entries representing client addresses from which the last packet received triggered either discarding or a KoD response. - The
mincount=countoption filters entries representing less than count packets. - The
laddr=localaddroption filters entries for packets received on any local address other than localaddr. resany=hexmaskandresall=hexmaskfilter entries containing none or less than all, respectively, of the bits in hexmask, which must begin with0x.
- The
The sortorder defaults to lstint and may be addr, avgint, count, lstint, or any of those preceded by β-β to reverse the sort order.
The output columns are:
lstintβ interval in seconds between the receipt of the most recent packet from this address and the completion of the retrieval of the MRU list byntpq.avgintβ average interval in s between packets from this address.rstrβ restriction flags associated with this address. most are copied unchanged from the matchingrestrictcommand, however0x400(kod) and0x20(limited) flags are cleared unless the last packet from this address triggered a rate control response. β οΈrβ rate control indicator, either a period,LorKfor no rate control response, rate limiting by discarding, or rate limiting with a KoD response, respectively.mβ packet mode.vβ packet version number.countβ packets received from this address.rportβ source port of last packet from this address.remote addressβ host or DNS name, numeric address, or address followed by claimed DNS name which could not be verified in parentheses.
opeers [-4 | -6]β obtain and print the old-style list of all peers and clients showingdstadr(associated with the given IP version), rather than therefid. vintage but make it cute π¦passociationsβ perform the same function as theassociationscommand, except that it uses previously stored data rather than making a new query. lowkey lazy but in a smart way βpeersβ display a list of peers in the form:
[tally]remote refid st t when pool reach delay offset jitter
[tally]β single-character code indicating current value of theselectfield of the peer status word:decode.html#peerremoteβ host name (or IP number) of peer. the value displayed will be truncated to 15 characters unless thentpq -woption is given, in which case the full value will be displayed on the first line, and if too long, the remaining data will be displayed on the next line. π€ so yeah,-wis your bestie if you hate truncationrefidβ source IP address or 'kiss code:decode.html#kiss
stβ stratum, bestie:0for local reference clocks,1for servers with local reference clocks, ..., all the way out to16for unsynchronized server clocks πtβ the β¨typeβ¨ tea:u= unicast or manycast client,b= broadcast or multicast client,p= pool source,l= local (reference clock),s= symmetric (peer),A= manycast server,B= broadcast server,M= multicast serverwhenβ time in seconds, minutes, hours, or days since the last packet was received, or-if a packet has never been received πpollβ poll interval (s)reachβ reach shift register (octal)delayβ roundtrip delayoffsetβ offset of server relative to this hostjitterβ offset RMS error estimate.
pstats associdβ pulls up the stats for whichever peer has thatassocid. The whole lineup:associd,status, remote host, local address, time last received, time until next send, reachability change, packets sent, packets received, bad authentication, bogus origin, duplicate, bad dispersion, bad reference time, candidate order. It's giving full dossier πreadlist [associd]rl [associd]
Displays all system or peer variables, no cap. If you ghost the associd, it just assumes it's zero. easy β¨
readvar [associd name[=value] [, ...]]rv [associd name[=value] [, ...]]
Displays the specific system or peer variables you asked for. Okay so the lore: if associd is zero, the variables come from the βSystem Variablesβ name space, otherwise they're from the βPeer Variablesβ name space. And yes the associd is literally required, because the same name can show up in both spaces β imagine the confusion π If you don't include any name, it displays all operative variables in the name space. In this one case only, if the associd is omitted, it's assumed to be zero.
Multiple names go in with comma separators and no whitespace. Also important: time values are represented in milliseconds and frequency values in parts-per-million (PPM). Some NTP timestamps show up in the format YYYYMM DD TTTT, where YYYY is the year, MM the month of year, DD the day of month and TTTT the time of day.
reslistβ displays the access control (restrict) list forntpq. Authentication is required πsaveconfig filenameβ saves the current configuration (including any runtime modifications made by:configorconfig-from-file) to the NTP server host filefilename. Lowkey important: this command will be rejected by the server unlesssaveconfigdir: miscopt.html#saveconfigdirappears in thentpd(8)configuration file.
Bonus: filename can use date(1) format specifiers to substitute the current date and time, like this:
saveconfig ntp-%Y%m%d-%H%M%S.conf.
The filename used gets stored in the system variable savedconfig. Authentication is required π
sysinfoβ shows the system operational summary, and it's a whole aesthetic β¨:associd,status, system peer, system peer mode, leap indicator,stratum, log2 precision, root delay, root dispersion, reference id, reference time, system jitter, clock jitter, clock wander, broadcast delay, symm. auth. delay.sysstatsβ displays system uptime and the packet counts kept in the protocol module:uptime,sysstats reset, packets received, current version, older version, bad length or format, authentication failed, declined, restricted, rate limited, KoD responses, processed for time. numbers go brrr πtimerstatsβ displays the interval timer counters: time since reset, timer overruns, calls to transmit.writelist associdβ sets all the system or peer variables included in the variable list.writevar associd name=value [, ...]β sets the specified variables in the variable list. Same rules as its read-y sibling: if theassocidis zero, the variables come from the βSystem Variablesβ name space, otherwise they come from the βPeer Variablesβ name space. Theassocidis required, since the same name can occur in both spaces. Authentication is required π
π Status Words and Kiss Codes π
The current state of the operating program is shown in a set of status words maintained by the system. Status info is also available per-association, because of course it is. These words are displayed by the readlist and associations commands in hexadecimal and in decoded short tip strings β double serve π
The codes, tips and short explanations are documented on the Event Messages and Status Words: decode.html page. That page also includes a list of system and peer messages, and the code for the latest of those is included in the status word.
Information resulting from protocol machine state transitions is displayed using an informal set of ASCII strings called kiss codes: decode.html#kiss. Originally the whole point was kiss-o'-death (KoD) packets sent by the server to advise the client of an unusual condition. Now they also get displayed, when appropriate, in the reference identifier field in various billboards. glow-up fr fr π
π¦ System Variables π¦
These are the system variables that appear in the readlist billboard. Ngl, not all variables are displayed in some configurations.
statusβ system status word:decode.html#sysversionβ NTP software version and build timeprocessorβ hardware platform and versionsystemβ operating system and versionleapβ leap warning indicator (0-3)stratumβ stratum (1-15)precisionβ precision (log2 s)rootdelayβ total roundtrip delay to the primary reference clockrootdispβ total dispersion to the primary reference clockrefidβ reference id or kiss code:decode.html#kissreftimeβ reference timeclockβ date and time of daypeerβ system peer association idtcβ time constant and poll exponent (log2 s) (3-17)mintcβ minimum time constant (log2 s) (3-10)offsetβ combined offset of server relative to this hostfrequencyβ frequency drift (PPM) relative to hardware clocksys_jitterβ combined system jitterclk_wanderβ clock frequency wander (PPM)clk_jitterβ clock jittertaiβ TAI-UTC offset (s)leapsecβ NTP seconds when the next leap second is/was insertedexpireβ NTP seconds when the NIST leapseconds file expires
The jitter and wander statistics are exponentially-weighted RMS averages β fancy math, don't worry about it too hard. The system jitter is defined in the NTPv4 specification; the clock jitter statistic is computed by the clock discipline module. bestie behaviour β¨
When the NTPv4 daemon is compiled with the OpenSSL software library, extra system variables show up too β some or all of the following, depending on the particular Autokey dance π:
hostβ Autokey host name for this hostidentβ Autokey group name for this hostflagsβ host flags (see Autokey specification)digestβ OpenSSL message digest algorithmsignatureβ OpenSSL digest/signature schemeupdateβ NTP seconds at last signature updatecertβ certificate subject, issuer and certificate flagsuntilβ NTP seconds when the certificate expires
πΈ Peer Variables πΈ
And these are the peer variables that appear in the readlist billboard for each association. Again, not all variables are displayed in some configurations β same energy as above.
associdβ association idstatusβ peer status word:decode.html#peersrcadrβ source (remote) IP addresssrcportβ source (remote) portdstadrβ destination (local) IP addressdstportβ destination (local) portleapβ leap indicator (0-3)stratumβ stratum (0-15)precisionβ precision (log2 s)rootdelayβ total roundtrip delay to the primary reference clockrootdispβ total root dispersion to the primary reference clockrefidβ reference id or kiss code:decode.html#kissreftimeβ reference timerecβ last packet received timereachβ reach register (octal)unreachβ unreach counterhmodeβ host mode (1-6)pmodeβ peer mode (1-5)hpollβ host poll exponent (log2 s) (3-17)ppollβ peer poll exponent (log2 s) (3-17)headwayβ headway (see Rate Management and the Kiss-o'-Death Packet:rate.html)flashβ flash status word:decode.html#flashkeyidβ symmetric key idoffsetβ filter offsetdelayβ filter delaydispersionβ filter dispersionjitterβ filter jitterbiasβ unicast/broadcast biasxleaveβ interleave delay (see NTP Interleaved Modes:xleave.html)
The bias variable gets calculated when the first broadcast packet is received after the calibration volley. It represents the offset of the broadcast subgraph relative to the unicast subgraph. The xleave variable appears only for the interleaved symmetric and interleaved modes, and it represents the internal queuing, buffering and transmission delays for the preceding packet. iykyk π
Okay so when the NTPv4 daemon is compiled with the OpenSSL software library, extra peer variables show up, including these besties:
flagsβ peer flags (see Autokey specification)hostβ Autokey server nameflagsβ peer flags (see Autokey specification)signatureβ OpenSSL digest/signature schemeinitsequenceβ initial key idinitkeyβ initial key indextimestampβ Autokey signature timestampidentβ Autokey group name for this association
π°οΈ Clock Variables π°οΈ
The following clock variables appear in the clocklist billboard for each association with a reference clock. Not all variables are displayed in some configurations.
associdβ association idstatusβ clock status word:decode.html#clockdeviceβ device descriptiontimecodeβ ASCII time code string (specific to device)pollβ poll messages sentnoreplyβ no replybadformatβ bad formatbaddataβ bad date or timefudgetime1β fudge time 1fudgetime2β fudge time 2stratumβ driver stratumrefidβ driver reference idflagsβ driver flags
β¨ OPTIONS β¨
-4,--ipv4β Force IPv4 name resolution. This option must not appear in combination with any of the following options:ipv6. Force resolution of following host names on the command line to the IPv4 namespace.-6,--ipv6β Force IPv6 name resolution. This option must not appear in combination with any of the following options:ipv4. Force resolution of following host names on the command line to the IPv6 namespace.-c cmd,--command=cmdβ run a command and exit. This option may appear an unlimited number of times. The following argument is interpreted as an interactive format command and is added to the list of commands to be executed on the specified host(s).-d,--debug-levelβ Increase debug verbosity level. This option may appear an unlimited number of times.-D number,--set-debug-level=numberβ Set the debug verbosity level. This option may appear an unlimited number of times. This option takes an integer number as its argument.-i,--interactiveβ Force ntpq to operate in interactive mode. This option must not appear in combination with any of the following options:command,peers. Force ntpq to operate in interactive mode. Prompts will be written to the standard output and commands read from the standard input.-n,--numericβ numeric host addresses. Output all host addresses in dotted-quad numeric format rather than converting to the canonical host names.--old-rvβ Always output status line with readvar. By default, ntpq now suppresses theassocid=...line that precedes the output ofreadvar(aliasrv) when a single variable is requested, such asntpq -c "rv 0 offset". This option causes ntpq to include both lines of output for a single-variable readvar. Using an environment variable to preset this option in a script will enable both older and newer ntpq to behave identically in this regard.-p,--peersβ Print a list of the peers. This option must not appear in combination with any of the following options:interactive. Print a list of the peers known to the server as well as a summary of their state. This is equivalent to the'peers'interactive command.-r keyword,--refid=keywordβ Set default display type for S2+ refids. This option takes a keyword as its argument. The argument sets an enumeration value that can be tested by comparing them against the option value macro. The available keywords are:hashipv4or their numeric equivalent. The default keyword for this option is:ipv4. Set the default display format for S2+ refids.-u,--unconnectedβ Use unconnected UDP to communicate with ntpd (default on Windows). Open an unconnected UDP association to ntpd (the default on Windows).-w,--wideβ Display the full'remote'value. Display the full value of the'remote'value. If this requires more than 15 characters, display the full value, emit a newline, and continue the data display properly indented on the next line.-?,--helpβ Display usage information and exit.-!,--more-helpβ Pass the extended usage information through a pager.-> [cfgfile],--save-opts [=cfgfile]β Save the option state to cfgfile. The default is the last configuration file listed in the OPTION PRESETS section, below. The command will exit after updating the config file.-< cfgfile,--load-opts=cfgfile,--no-load-optsβ Load options from cfgfile. The no-load-opts form will disable the loading of earlier config/rc/ini files.--no-load-optsis handled early, out of order.--version [{v|c|n}]β Output version of program and exit. The default mode isv, a simple version. Thecmode will print copyright information andnwill print the full copyright notice.
π OPTION PRESETS π
Any option that is not marked as not presettable may be preset by loading values from configuration ("RC" or ".INI") file(s) and values from environment variables named:
NTPQ_<option-name> or NTPQ
The environmental presets take precedence (are processed later than) the configuration files. The homerc files are "$HOME", and ".". If any of these are directories, then the file .ntprc is searched for within those directories.
π ENVIRONMENT π
See OPTION PRESETS for configuration environment variables.
π¦ FILES π¦
See OPTION PRESETS for configuration files.
π EXIT STATUS π
One of the following exit values will be returned:
0(EXIT_SUCCESS) β Successful program execution.1(EXIT_FAILURE) β The operation failed or the command syntax was not valid.66(EX_NOINPUT) β A specified configuration file could not be loaded.70(EX_SOFTWARE) β libopts had an internal operational error. Please report it toautogen-users@lists.sourceforge.net. Thank you.
π AUTHORS π
The University of Delaware and Network Time Foundation
π COPYRIGHT π
Copyright (C) 1992-2024 The University of Delaware and Network Time Foundation all rights reserved. This program is released under the terms of the NTP license, <http://ntp.org/license>.
π BUGS π
Please send bug reports to: https://bugs.ntp.org, bugs@ntp.org
π NOTES π
This manual page was AutoGen-erated from the ntpq option definitions.
okay thatβs the whole page, bestie β Debian, May 25 2024, page NTPQ(8). bye and stay synced πβ¨
π¦ where this page comes from
- freebsd 15.1: base 15.1
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash-1017 on : a language model's rewrite of the original, under its terms