-
Notifications
You must be signed in to change notification settings - Fork 1.8k
[201911][Monit] Monitor critical processes in radv and dhcp_relay containers. #7340
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
36 changes: 36 additions & 0 deletions
36
dockers/docker-dhcp-relay/base_image_files/monit_dhcp_relay.j2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| {# 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 -%} | ||
33 changes: 33 additions & 0 deletions
33
dockers/docker-router-advertiser/base_image_files/monit_radv.j2
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,33 @@ | ||
| {# 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 -%} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,12 @@ | ||
| #!/bin/bash | ||
|
|
||
| # Generate the following files from templates: | ||
| # 1. Monit configuration file of radv container | ||
| # 2. Monit configuration file of dhcp_relay container | ||
|
|
||
| CFGGEN_PARAMS=" \ | ||
| -d \ | ||
| -t /usr/share/sonic/templates/monit_radv.j2,/etc/monit/conf.d/monit_radv \ | ||
| -t /usr/share/sonic/templates/monit_dhcp_relay.j2,/etc/monit/conf.d/monit_dhcp_relay \ | ||
| " | ||
| sonic-cfggen $CFGGEN_PARAMS |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.