-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
syslog changes Multi ASIC platforms (#4738)
Add changes for syslog support for containers running in namespaces on multi ASIC platforms. On Multi ASIC platforms Rsyslog service is only running on the host. There is no rsyslog service running in each namespace. On multi ASIC platforms the rsyslog service on the host will be listening on the docker0 ip address instead of loopback address. The rsyslog.conf on the containers is modified to have omfwd target ip to be docker0 ipaddress instead of loopback ip Signed-off-by: Arvindsrinivasan Lakshmi Narasimhan <arlakshm@microsoft.com>
- Loading branch information
Showing
5 changed files
with
115 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,23 @@ | ||
#!/bin/bash | ||
|
||
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 >/etc/rsyslog.conf | ||
PLATFORM=`sonic-cfggen -H -v DEVICE_METADATA.localhost.platform` | ||
|
||
# Parse the device specific asic conf file, if it exists | ||
ASIC_CONF=/usr/share/sonic/device/$PLATFORM/asic.conf | ||
if [ -f "$ASIC_CONF" ]; then | ||
source $ASIC_CONF | ||
fi | ||
|
||
# On Multi NPU platforms we need to start the rsyslog server on the docker0 ip address | ||
# for the syslogs from the containers in the namespaces to work. | ||
# on Single NPU platforms we continue to use loopback adddres | ||
|
||
if [[ ($NUM_ASIC -gt 1) ]]; then | ||
udp_server_ip=$(ip -o -4 addr list docker0 | awk '{print $4}' | cut -d/ -f1) | ||
else | ||
udp_server_ip=$(ip -o -4 addr list lo scope host | awk '{print $4}' | cut -d/ -f1) | ||
fi | ||
|
||
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 -a "{\"udp_server_ip\": \"$udp_server_ip\"}" >/etc/rsyslog.conf | ||
|
||
systemctl restart rsyslog |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
# | ||
# /etc/rsyslog.conf Configuration file for rsyslog. | ||
# | ||
# For more information see | ||
# /usr/share/doc/rsyslog-doc/html/rsyslog_conf.html | ||
|
||
|
||
################# | ||
#### MODULES #### | ||
################# | ||
|
||
$ModLoad imuxsock # provides support for local system logging | ||
|
||
# | ||
# Set a rate limit on messages from the container | ||
# | ||
$SystemLogRateLimitInterval 300 | ||
$SystemLogRateLimitBurst 20000 | ||
|
||
#$ModLoad imklog # provides kernel logging support | ||
#$ModLoad immark # provides --MARK-- message capability | ||
|
||
# provides UDP syslog reception | ||
#$ModLoad imudp | ||
#$UDPServerRun 514 | ||
|
||
# provides TCP syslog reception | ||
#$ModLoad imtcp | ||
#$InputTCPServerRun 514 | ||
|
||
|
||
########################### | ||
#### GLOBAL DIRECTIVES #### | ||
########################### | ||
|
||
# Set remote syslog server | ||
template (name="ForwardFormatInContainer" type="string" string="<%PRI%>%TIMESTAMP:::date-rfc3339% %HOSTNAME% {{container_name}}#%syslogtag%%msg:::sp-if-no-1st-sp%%msg%") | ||
*.* action(type="omfwd" target="{{target_ip}}" port="514" protocol="udp" Template="ForwardFormatInContainer") | ||
|
||
# | ||
# Use traditional timestamp format. | ||
# To enable high precision timestamps, comment out the following line. | ||
# | ||
#$ActionFileDefaultTemplate RSYSLOG_TraditionalFileFormat | ||
|
||
# Define a custom template | ||
$template SONiCFileFormat,"%TIMESTAMP%.%timestamp:::date-subseconds% %HOSTNAME% %syslogseverity-text:::uppercase% {{container_name}}#%syslogtag%%msg:::sp-if-no-1st-sp%%msg:::drop-last-lf%\n" | ||
$ActionFileDefaultTemplate SONiCFileFormat | ||
|
||
# | ||
# Set the default permissions for all log files. | ||
# | ||
$FileOwner root | ||
$FileGroup adm | ||
$FileCreateMode 0640 | ||
$DirCreateMode 0755 | ||
$Umask 0022 | ||
|
||
# | ||
# Where to place spool and state files | ||
# | ||
$WorkDirectory /var/spool/rsyslog | ||
|
||
# | ||
# Include all config files in /etc/rsyslog.d/ | ||
# | ||
$IncludeConfig /etc/rsyslog.d/*.conf | ||
|
||
# | ||
# Suppress duplicate messages and report "message repeated n times" | ||
# | ||
$RepeatedMsgReduction on | ||
|
||
############### | ||
#### RULES #### | ||
############### |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters