From 855b7a6e30ead43cce1936a7cb381d783f9fad00 Mon Sep 17 00:00:00 2001 From: ETWen Date: Thu, 20 Aug 2026 11:00:04 +0800 Subject: [PATCH] feat(bmc): Split DDR stress out of bmc_monitor into bmc_monitor_ddr.sh bmc_monitor.sh was doing two unrelated jobs: sampling `free -m` every few seconds, and running `memtester 500M 1` as a stress load. They want different timeouts -- a monitor should give up in 30 s, a memtester pass legitimately runs for minutes -- and mixing them meant either cutting memtester short or letting a hung sample stall the loop. bmc_monitor.sh now polls `free -m` only, keeping CMD_TIMEOUT_SEC=30. bmc_monitor_ddr.sh is the stress half: memtester only, with CMD_TIMEOUT_SEC raised to 3600. The two are otherwise identical. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM --- .../Blanton_Script/bmc_monitor.sh | 1 - .../Blanton_Script/bmc_monitor_ddr.sh | 340 ++++++++++++++++++ 2 files changed, 340 insertions(+), 1 deletion(-) create mode 100644 src/Script_ABC_Blanton/Blanton_Script/bmc_monitor_ddr.sh diff --git a/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh index 40af6fd..87b3d11 100644 --- a/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh +++ b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh @@ -34,7 +34,6 @@ set -u # Add a line to add a command; comment it out to disable it. COMMANDS=( "free -m" - "memtester 500M 1" #"uptime" #"cat /proc/loadavg" #"cat /proc/meminfo" diff --git a/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor_ddr.sh b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor_ddr.sh new file mode 100644 index 0000000..ef8d106 --- /dev/null +++ b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor_ddr.sh @@ -0,0 +1,340 @@ +#!/bin/bash +############################################################################### +# bmc_monitor_ddr.sh +# +# Version : V1.1.0 +# Author : ETWen +# Date : 20260820 +# +# Purpose : Periodically execute a list of commands on the BMC through +# `bmc-manager run ""` from the SONiC host side, and append all +# output to a rotating log file. Designed to run detached in the +# background so no interactive SSH session to the BMC is required. +# +# Notes : - Everything runs on the HOST. Nothing is deployed to the BMC, so +# the BMC busybox toolchain (no base64 / no setsid ...) is a +# non-issue. +# - `bmc-manager run` prints the remote command output on stdout and +# its own banner on stderr; the two streams are captured separately +# so the log stays clean. +# +# Version History +# V1.0.0 20260820 Initial Version +# V1.1.0 20260820 `start` clears the previous log by default +# (START_LOG_MODE: new / archive / append) +############################################################################### + +set -u + +############################################################################### +# User Configurable Section -- normally this is the only part you need to edit +############################################################################### + +# Commands executed on the BMC, one per line, in this order. +# Add a line to add a command; comment it out to disable it. +COMMANDS=( + "memtester 500M 1" + #"uptime" + #"cat /proc/loadavg" + #"cat /proc/meminfo" + #"df -h /tmp" + #"dmesg | tail -n 30" +) + +# Seconds to wait after a full round (all COMMANDS executed) before the next one +INTERVAL_SEC=5 + +# Seconds to wait between two commands inside the same round (0 = no wait) +INTER_CMD_DELAY_SEC=0 + +# Per-command timeout in seconds; prevents a hung bmc-manager from freezing the +# whole loop. Set to 0 to disable. +CMD_TIMEOUT_SEC=3600 + +# Stop after this many rounds. 0 = run until stopped manually. +MAX_ROUNDS=0 + +# Command runner. Final invocation is: +# "$RUNNER_BIN" "${RUNNER_ARGS[@]}" "" +# BMC side : RUNNER_BIN="bmc-manager" ; RUNNER_ARGS=(run) +# BMC by IP : RUNNER_BIN="bmc-manager" ; RUNNER_ARGS=(--ip 192.168.200.200 run) +# Host side : RUNNER_BIN="bash" ; RUNNER_ARGS=(-c) +RUNNER_BIN="bmc-manager" +RUNNER_ARGS=(run) + +# stderr handling of the runner (bmc-manager banner lives here) +# 0 = log stderr only when the command fails (recommended, keeps log clean) +# 1 = always log stderr +LOG_STDERR=0 + +# Logging +LOG_DIR="" # empty =