Skip to content

Commit bf57f4b

Browse files
tsvanduynjleveque
authored andcommitted
[show] Add command 'show runningconfig ntp' (sonic-net#620)
1 parent e962f95 commit bf57f4b

File tree

2 files changed

+16
-4
lines changed

2 files changed

+16
-4
lines changed

doc/Command-Reference.md

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3010,7 +3010,11 @@ This command displays the running configuration of the ntp module.
30103010

30113011
- Example:
30123012
```
3013-
admin@sonic:~$ show runningconfiguration ntp
3013+
admin@str-s6000-acs-11:~$ show runningconfiguration ntp
3014+
NTP Servers
3015+
-------------
3016+
1.1.1.1
3017+
2.2.2.2
30143018
```
30153019

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

30243028
- Example:
30253029
```
3026-
admin@str-s6000-acs-11:~$ show run syslog
3030+
admin@str-s6000-acs-11:~$ show runningconfiguration syslog
30273031
Syslog Servers
30283032
----------------
30293033
4.4.4.4

show/main.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1476,8 +1476,16 @@ def snmp(server, verbose):
14761476
@click.option('--verbose', is_flag=True, help="Enable verbose output")
14771477
def ntp(verbose):
14781478
"""Show NTP running configuration"""
1479-
cmd = "cat /etc/ntp.conf"
1480-
run_command(cmd, display_cmd=verbose)
1479+
ntp_servers = []
1480+
ntp_dict = {}
1481+
with open("/etc/ntp.conf") as ntp_file:
1482+
data = ntp_file.readlines()
1483+
for line in data:
1484+
if line.startswith("server "):
1485+
ntp_server = line.split(" ")[1]
1486+
ntp_servers.append(ntp_server)
1487+
ntp_dict['NTP Servers'] = ntp_servers
1488+
print tabulate(ntp_dict, headers=ntp_dict.keys(), tablefmt="simple", stralign='left', missingval="")
14811489

14821490

14831491
# 'syslog' subcommand ("show runningconfiguration syslog")

0 commit comments

Comments
 (0)