From 310f897067719da92c0460e0cee990418a9d2857 Mon Sep 17 00:00:00 2001 From: ETWen Date: Thu, 20 Aug 2026 10:47:35 +0800 Subject: [PATCH] feat(bmc): Add bmc_monitor.sh, log build/uptime/reboot-cause in A and C bmc_monitor.sh (V1.1.0): polls the BMC from the SONiC host via `bmc-manager run`, appending to a rotating log. Runs detached, so no interactive SSH session to the BMC is needed and the BMC's busybox toolchain never comes into play. Subcommands start/stop/status/fg/tail/ clear; the polled command list, interval, per-command timeout and log rotation are configured at the top of the file. START_LOG_MODE defaults to "new", so one run means one log. Default COMMANDS are `free -m` and `memtester 500M 1`, i.e. the BMC is memory-stressed alongside the host soak. Script A: `show boot` after the time sync to record the image the DUT booted, and `show uptime` at the end of the traffic baseline. Script C: `show reboot-cause` and `show uptime` after the traffic report, so an unplanned reset during the soak is visible in the closing snapshot rather than only in dmesg. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_014RetWKFZFG1ZHcitQAyhwM --- src/Script_ABC_Blanton/1_Blanton_Script_A.ttl | 7 + src/Script_ABC_Blanton/3_Blanton_Script_C.ttl | 6 + .../Blanton_Script/bmc_monitor.sh | 341 ++++++++++++++++++ 3 files changed, 354 insertions(+) create mode 100644 src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh diff --git a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl index 009262f..eabac5b 100644 --- a/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl +++ b/src/Script_ABC_Blanton/1_Blanton_Script_A.ttl @@ -49,6 +49,9 @@ gettime timestr sprintf2 cmd 'sudo date -s "%s %s"' datestr timestr sendln cmd +; ========== Show Build Name ========== +sendln "show boot" + ; ========== Load Shell Script ========== wait prompt_sonic_root sendln "source ~/Blanton_Script/blanton_fpga_pcimem.sh" @@ -112,6 +115,10 @@ sendln "blanton_traffic_linespeed stop" wait prompt_sonic_root sendln "blanton_traffic_linespeed report" +; ========== Show Power on uptime ========== +wait prompt_sonic_root +sendln "show uptime" + wait prompt_sonic_root messagebox 'Start Script B' 'Script A DONE' \ No newline at end of file diff --git a/src/Script_ABC_Blanton/3_Blanton_Script_C.ttl b/src/Script_ABC_Blanton/3_Blanton_Script_C.ttl index 6ce7df8..016a234 100644 --- a/src/Script_ABC_Blanton/3_Blanton_Script_C.ttl +++ b/src/Script_ABC_Blanton/3_Blanton_Script_C.ttl @@ -37,5 +37,11 @@ sendln "blanton_traffic_linespeed stop" wait prompt_sonic_root sendln "blanton_traffic_linespeed report" +wait prompt_sonic_root +sendln "show reboot-cause" + +; ========== Show Power on uptime ========== +wait prompt_sonic_root +sendln "show uptime" messagebox 'GOOD JOB! Test Case DONE' 'teraterm' \ No newline at end of file diff --git a/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh new file mode 100644 index 0000000..40af6fd --- /dev/null +++ b/src/Script_ABC_Blanton/Blanton_Script/bmc_monitor.sh @@ -0,0 +1,341 @@ +#!/bin/bash +############################################################################### +# bmc_monitor.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=( + "free -m" + "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=30 + +# 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 =