Project

General

Profile

Bug #10307

NTP status widget doesn't display stratum

Added by Adam Thompson 8 months ago. Updated about 18 hours ago.

Status:
Resolved
Priority:
Normal
Assignee:
Category:
NTPD
Target version:
Start date:
03/01/2020
Due date:
% Done:

100%

Estimated time:
Affected Version:
2.4.4-p3
Affected Architecture:

Description

On 2.4.4-RELEASE-p3, if I have a) an IPv6 NTP server, and b) the NTP status widget on the dashboard, the widget doesn't display the stratum correctly:

NTP Status 
Server Time    10:08:58 CST
Sync Source    2620:19:4000:100::86 (stratum )

where stratum is blank entirely.

Meanwhile, the NTP Status page displays stratum for all servers:

Network Time Protocol Status
Pool Placeholder    pfsense.pool.nt    .POOL.    16    p    -    64    0    0.000    0.000    0.000
Pool Placeholder    time.mbix.ca    .POOL.    16    p    -    64    0    0.000    0.000    0.000
Active Peer    2620:19:4000:10    16.164.40.197    2    u    504    512    377    4.913    3.742    1.795
Candidate    2620:19:4000:10    132.246.11.229    3    u    293    512    357    4.550    3.176    2.987
Outlier    2620:19:4000:10    16.164.40.197    2    u    294    512    377    6.126    1.612    1.855
Candidate    198.181.199.86    16.164.40.197    2    u    519    512    377    3.291    2.311    1.829
Candidate    198.181.199.84    132.246.11.229    3    u    17    512    377    4.055    3.105    2.640
Candidate    198.181.199.82    16.164.40.197    2    u    432    512    377    3.658    3.368    1.722

No idea if it affects other arches (although I would guess it probably does).
Not sure if this should be "Dashboard" or "NTPD" category.

Immagine.jpg (111 KB) Immagine.jpg ntp status page - viktor patch Manuel Piovan, 03/09/2020 06:09 AM
Immagine2.jpg (15.7 KB) Immagine2.jpg ntp widget -viktor patch Manuel Piovan, 03/09/2020 06:11 AM
Immagine3.jpg (86.7 KB) Immagine3.jpg Manuel Piovan, 03/09/2020 07:19 AM

Associated revisions

Revision b69ecd3a (diff)
Added by Viktor Gurov 8 months ago

NTP status/widget long IPv6 address. Issue #10307

Revision d09e19ad (diff)
Added by Jim Pingle 8 months ago

Use awk instead of sed for long NTP status lines. Fixes #10307

History

#1 Updated by Adam Thompson 8 months ago

Ohhh... as soon as it selects a sane peer, the problem goes away.
Now I don't know if the problem is "Outlier" or if the problem is IPv6 addresses.

#2 Updated by Manuel Piovan 8 months ago

affected version also 2.5.0
Candidate 192.168.10.200 .GPS. 1 u 28 64 17 0.187 -0.436 0.048
Candidate 172.17.0.100 192.168.10.200 2 u 25 64 17 0.971 -0.111 0.065
Active Peer 2001:470:26:5dc .GPS. 1 u 21 64 17
^ address truncated
ntp widget
Sync Source 2001:470:26:5dc:ffff:ffff:ffff:fffe (stratum )

ntp_status.widget.php line 41 -> exec("/usr/local/sbin/ntpq -pn -w $inet_version | /usr/bin/tail +3", $ntpq_output);

the problem is with the -w flag

[2.5.0-DEVELOPMENT][]/root: /usr/local/sbin/ntpq -pn -w | /usr/bin/tail +3
+192.168.10.200 .GPS. 1 u 24 64 377 0.272 -0.042 0.016
-172.17.0.100 192.168.10.200 2 u 7 128 377 1.053 -0.160 0.069
*2001:470:26:5dc:ffff:ffff:ffff:fffe
.GPS. 1 u 13 64 377 0.279 -0.079 1.379
0.it.pool.ntp.org
.POOL. 16 p - 64 0 0.000 +0.000 0.002
+185.19.184.35 193.204.114.233 2 u 15 64 377 18.030 +4.095 0.364
+212.45.144.3 193.204.114.232 2 u 66 64 377 18.574 +4.374 5.044
+46.235.141.130 85.199.214.99 2 u 7 128 377 31.823 +5.108 0.114
+212.45.144.88 193.204.114.233 2 u 2 128 377 18.133 +2.920 6.557
+85.199.214.99 .GPS. 1 u 7 64 377 46.107 +6.538 0.497
+162.159.200.1 10.39.8.8 3 u 9 128 377 17.660 +3.786 0.506

the regexp at line 48 does not match

without -w the address is truncated but regexp work and show the right stratum
Sync Source 2001:470:26:5dc (stratum 1, .GPS.)

introduced by Do not truncate IPv6 addresss in NTP widget (Bug #4815)

#3 Updated by Viktor Gurov 8 months ago

Also NTP status page shows truncated IPv6 address

from ntpq(1):


 -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.

This PR fixes both issues:
https://github.com/pfsense/pfsense/pull/4223

#4 Updated by Manuel Piovan 8 months ago

tested it, work partially

NTP status page is wrong for me the table is shifted of 1 place after the long ipv6 address

NTP widget show

2001:470:26:5dc:ffff:ffff:ffff:fffe (stratum .GPS.)

you can see refid .GPS. but stratum is empty

keep up the good work viktor, you have all my esteem for your hard work !

#5 Updated by Manuel Piovan 8 months ago

screenshot added

#6 Updated by Viktor Gurov 8 months ago

Thanks for testing!

Can you show 'ntpq -pn -w' output?

#7 Updated by Manuel Piovan 8 months ago

of course
the problwm with the -w flag is that 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.

#8 Updated by Jim Pingle 8 months ago

We've hit that newline issue before with ntpq output -- see #4815

Probably will break more than it helps by adding -w in situations where it forces a newline, but perhaps we can find a regex or similar way to parse the output which mitigates that.

#9 Updated by Jim Pingle 8 months ago

  • Status changed from New to Pull Request Review
  • Target version set to 2.5.0

#10 Updated by Renato Botelho 8 months ago

  • Status changed from Pull Request Review to Feedback
  • Assignee set to Renato Botelho
  • % Done changed from 0 to 100

PR has been merged. Thanks!

#11 Updated by Jim Pingle 8 months ago

  • Status changed from Feedback to In Progress
  • Assignee changed from Renato Botelho to Jim Pingle
  • % Done changed from 100 to 90

Looks like the sed pattern I suggested will skip the last line in certain cases. Need to tinker with it some more. It also doesn't properly handle some peer lines since they can start with a space. That's an easy fix, but the last line being skipped is tougher. The sed N command has to operate on pairs of lines. I've found some workarounds but so far none have worked properly. Might have to use awk instead, but that is a bit more complex.

#12 Updated by Jim Pingle 8 months ago

  • % Done changed from 90 to 100

I just pushed a new version using awk instead of sed which fixes the reported problem plus the other problem I found.

#13 Updated by Jim Pingle 8 months ago

  • Status changed from In Progress to Feedback

#14 Updated by Ronald Schellberg 8 months ago

Latest commit appears to work even for the peer on the last line. Thanks

#15 Updated by Manuel Piovan 8 months ago

yup work ok with my long ipv6 address too

#16 Updated by Viktor Gurov 8 months ago

  • Status changed from Feedback to Resolved

work ok with any address on 2.5.0.a.20200312.1334

#17 Updated by Jim Pingle about 18 hours ago

  • Category changed from Dashboard to NTPD

Also available in: Atom PDF