Module ntpstat

NTP client ntpstat functionality

Functionality similar to executing the following shell commands: $ ntpstat $ chronyc -n tracking $ ntpq -c 'timeout 5' -c raw -c 'rv 0' 127.0.0.1.

Copyright © 2025 Michael Truog

Version: 2.0.8 May 15 2025 20:44:11 ------------------------------------------------------------------------

Authors: Michael Truog (mjtruog at protonmail dot com).

Description

NTP client ntpstat functionality

Functionality similar to executing the following shell commands: $ ntpstat $ chronyc -n tracking $ ntpq -c 'timeout 5' -c raw -c 'rv 0' 127.0.0.1

Data Types

bytestring()

bytestring() = [byte()]

options()

options() = [{host, inet:ip_address() | inet:hostname()} | {port, inet:port_number()}]

status()

status() = #status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}

status_error()

status_error() = clock_unsynchronized | clock_unknown

ntpstatus exit status 2

Function Index

destroy/1

Destroy ntpstat status.

.
main/1

Escript Main Function.

.
message/1

Get the current ntpstat output message if it exists.

.
new/0

Create ntpstat status.

.
new/1

Create ntpstat status with options.

.
update/2

Update ntpstat status.

.

Function Details

destroy/1

destroy(Status::#status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}) -> ok

Destroy ntpstat status.

main/1

main(X1::[string()]) -> no_return()

Escript Main Function.

message/1

message(Status::#status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}) -> bytestring() | undefined

Get the current ntpstat output message if it exists.

new/0

new() -> #status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}

Create ntpstat status.

new/1

new(Options::options()) -> #status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}

Create ntpstat status with options.

update/2

update(Timeout::timeout(), Status::#status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}) -> {ok, #status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}} | {error, status_error(), #status{error = status_error() | undefined, restart = boolean(), message = bytestring(), host = inet:ip_address() | inet:hostname(), port = inet:port_number(), socket = gen_udp:socket() | undefined, socket_error = any(), sequence = pos_integer(), leap_indicator = non_neg_integer() | undefined, clock_source = non_neg_integer() | undefined, count = non_neg_integer() | undefined, code = non_neg_integer() | undefined, payload = #{bytestring() := bytestring()} | undefined}}

Update ntpstat status.


Generated by EDoc