Skip to content

Commit 8bfa3b7

Browse files
authored
[show] Add ntpstat output to show ntp (sonic-net#861)
Signed-off-by: yangshiping <yangshiping@jd.com>
1 parent 157f4ae commit 8bfa3b7

2 files changed

Lines changed: 11 additions & 4 deletions

File tree

doc/Command-Reference.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,12 +3997,17 @@ This command displays a list of NTP peers known to the server as well as a summa
39973997
- Example:
39983998
```
39993999
admin@sonic:~$ show ntp
4000+
synchronised to NTP server (204.2.134.164) at stratum 3
4001+
time correct to within 326797 ms
4002+
polling server every 1024 s
4003+
40004004
remote refid st t when poll reach delay offset jitter
40014005
==============================================================================
40024006
23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000
40034007
*204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128
40044008
```
40054009
4010+
40064011
### NTP Config Commands
40074012
40084013
This sub-section of commands is used to add or remove the configured NTP servers.

show/main.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2028,20 +2028,22 @@ def bgp(verbose):
20282028
@click.option('--verbose', is_flag=True, help="Enable verbose output")
20292029
def ntp(ctx, verbose):
20302030
"""Show NTP information"""
2031+
ntpstat_cmd = "ntpstat"
20312032
ntpcmd = "ntpq -p -n"
20322033
if is_mgmt_vrf_enabled(ctx) is True:
20332034
#ManagementVRF is enabled. Call ntpq using "ip vrf exec" or cgexec based on linux version
20342035
os_info = os.uname()
20352036
release = os_info[2].split('-')
20362037
if parse_version(release[0]) > parse_version("4.9.0"):
2037-
ntpcmd = "ip vrf exec mgmt ntpq -p -n"
2038+
ntpstat_cmd = "sudo ip vrf exec mgmt ntpstat"
2039+
ntpcmd = "sudo ip vrf exec mgmt ntpq -p -n"
20382040
else:
2039-
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
2041+
ntpstat_cmd = "sudo cgexec -g l3mdev:mgmt ntpstat"
2042+
ntpcmd = "sudo cgexec -g l3mdev:mgmt ntpq -p -n"
20402043

2044+
run_command(ntpstat_cmd, display_cmd=verbose)
20412045
run_command(ntpcmd, display_cmd=verbose)
20422046

2043-
2044-
20452047
#
20462048
# 'uptime' command ("show uptime")
20472049
#

0 commit comments

Comments
 (0)