repro_lock.sh
Shell Script · 25 lines
#!/usr/bin/env bash# 复现场景④:锁竞争。使用赛题官方 stress-ng --mutex 注入锁争用,# 同时运行 ebpf-rca(lock) 做 off-CPU 阻塞 + 唤醒链分析并输出诊断。set -euo pipefail
DUR="${1:-60}"BIN="$(dirname "$0")/../bin/ebpf-rca"
if ! command -v stress-ng >/dev/null 2>&1; then echo "请先安装 stress-ng(make deps 或 apt-get install stress-ng)" >&2 exit 1fi
echo "[repro] 启动 ebpf-rca 场景=lock(后台)..."sudo "$BIN" --scenario lock --interval 1s --threshold 0.30 --sustain 3 \ --format md --duration "${DUR}s" &RCA_PID=$!
sleep 2echo "[repro] 注入锁竞争负载(官方脚本)..."stress-ng --mutex 8 --timeout "${DUR}s" --metrics-brief || true
wait "$RCA_PID" 2>/dev/null || trueecho "[repro] 完成。"





