2017-01-29 13:33:33 -06:00
|
|
|
#!/bin/bash
|
|
|
|
|
2020-06-30 08:29:20 -05:00
|
|
|
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
|
2021-11-03 20:29:09 -05:00
|
|
|
udp_server_ip=$(ip -o -4 addr list docker0 | awk '{print $4}' | cut -d/ -f1)
|
2020-06-30 08:29:20 -05:00
|
|
|
else
|
2021-08-09 21:53:49 -05:00
|
|
|
udp_server_ip=$(ip -j -4 addr list lo scope host | jq -r -M '.[0].addr_info[0].local')
|
2020-06-30 08:29:20 -05:00
|
|
|
fi
|
2023-07-10 13:40:08 -05:00
|
|
|
hostname=$(hostname)
|
2020-06-30 08:29:20 -05:00
|
|
|
|
2023-07-10 13:40:08 -05:00
|
|
|
sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog.conf.j2 \
|
|
|
|
-a "{\"udp_server_ip\": \"$udp_server_ip\", \"hostname\": \"$hostname\"}" \
|
|
|
|
> /etc/rsyslog.conf
|
2020-06-30 08:29:20 -05:00
|
|
|
|
2017-07-27 21:52:22 -05:00
|
|
|
systemctl restart rsyslog
|