sonic-buildimage/platform
Hua Liu 1f3da955b9
[S6100] Improve S6100 serial-getty monitor, wait and re-check when getty not running to avoid false alert. (#14402) (#14755)
[S6100] Improve S6100 serial-getty monitor, wait and re-check when getty not running to avoid false alert. 

This is cherry-pick PR for: https://github.com/sonic-net/sonic-buildimage/pull/14402

#### Why I did it
On S6100, the serial-getty service some time can't auto-restart by systemd. So there is a monit unit to check serial-getty service status and restart it.

However, this monit will report false alert, because in most case when serial-getty not running, systemd can restart it successfully.

To avoid the false alert, improve the monitor to wait and re-check.

Steps to reproduce this issue:
1. User login to device via console, and keep the connection.
2. User login to device via SSH, check the serial-getty@ttyS1.service service, it's running.
3. Run 'monit reload' from SSH connection.
4. Check syslog 1 minutes later, there will be false alert: ' 'serial-getty' process is not running'

##### Work item tracking
- Microsoft ADO :17424426

#### How I did it
Add check-getty.sh script to recheck again later when getty service not running.
And update monit unit to check serial-getty service status with this script to avoid false alert.

#### How to verify it
Pass all UT.
Manually check fixed code work correctly:


```
admin@***:~$ sudo systemctl stop  serial-getty@ttyS1.service
admin@***:~$ sudo /usr/local/bin/check-getty.sh 
admin@***:~$ echo $?
1
admin@***:~$ sudo systemctl status serial-getty@ttyS1.serviceserial-getty@ttyS1.service - Serial Getty on ttyS1
     Loaded: loaded (/lib/systemd/system/serial-getty@.service; enabled-runtime; vendor preset: enabled)
     Active: inactive (dead) since Tue 2023-03-28 07:15:21 UTC; 1min 13s ago

admin@***:~$ sudo /usr/local/bin/check-getty.sh 
admin@***:~$ echo $?
0
admin@***:~$ sudo systemctl status serial-getty@ttyS1.serviceserial-getty@ttyS1.service - Serial Getty on ttyS1
     Loaded: loaded (/lib/systemd/system/serial-getty@.service; enabled-runtime; vendor preset: enabled)
```

syslog:
```
Mar 28 07:10:37.597458 *** INFO systemd[1]: serial-getty@ttyS1.service: Succeeded.
Mar 28 07:12:43.010550 *** ERR monit[593]: 'serial-getty' status failed (1) -- no output
Mar 28 07:12:43.010744 *** INFO monit[593]: 'serial-getty' trying to restart
Mar 28 07:12:43.010846 *** INFO monit[593]: 'serial-getty' stop: '/bin/systemctl stop serial-getty@ttyS1.service'
Mar 28 07:12:43.132172 *** INFO monit[593]: 'serial-getty' start: '/bin/systemctl start serial-getty@ttyS1.service'
Mar 28 07:13:43.286276 *** INFO monit[593]: 'serial-getty' status succeeded (0) -- no output
```

#### Tested branch (Please provide the tested image version)

- [x] 20201231.77

#### Description for the changelog
[S6100] Improve S6100 serial-getty monitor.
2023-04-20 23:10:01 -07:00
..
barefoot [ BFN ] update SDE package for BFN platform (#10049) 2022-03-04 20:43:08 -08:00
broadcom [S6100] Improve S6100 serial-getty monitor, wait and re-check when getty not running to avoid false alert. (#14402) (#14755) 2023-04-20 23:10:01 -07:00
cavium [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
centec [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
centec-arm64 [arm] support compile sonic arm image on arm server (#7285) 2021-05-02 08:11:56 -07:00
checkout [cisco-8000] update platform module to 0.2.7 (#14172) 2023-04-03 20:36:11 -07:00
generic [dockers] Rename 'docker-snmp-sv2' to 'docker-snmp' (#4699) 2020-06-11 16:04:23 -07:00
innovium Innovium: update 202012 build files (#8524) 2021-09-14 19:17:01 -07:00
marvell [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
marvell-arm64 [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
marvell-armhf [marvell-armhf][uboot] Fixed the uboot setting for sonic-installer set-default form 202012 to 202205 branch. (#13911) 2023-03-08 15:27:49 -08:00
mellanox [202012][Mellanox] update sdk/fw build procedure (#14025) (#14220) 2023-03-16 12:42:19 +02:00
nephos [202012][Monit] Deprecate the feature of monitoring the critical processes by Monit (#7823) 2021-06-09 09:04:22 -07:00
p4 Add support to start fdbsyncd when orchagent docker starts (#5979) 2020-12-24 18:36:01 -08:00
pddf [PDDF] Build and install Python 3 package (#6286) 2021-02-23 23:56:01 +00:00
template Add gearbox phy device files and a new physyncd docker to support VS gearbox phy feature (#4851) 2020-09-25 08:32:44 -07:00
vs [SAI-PTF][202012]Fix sai ptf 202012 (#12724) 2022-11-16 20:32:24 -08:00