Skip to content

Commit

Permalink
[show] Add ntpstat output to show ntp (sonic-net#861)
Browse files Browse the repository at this point in the history
Signed-off-by: yangshiping <[email protected]>
  • Loading branch information
yangshp1987 authored May 11, 2020
1 parent 157f4ae commit 8bfa3b7
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 4 deletions.
5 changes: 5 additions & 0 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3997,12 +3997,17 @@ This command displays a list of NTP peers known to the server as well as a summa
- Example:
```
admin@sonic:~$ show ntp
synchronised to NTP server (204.2.134.164) at stratum 3
time correct to within 326797 ms
polling server every 1024 s

remote refid st t when poll reach delay offset jitter
==============================================================================
23.92.29.245 .XFAC. 16 u - 1024 0 0.000 0.000 0.000
*204.2.134.164 46.233.231.73 2 u 916 1024 377 3.079 0.394 0.128
```
### NTP Config Commands
This sub-section of commands is used to add or remove the configured NTP servers.
Expand Down
10 changes: 6 additions & 4 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -2028,20 +2028,22 @@ def bgp(verbose):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ntp(ctx, verbose):
"""Show NTP information"""
ntpstat_cmd = "ntpstat"
ntpcmd = "ntpq -p -n"
if is_mgmt_vrf_enabled(ctx) is True:
#ManagementVRF is enabled. Call ntpq using "ip vrf exec" or cgexec based on linux version
os_info = os.uname()
release = os_info[2].split('-')
if parse_version(release[0]) > parse_version("4.9.0"):
ntpcmd = "ip vrf exec mgmt ntpq -p -n"
ntpstat_cmd = "sudo ip vrf exec mgmt ntpstat"
ntpcmd = "sudo ip vrf exec mgmt ntpq -p -n"
else:
ntpcmd = "cgexec -g l3mdev:mgmt ntpq -p -n"
ntpstat_cmd = "sudo cgexec -g l3mdev:mgmt ntpstat"
ntpcmd = "sudo cgexec -g l3mdev:mgmt ntpq -p -n"

run_command(ntpstat_cmd, display_cmd=verbose)
run_command(ntpcmd, display_cmd=verbose)



#
# 'uptime' command ("show uptime")
#
Expand Down

0 comments on commit 8bfa3b7

Please sign in to comment.