Skip to content

Commit

Permalink
[show] Add command 'show runningconfig ntp' (sonic-net#620)
Browse files Browse the repository at this point in the history
  • Loading branch information
tsvanduyn authored and jleveque committed Aug 26, 2019
1 parent e962f95 commit bf57f4b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 4 deletions.
8 changes: 6 additions & 2 deletions doc/Command-Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -3010,7 +3010,11 @@ This command displays the running configuration of the ntp module.

- Example:
```
admin@sonic:~$ show runningconfiguration ntp
admin@str-s6000-acs-11:~$ show runningconfiguration ntp
NTP Servers
-------------
1.1.1.1
2.2.2.2
```

**show runningconfiguration syslog**
Expand All @@ -3023,7 +3027,7 @@ This command displays the running configuration of the syslog module.

- Example:
```
admin@str-s6000-acs-11:~$ show run syslog
admin@str-s6000-acs-11:~$ show runningconfiguration syslog
Syslog Servers
----------------
4.4.4.4
Expand Down
12 changes: 10 additions & 2 deletions show/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -1476,8 +1476,16 @@ def snmp(server, verbose):
@click.option('--verbose', is_flag=True, help="Enable verbose output")
def ntp(verbose):
"""Show NTP running configuration"""
cmd = "cat /etc/ntp.conf"
run_command(cmd, display_cmd=verbose)
ntp_servers = []
ntp_dict = {}
with open("/etc/ntp.conf") as ntp_file:
data = ntp_file.readlines()
for line in data:
if line.startswith("server "):
ntp_server = line.split(" ")[1]
ntp_servers.append(ntp_server)
ntp_dict['NTP Servers'] = ntp_servers
print tabulate(ntp_dict, headers=ntp_dict.keys(), tablefmt="simple", stralign='left', missingval="")


# 'syslog' subcommand ("show runningconfiguration syslog")
Expand Down

0 comments on commit bf57f4b

Please sign in to comment.