diff --git a/dockers/docker-snmp/Dockerfile.j2 b/dockers/docker-snmp/Dockerfile.j2 index 174f1ae44150..d073e20ef910 100644 --- a/dockers/docker-snmp/Dockerfile.j2 +++ b/dockers/docker-snmp/Dockerfile.j2 @@ -66,9 +66,9 @@ RUN apt-get -y purge \ find / | grep -E "__pycache__" | xargs rm -rf && \ rm -rf /debs /python-wheels ~/.cache +COPY ["docker-snmp-init.sh", "/usr/bin/"] COPY ["start.sh", "/usr/bin/"] COPY ["snmp_yml_to_configdb.py", "/usr/bin/"] -COPY ["supervisord.conf", "/etc/supervisor/conf.d/"] COPY ["*.j2", "/usr/share/sonic/templates/"] COPY ["files/supervisor-proc-exit-listener", "/usr/bin"] COPY ["critical_processes", "/etc/supervisor"] @@ -76,4 +76,5 @@ COPY ["critical_processes", "/etc/supervisor"] # Although exposing ports is not needed for host net mode, keep it for possible bridge mode EXPOSE 161/udp 162/udp -ENTRYPOINT ["/usr/local/bin/supervisord"] +RUN chmod +x /usr/bin/docker-snmp-init.sh +ENTRYPOINT ["/usr/bin/docker-snmp-init.sh"] diff --git a/dockers/docker-snmp/docker-snmp-init.sh b/dockers/docker-snmp/docker-snmp-init.sh new file mode 100644 index 000000000000..135ff48255d6 --- /dev/null +++ b/dockers/docker-snmp/docker-snmp-init.sh @@ -0,0 +1,5 @@ +#!/usr/bin/env bash +#Generate supervisord.conf based on device metadata +mkdir -p /etc/supervisor/conf.d/ +sonic-cfggen -d -t /usr/share/sonic/templates/supervisord.conf.j2 > /etc/supervisor/conf.d/supervisord.conf +exec /usr/local/bin/supervisord diff --git a/dockers/docker-snmp/supervisord.conf b/dockers/docker-snmp/supervisord.conf.j2 similarity index 89% rename from dockers/docker-snmp/supervisord.conf rename to dockers/docker-snmp/supervisord.conf.j2 index 1f01a7c21e4b..bebc409564bd 100644 --- a/dockers/docker-snmp/supervisord.conf +++ b/dockers/docker-snmp/supervisord.conf.j2 @@ -50,7 +50,11 @@ dependent_startup=true dependent_startup_wait_for=start:exited [program:snmp-subagent] +{% if DEVICE_METADATA['localhost']['switch_type'] == 'chassis-packet' %} +command=/usr/bin/env python3 -m sonic_ax_impl --enable_dynamic_frequency +{% else %} command=/usr/bin/env python3 -m sonic_ax_impl +{% endif %} priority=4 autostart=false autorestart=false