528543bc6a
Signed-off-by: Yong Zhao yozhao@microsoft.com Why I did it This PR aims to monitor critical processes in router advertiser and dhcp_relay containers by Monit. How I did it Router advertiser container only ran on T0 device and the T0 device should have at least one VLAN interface which was configured an IPv6 address. At the same time, router advertiser container will not run on devices of which the deployment type is 8. As such, I created a service which will dynamically generate Monit configuration file of router advertiser from a template. Similarly Monit configuration file of dhcp_relay was also generated from a template since the number of dhcrelay process in dhcp_relay container is depended on number of VLANs. How to verify it I verified this implementation on a DuT.
34 lines
1.5 KiB
Django/Jinja
34 lines
1.5 KiB
Django/Jinja
{# This template is used to generate Monit configuration file of router advertiser container -#}
|
|
|
|
###############################################################################
|
|
## Monit configuration for radv container
|
|
## process list:
|
|
## radvd
|
|
###############################################################################
|
|
{# 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 -%}
|
|
{# Check the running status of radvd process #}
|
|
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 -%}
|