forked from sonic-net/sonic-buildimage
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Celestica-E1031] Enable CPU watchdog (sonic-net#16083)
Enable CPU watchdog on Celestica-E1031.
- Loading branch information
1 parent
3fe7223
commit 811d156
Showing
4 changed files
with
105 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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 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
89 changes: 89 additions & 0 deletions
89
platform/broadcom/sonic-platform-modules-cel/haliburton/script/cpu_wdt
This file contains 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,89 @@ | ||
#!/bin/bash | ||
|
||
SYSLOG_IDENTIFIER="cpu_wdt" | ||
CPUWDT_MAIN_TASK_RUNNING_FLAG=true | ||
TIMEOUT=180 | ||
KEEPALIVE=60 | ||
|
||
function log_info() | ||
{ | ||
logger -p info -t ${SYSLOG_IDENTIFIER} "$@" | ||
} | ||
|
||
function usage() | ||
{ | ||
echo "Usage: $0 ACTION [OPTIONS]..." | ||
echo "" | ||
echo "Actions:" | ||
echo " start Start CPU WDT" | ||
echo " stop Stop CPU WDT" | ||
echo "" | ||
echo "Options:" | ||
echo " -h Show this help" | ||
echo " -t <timeout> WDT timeout period: {30|60|180}, default 180" | ||
echo " -k <keepalive> WDT keep alive period, {1..(timeout-5)}, default 60" | ||
exit 1 | ||
} | ||
|
||
function validate_action() | ||
{ | ||
if [[ "${ACTION}" != "start" && "${ACTION}" != "stop" ]]; then | ||
echo -e "Invalid action: ${ACTION}\n" | ||
usage | ||
fi | ||
} | ||
|
||
function validate_options() | ||
{ | ||
if [[ ${TIMEOUT} != "30" && ${TIMEOUT} != "60" && ${TIMEOUT} != "180" ]]; then | ||
echo -e "Invalid timeout value: ${TIMEOUT}\n" | ||
usage | ||
fi | ||
if [[ ${KEEPALIVE} -le 0 || ${KEEPALIVE} -gt $((TIMEOUT - 5)) ]]; then | ||
echo "Invalid keepalive value: ${KEEPALIVE}" | ||
echo "" | ||
usage | ||
fi | ||
} | ||
|
||
trap 'log_info "Caught SIGHUP - ignoring..."' SIGHUP | ||
trap 'log_info "Caught SIGINT - exiting..."; CPUWDT_MAIN_TASK_RUNNING_FLAG=false' SIGINT | ||
trap 'log_info "Caught SIGTERM - exiting..."; CPUWDT_MAIN_TASK_RUNNING_FLAG=false' SIGTERM | ||
|
||
ACTION=$1 | ||
shift | ||
validate_action | ||
|
||
while getopts "t:k:" OPTION; do | ||
case $OPTION in | ||
t) | ||
TIMEOUT=${OPTARG} | ||
;; | ||
k) | ||
KEEPALIVE=${OPTARG} | ||
;; | ||
*) | ||
usage | ||
esac | ||
done | ||
|
||
validate_options | ||
|
||
if [[ "${ACTION}" == "start" ]]; then | ||
# enable | ||
log_info "Enable CPU WDT.." | ||
watchdogutil arm -s "${TIMEOUT}" > /dev/null | ||
log_info "CPU WDT has been enabled with $TIMEOUT seconds timeout" | ||
|
||
# keep alive | ||
log_info "Enable keep alive messaging every $KEEPALIVE seconds" | ||
while [[ ${CPUWDT_MAIN_TASK_RUNNING_FLAG} == "true" ]]; do | ||
watchdogutil arm -s "${TIMEOUT}" > /dev/null | ||
sleep "${KEEPALIVE}" | ||
done | ||
log_info "Keep alive messaging has been disabled" | ||
fi | ||
|
||
log_info "Disable CPU WDT.." | ||
watchdogutil disarm | ||
log_info "CPU WDT has been disabled!" |
10 changes: 10 additions & 0 deletions
10
platform/broadcom/sonic-platform-modules-cel/haliburton/systemd/cpu_wdt.service
This file contains 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,10 @@ | ||
[Unit] | ||
Description=CPU WDT | ||
After=platform-modules-haliburton.service | ||
Requires=platform-modules-haliburton.service | ||
|
||
[Service] | ||
ExecStart=-/usr/local/bin/cpu_wdt start | ||
|
||
[Install] | ||
WantedBy=multi-user.target |