Skip to content

Commit e962f95

Browse files
tsvanduynjleveque
authored andcommitted
[show] Add command 'show runningconfiguration syslog' (sonic-net#617)
1 parent b6ec539 commit e962f95

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed

doc/Command-Reference.md

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2959,6 +2959,7 @@ This sub-section explains the show commands for displaying the running configura
29592959
5) all
29602960
6) acl
29612961
7) ports
2962+
8) syslog
29622963

29632964
**show runningconfiguration all**
29642965

@@ -3012,6 +3013,24 @@ This command displays the running configuration of the ntp module.
30123013
admin@sonic:~$ show runningconfiguration ntp
30133014
```
30143015

3016+
**show runningconfiguration syslog**
3017+
3018+
This command displays the running configuration of the syslog module.
3019+
3020+
- Usage:
3021+
show runningconfiguration syslog
3022+
3023+
3024+
- Example:
3025+
```
3026+
admin@str-s6000-acs-11:~$ show run syslog
3027+
Syslog Servers
3028+
----------------
3029+
4.4.4.4
3030+
5.5.5.5
3031+
```
3032+
3033+
30153034
**show runningconfiguration snmp**
30163035

30173036
This command displays the running configuration of the snmp module.

show/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1480,6 +1480,24 @@ def ntp(verbose):
14801480
run_command(cmd, display_cmd=verbose)
14811481

14821482

1483+
# 'syslog' subcommand ("show runningconfiguration syslog")
1484+
@runningconfiguration.command()
1485+
@click.option('--verbose', is_flag=True, help="Enable verbose output")
1486+
def syslog(verbose):
1487+
"""Show Syslog running configuration"""
1488+
syslog_servers = []
1489+
syslog_dict = {}
1490+
with open("/etc/rsyslog.conf") as syslog_file:
1491+
data = syslog_file.readlines()
1492+
for line in data:
1493+
if line.startswith("*.* @"):
1494+
line = line.split(":")
1495+
server = line[0][5:]
1496+
syslog_servers.append(server)
1497+
syslog_dict['Syslog Servers'] = syslog_servers
1498+
print tabulate(syslog_dict, headers=syslog_dict.keys(), tablefmt="simple", stralign='left', missingval="")
1499+
1500+
14831501
#
14841502
# 'startupconfiguration' group ("show startupconfiguration ...")
14851503
#

0 commit comments

Comments
 (0)