From 31451295d5a446f53acca5313ad4c59dda80bfe0 Mon Sep 17 00:00:00 2001 From: Kebo Liu Date: Tue, 24 Oct 2023 22:54:44 +0800 Subject: [PATCH] Add special rsyslog filter for MSN2700 platform (#16684) - Why I did it Mellanox MSN2700 platforms have a non-functional error log: "ERR pmon#sensord: Error getting sensor data: dps460/#10: Can't read". This error is because of a firmware issue with some PSU, we are not able to upgrade the FW online. Since there is no functional impact, this error log can be ignored safely. - How I did it Add a new rsyslog rule to the rsyslog-container.conf.j2, if the docker name is pmon and the platform name matches, the new rule will be inserted into the docker rsyslogd.conf - How to verify it run regression on the MSN2700 platform to make the error log will not be printed to the syslog. Signed-off-by: Kebo Liu --- files/build_templates/docker_image_ctl.j2 | 4 ++-- files/image_config/rsyslog/rsyslog-container.conf.j2 | 11 +++++++++++ 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/files/build_templates/docker_image_ctl.j2 b/files/build_templates/docker_image_ctl.j2 index 0b173d3eedb4..f8e5d8b4b5ad 100644 --- a/files/build_templates/docker_image_ctl.j2 +++ b/files/build_templates/docker_image_ctl.j2 @@ -47,10 +47,10 @@ function updateSyslogConf() {%- if docker_container_name == "database" %} python -c "import jinja2, os; paths=['/usr/share/sonic/templates']; loader = jinja2.FileSystemLoader(paths); env = jinja2.Environment(loader=loader, trim_blocks=True); template_file='/usr/share/sonic/templates/rsyslog-container.conf.j2'; template = env.get_template(os.path.basename(template_file)); data=template.render({\"target_ip\":\"$TARGET_IP\",\"container_name\":\"$CONTAINER_NAME\"}); print(data)" > $TMP_FILE {%- else %} - sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + sonic-cfggen -d -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\", \"platform\": \"$PLATFORM\" }" > $TMP_FILE if [ $? -ne 0 ]; then echo "Error: Execute sonic-cfggen -d failed. Execute without '-d'." - sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\" }" > $TMP_FILE + sonic-cfggen -t /usr/share/sonic/templates/rsyslog-container.conf.j2 -a "{\"target_ip\": \"$TARGET_IP\", \"container_name\": \"$CONTAINER_NAME\", \"platform\": \"$PLATFORM\" }" > $TMP_FILE fi {%- endif %} docker cp $TMP_FILE ${DOCKERNAME}:/etc/rsyslog.conf diff --git a/files/image_config/rsyslog/rsyslog-container.conf.j2 b/files/image_config/rsyslog/rsyslog-container.conf.j2 index a6419eba846a..bb786eacd4ec 100644 --- a/files/image_config/rsyslog/rsyslog-container.conf.j2 +++ b/files/image_config/rsyslog/rsyslog-container.conf.j2 @@ -52,7 +52,18 @@ $SystemLogRateLimitBurst 20000 ########################### #### GLOBAL DIRECTIVES #### ########################### +{% if container_name == 'pmon' %} +{% if platform == 'x86_64-mlnx_msn2700-r0' or platform == 'x86_64-mlnx_msn2700a1-r0' %} +# This rsyslog configuration is intended to resolve the following error message that only appears on the MSN2700 platform: +# "ERR pmon#sensord: Error getting sensor data: dps460/#10: Can't read" +# This error is because of firmware issue with some type of PSU, we are not able to upgrade the FW online. +# Since there is no functional impact, this error log can be ignored safely. + +if $programname contains "sensord" and $msg contains "Error getting sensor data: dps460/#" then stop + +{% endif %} +{% endif %} # 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")