Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions dockers/docker-router-advertiser/base_image_files/monit_radv.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{# This template file is used to generate Monit configuration file of router advertiser container. -#}

{# Router advertiser should only run on ToR (T0) devices which have #}
{# at least one VLAN interface which has an IPv6 address asigned #}
{# But not for specific deployment_id #}
{%- set vlan_v6 = namespace(count=0) -%}
{%- if DEVICE_METADATA is defined and DEVICE_METADATA.localhost is defined -%}
{%- if DEVICE_METADATA.localhost.deployment_id is defined and DEVICE_METADATA.localhost.type is defined -%}
{%- if DEVICE_METADATA.localhost.deployment_id != "8" -%}
{%- if "ToRRouter" in DEVICE_METADATA.localhost.type and DEVICE_METADATA.localhost.type != "MgmtToRRouter" -%}
{%- if VLAN_INTERFACE -%}
{%- for (name, prefix) in VLAN_INTERFACE|pfx_filter -%}
{# If this VLAN has an IPv6 address... #}
{%- if prefix | ipv6 -%}
{%- set vlan_v6.count = vlan_v6.count + 1 -%}
{%- endif -%}
{%- endfor -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}
{%- endif -%}

{%- if vlan_v6.count > 0 %}
###############################################################################
## Monit configuration for radv container
## process list:
## radvd
###############################################################################
check program radv|radvd with path "/usr/bin/process_checker radv /usr/sbin/radvd -n"
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
{% endif -%}
4 changes: 3 additions & 1 deletion files/build_templates/sonic_debian_extension.j2
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,9 @@ sudo cp $IMAGE_CONFIGS/monit/process_checker $FILESYSTEM_ROOT/usr/bin/
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/process_checker
sudo cp $IMAGE_CONFIGS/monit/container_checker $FILESYSTEM_ROOT/usr/bin/
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/container_checker

sudo cp $IMAGE_CONFIGS/monit/generate_monit_config.service $FILESYSTEM_ROOT_USR_LIB_SYSTEMD_SYSTEM
sudo cp $IMAGE_CONFIGS/monit/generate_monit_config $FILESYSTEM_ROOT/usr/bin/
sudo chmod 755 $FILESYSTEM_ROOT/usr/bin/generate_monit_config

# Install custom-built openssh sshd
sudo dpkg --root=$FILESYSTEM_ROOT -i $debs_path/openssh-server_*.deb
Expand Down
6 changes: 6 additions & 0 deletions files/image_config/monit/generate_monit_config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/bin/bash

CFGGEN_PARAMS=" \
-d -t /usr/share/sonic/templates/monit_radv.j2,/etc/monit/conf.d/monit_radv \
"
sonic-cfggen $CFGGEN_PARAMS
13 changes: 13 additions & 0 deletions files/image_config/monit/generate_monit_config.service
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
[Unit]
Description=Generate Monit configuration file from template
Requires=updategraph.service
After=updategraph.service
Before=monit.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/usr/bin/generate_monit_config

[Install]
WantedBy=multi-user.target
1 change: 1 addition & 0 deletions rules/docker-router-advertiser.mk
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ $(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += --privileged -t
$(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += -v /etc/sonic:/etc/sonic:ro
$(DOCKER_ROUTER_ADVERTISER)_RUN_OPT += -v /usr/share/sonic/scripts:/usr/share/sonic/scripts:ro
$(DOCKER_ROUTER_ADVERTISER)_FILES += $(SUPERVISOR_PROC_EXIT_LISTENER_SCRIPT)
$(DOCKER_ROUTER_ADVERTISER)_BASE_IMAGE_FILES += monit_radv.j2:/usr/share/sonic/tempaltes