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.
37 lines
1.8 KiB
Django/Jinja
37 lines
1.8 KiB
Django/Jinja
{# This template file is used to generate Monit configuration file of dhcp_relay container -#}
|
|
|
|
################################################################################
|
|
## Monit configuration file for dhcp_relay container
|
|
## process list:
|
|
## dhcrelay
|
|
################################################################################
|
|
{# If our configuration has VLANs... #}
|
|
{%- if VLAN_INTERFACE -%}
|
|
{# Count how may VLANs require a DHCP relay agent... #}
|
|
{%- set num_relays = namespace(count=0) -%}
|
|
{%- for vlan_name in VLAN_INTERFACE -%}
|
|
{%- if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length > 0 -%}
|
|
{%- set num_relays.count = num_relays.count + 1 -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{# if one or more VLANs require DHCP relay agent #}
|
|
{%- if num_relays.count > 0 -%}
|
|
{%- set relay_for_ipv4 = namespace(flag=False) -%}
|
|
{%- for vlan_name in VLAN_INTERFACE -%}
|
|
{%- if VLAN and vlan_name in VLAN and 'dhcp_servers' in VLAN[vlan_name] and VLAN[vlan_name]['dhcp_servers']|length >0 -%}
|
|
{%- for dhcp_server in VLAN[vlan_name]['dhcp_servers'] -%}
|
|
{%- if dhcp_server | ipv4 -%}
|
|
{%- set relay_for_ipv4.flag = True -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- if relay_for_ipv4.flag -%}
|
|
{%- set relay_for_ipv4 = False -%}
|
|
{# Check the running status of each DHCP relay agent instance #}
|
|
check program dhcp_relay|dhcrelay with path "/usr/bin/process_checker dhcp_relay /usr/sbin/dhcrelay -d -m discard -a %h:%p %P --name-alias-map-file /tmp/port-name-alias-map.txt -id {{ vlan_name }}"
|
|
if status != 0 for 5 times within 5 cycles then alert repeat every 1 cycles
|
|
{%- endif -%}
|
|
{%- endif -%}
|
|
{%- endfor -%}
|
|
{%- endif -%}
|
|
{%- endif -%}
|