sonic-buildimage/dockers
yozhao101 e6c18fa6dd [Monit] Fix the issue which shows Monit can not reset its counter. (#10288)
Signed-off-by: Yong Zhao <yozhao@microsoft.com>

Why I did it
This PR aims to fix the Monit issue which shows Monit can't reset its counter when monitoring memory usage of telemetry container.

Specifically the Monit configuration file related to monitoring memory usage of telemetry container is as following:

  check program container_memory_telemetry with path "/usr/bin/memory_checker telemetry 419430400"
      if status == 3 for 10 times within 20 cycles then exec "/usr/bin/restart_service telemetry"
If memory usage of telemetry container is larger than 400MB for 10 times within 20 cycles (minutes), then it will be restarted.
Recently we observed, after telemetry container was restarted, its memory usage continuously increased from 400MB to 11GB within 1 hour, but it was not restarted anymore during this 1 hour sliding window.

The reason is Monit can't reset its counter to count again and Monit can reset its counter if and only if the status of monitored service was changed from Status failed to Status ok. However, during this 1 hour sliding window, the status of monitored service was not changed from Status failed to Status ok.

Currently for each service monitored by Monit, there will be an entry showing the monitoring status, monitoring mode etc. For example, the following output from command sudo monit status shows the status of monitored service to monitor memory usage of telemetry:

    Program 'container_memory_telemetry'
         status                             Status ok
         monitoring status          Monitored
         monitoring mode          active
         on reboot                      start
         last exit value                0
         last output                    -
         data collected               Sat, 19 Mar 2022 19:56:26
Every 1 minute, Monit will run the script to check the memory usage of telemetry and update the counter if memory usage is larger than 400MB. If Monit checked the counter and found memory usage of telemetry is larger than 400MB for 10 times
within 20 minutes, then telemetry container was restarted. Following is an example status of monitored service:

    Program 'container_memory_telemetry'
         status                             Status failed
         monitoring status          Monitored
         monitoring mode          active
         on reboot                      start
         last exit value                0
         last output                    -
         data collected               Tue, 01 Feb 2022 22:52:55
After telemetry container was restarted. we found memory usage of telemetry increased rapidly from around 100MB to more than 400MB during 1 minute and status of monitored service did not have a chance to be changed from Status failed to Status ok.

How I did it
In order to provide a workaround for this issue, Monit recently introduced another syntax format repeat every <n> cycles related to exec. This new syntax format will enable Monit repeat executing the background script if the error persists for a given number of cycles.

How to verify it
I verified this change on lab device str-s6000-acs-12. Another pytest PR (Azure/sonic-mgmt#5492) is submitted in sonic-mgmt repo for review.
2022-04-21 22:00:42 +00:00
..
docker-base Add a config variable to override default container registry instead of dockerhub. (#10166) (#10262) 2022-03-18 12:01:52 +08:00
docker-base-buster Image disk space reduction (#10172) (#10371) 2022-03-29 10:11:28 -07:00
docker-base-stretch Add a config variable to override default container registry instead of dockerhub. (#10166) (#10262) 2022-03-18 12:01:52 +08:00
docker-basic_router [supervisord]: use abspath as supervisord entrypoint (#5995) 2020-11-22 21:18:44 -08:00
docker-config-engine [docker-base-buster][docker-config-engine-buster] No longer install Python 2 (#6162) 2020-12-25 21:29:25 -08:00
docker-config-engine-buster Image disk space reduction (#10172) (#10371) 2022-03-29 10:11:28 -07:00
docker-config-engine-stretch [docker-base-buster][docker-config-engine-buster] No longer install Python 2 (#6162) 2020-12-25 21:29:25 -08:00
docker-database [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
docker-dhcp-relay [dhcp_relay] Remove dhcp6mon (#10467) 2022-04-12 18:39:19 +00:00
docker-fpm-frr Add dualtor TSA/B/C support (#9726) 2022-03-08 19:02:06 +00:00
docker-fpm-gobgp [202012][dockers][supervisor] Increase event buffer size for process exit listener; Set all event buffer sizes to 1024 (#7203) 2021-04-01 12:52:19 -07:00
docker-iccpd [iccpd][docker] fix initial startup configuration (#7982) 2021-08-05 15:21:33 +00:00
docker-lldp [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
docker-mux [mux]: Call write_standby from host only 2021-11-10 18:54:33 -08:00
docker-nat Create a docker-swss-layer that holds the swss package. 2022-01-27 23:53:09 -08:00
docker-orchagent [scapy] update scapy to 2.4.5 and patch it (#10457) 2022-04-07 22:57:47 +00:00
docker-platform-monitor fix build error (#9902) 2022-02-03 08:52:29 +05:30
docker-ptf Add a config variable to override default container registry instead of dockerhub. (#10166) (#10262) 2022-03-18 12:01:52 +08:00
docker-ptf-sai [PTF-SAIv2]Add ptf docker for sai-ptf (saiv2) (#9729) 2022-02-23 22:46:33 +00:00
docker-router-advertiser Update docker-router-advertiser.supervisord.conf.j2 (#10375) 2022-04-07 22:57:37 +00:00
docker-sflow Create a docker-swss-layer that holds the swss package. 2022-01-27 23:53:09 -08:00
docker-snmp updated jinja template for snmp contact python2 vs python3 issue (#9949) 2022-02-12 01:06:13 +00:00
docker-sonic-mgmt Add a config variable to override default container registry instead of dockerhub. (#10166) (#10262) 2022-03-18 12:01:52 +08:00
docker-sonic-mgmt-framework Image disk space reduction (#10172) (#10371) 2022-03-29 10:11:28 -07:00
docker-sonic-restapi [restapi]: Don't use python/python2 for restapi start scripts (#10285) 2022-03-22 18:35:27 -07:00
docker-sonic-telemetry [Monit] Fix the issue which shows Monit can not reset its counter. (#10288) 2022-04-21 22:00:42 +00:00
docker-swss-layer-buster Create a docker-swss-layer that holds the swss package. 2022-01-27 23:53:09 -08:00
docker-teamd Create a docker-swss-layer that holds the swss package. 2022-01-27 23:53:09 -08:00
dockerfile-macros.j2 [sonic-config-engine] Clean up dependencies, pin versions; install Python 3 package in Buster container (#5656) 2020-10-26 13:48:50 -07:00