chronyc: add wider output option

Add option '-w' which set the output width from 80 to 94. This allows
for all table-outputting operations to display IPv4 and IPv6 addresses
aligned with the headers.

Extend test/simulation/110-chronyc to test for the five commands which
support wide mode.

To set wide display, call `chronyc` with option `-w`.

Example of a `clients` list before and after:

chronyc -n clients -p 5
Hostname                      NTP   Drop Int IntL Last     Cmd   Drop Int  Last
===============================================================================
2001:db8:1234:5678:90ab:cdef:1234:5678     952      0   7   -    75       0      0   -     -
192.168.1.1                     0      0   -   -     -       0      0   -     -

chronyc -n -w clients -p 5
Hostname                                    NTP   Drop Int IntL Last     Cmd   Drop Int  Last
=============================================================================================
2001:db8:1234:5678:90ab:cdef:1234:5678      952      0   7   -    75       0      0   -     -
192.168.1.1                                   0      0   -   -     -       0      0   -     -
This commit is contained in:
Thomas Kupper
2026-02-14 12:24:32 +01:00
committed by Miroslav Lichvar
parent 4ddc6b334d
commit d622b222a9
3 changed files with 126 additions and 47 deletions

View File

@@ -103,6 +103,49 @@ check_chronyc_output "^#,.,SHM0.*
\.$" \
|| test_fail
client_conf=""
client_server_conf="
server node1.net1.clk
server ntp.notresolved.com
server 2001:db8:c001:cafe:1234:1234:1234:1234"
server_conf="server 192.168.123.1"
server_strata=1
cmdmon_unix=1
dns=0
chronyc_options="-w"
chronyc_conf="authdata -a
selectdata -a
sources -a
sourcestats -a
clients -k"
run_test || test_fail
check_chronyd_exit || test_fail
check_chronyc_output "^Name/IP address Mode KeyID Type KLen Last Atmp NAK Cook CLen
=======================================================================================
192\.168\.123\.1 - 0 0 0 - 0 0 0 0
ID#0000000002 - 0 0 0 - 0 0 0 0
(2001:db8:c001:cafe:1234:1234:1234:1234|ID#0000000003) [- ]+ 0 0 0 - 0 0 0 0
S Name/IP Address Auth COpts EOpts Last Score Interval Leap
=====================================================================================
\* 192\.168\.123\.1 N ----- ----- [0-9]+ 1\.0 [0-9 +-]+[un]s [0-9 +-]+[un]s N
M ID#0000000002 N ----- ----- 0 1\.0 \+0ns \+0ns \?
M (2001:db8:c001:cafe:1234:1234:1234:1234|ID#0000000003) [N ]+ ----- ----- 0 1\.0 \+0ns \+0ns \?
MS Name/IP address Stratum Poll Reach LastRx Last sample
=============================================================================================
\^\* 192\.168\.123\.1 1 [67] 377 [0-9]+ [0-9 +-]+[un]s\[[0-9 +-]+[un]s\] \+/-[ 0-9]+[un]s
\^\? ID#0000000002 0 [0-9]+ 0 - \+0ns\[ \+0ns\] \+/- 0ns
\^\? (2001:db8:c001:cafe:1234:1234:1234:1234|ID#0000000003) [0 ]+ [0-9]+ 0 - \+0ns\[ \+0ns\] \+/- 0ns
Name/IP Address NP NR Span Frequency Freq Skew Offset Std Dev
============================================================================================
192\.168\.123\.1 [0-9 ]+ [0-9 ]+ [0-9 ]+ [ +-][01]\.... [0-9 ]+\.... [0-9 +-]+[un]s [0-9 ]+[un]s
ID#0000000002 0 0 0 \+0\.000 2000\.000 \+0ns 4000ms
(2001:db8:c001:cafe:1234:1234:1234:1234|ID#0000000003) [0 ]+ 0 0 \+0\.000 2000\.000 \+0ns 4000ms
Hostname NTP Drop Int IntL Last NTS-KE Drop Int Last
=============================================================================================$" || test_fail
chronyc_options=""
server_strata=0
chronyc_start=0.5
@@ -110,6 +153,8 @@ client_server_conf=""
client_conf=""
server_conf="server 192.168.123.1"
limit=1
dns=1
cmdmon_unix=0
for chronyc_conf in \
"accheck 1.2.3.4" \