Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ntp-server.sh uses incorrect values for "offset" and "frequency" #406

Open
nsuan opened this issue May 18, 2022 · 1 comment
Open

ntp-server.sh uses incorrect values for "offset" and "frequency" #406

nsuan opened this issue May 18, 2022 · 1 comment

Comments

@nsuan
Copy link

nsuan commented May 18, 2022

The latest version of ntp-agent seems to be incorrectly parsing the variables following tc when tc ends up on the same line as offset and frequency:

[tevruden@ntp3 ~]$ wget https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/ntp-server.sh -O ntp-server.sh
--2022-05-18 21:16:28--  https://raw.githubusercontent.com/librenms/librenms-agent/master/snmp/ntp-server.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 2606:50c0:8000::154, 2606:50c0:8003::154, 2606:50c0:8001::154, ...
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|2606:50c0:8000::154|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 4406 (4.3K) [text/plain]
Saving to: 'ntp-server.sh'

ntp-server.sh                     100%[============================================================>]   4.30K  --.-KB/s    in 0s      

2022-05-18 21:16:28 (38.5 MB/s) - 'ntp-server.sh' saved [4406/4406]

[tevruden@ntp3 ~]$ chmod +x ./ntp-server.sh
[tevruden@ntp3 ~]$ ./ntp-server.sh
{"data":{"offset":"+28.460","frequency":"0.021443","sys_jitter":"0.028","clk_jitter":"0.001","clk_wander":"37","stratum":"1","time_since_reset":"13401126","receive_buffers":"416","free_receive_buffers":"415","used_receive_buffers":"0","low_water_refills":"6","dropped_packets":"137","ignored_packets":"2255","received_packets":"11565293601","packets_sent":"10159669024","packet_send_failures":"57006","input_wakeups":"57006","useful_input_wakeups":"9675314786"},"error":"0","errorString":"","version":"1"}
[tevruden@ntp3 ~]$ ntpq -c rv 
associd=0 status=041c leap_none, sync_uhf_radio, 1 event, clock_step,
version="ntpd 4.2.8p15-a (1)", processor="amd64",
system="FreeBSD/12.3-RELEASE", leap=00, stratum=1, precision=-23,
rootdelay=0.000, rootdisp=1.165, refid=PPS,
reftime=e62fe0b9.2cb7dc30  Wed, May 18 2022 21:16:41.174,
clock=e62fe0c4.7baf4331  Wed, May 18 2022 21:16:52.483, peer=23933, tc=4,
mintc=3, offset=+0.044509, frequency=+28.460, sys_jitter=0.021443,
clk_jitter=0.028, clk_wander=0.001, tai=37, leapsec=201701010000,
expire=202206280000

Here offset, frequency, sys_jitter, clk_jitter and clk_wander all get the values for the next variable in the output.

I'm unsure what causes the wrapping, (I've seen both working and non-working on ntpd 4.2.8p15-a) but I've fixed this locally by forcing the script to request offset/frequency/sys_jitter/clk_jitter/clk_wander individually using ntpq -c "rv 0 <name>"

@Jellyfrog
Copy link
Member

Please submit a pull request

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants